acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
Arduino_NT39125.cpp (2721B)
1 /* 2 * start rewrite from: 3 * https://github.com/adafruit/Adafruit-GFX-Library.git 4 * https://github.com/daumemo/IPS_LCD_NT39125_FT6236_Arduino_eSPI_Test 5 */ 6 #include "Arduino_NT39125.h" 7 8 Arduino_NT39125::Arduino_NT39125( 9 Arduino_DataBus *bus, int8_t rst, uint8_t r, 10 bool ips, int16_t w, int16_t h, 11 uint8_t col_offset1, uint8_t row_offset1, uint8_t col_offset2, uint8_t row_offset2) 12 : Arduino_TFT(bus, rst, r, ips, w, h, col_offset1, row_offset1, col_offset2, row_offset2) 13 { 14 } 15 16 bool Arduino_NT39125::begin(int32_t speed) 17 { 18 return Arduino_TFT::begin(speed); 19 } 20 21 void Arduino_NT39125::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) 22 { 23 if ((x != _currentX) || (w != _currentW)) 24 { 25 _bus->writeC8D16D16(NT39125_CASET, x + _xStart, x + w - 1 + _xStart); 26 27 _currentX = x; 28 _currentW = w; 29 } 30 if ((y != _currentY) || (h != _currentH)) 31 { 32 _bus->writeC8D16D16(NT39125_RASET, y + _yStart, y + h - 1 + _yStart); 33 34 _currentY = y; 35 _currentH = h; 36 } 37 38 _bus->writeCommand(NT39125_RAMWR); // write to RAM 39 } 40 41 /**************************************************************************/ 42 /*! 43 @brief Set origin of (0,0) and orientation of TFT display 44 @param m The index for rotation, from 0-3 inclusive 45 */ 46 /**************************************************************************/ 47 void Arduino_NT39125::setRotation(uint8_t r) 48 { 49 Arduino_TFT::setRotation(r); 50 switch (_rotation) 51 { 52 case 3: 53 r = NT39125_MADCTL_BGR | NT39125_MADCTL_MV | NT39125_MADCTL_MX | NT39125_MADCTL_MY; 54 break; 55 case 2: 56 r = NT39125_MADCTL_BGR | NT39125_MADCTL_MY; 57 break; 58 case 1: 59 r = NT39125_MADCTL_BGR | NT39125_MADCTL_MV; 60 break; 61 default: // case 0: 62 r = NT39125_MADCTL_BGR | NT39125_MADCTL_MX; 63 break; 64 } 65 _bus->beginWrite(); 66 _bus->writeCommand(NT39125_MADCTL); 67 _bus->write(r); 68 _bus->endWrite(); 69 } 70 71 void Arduino_NT39125::invertDisplay(bool i) 72 { 73 _bus->sendCommand((_ips ^ i) ? NT39125_INVON : NT39125_INVOFF); 74 } 75 76 void Arduino_NT39125::displayOn(void) 77 { 78 _bus->sendCommand(NT39125_SLPOUT); 79 delay(NT39125_SLPOUT_DELAY); 80 } 81 82 void Arduino_NT39125::displayOff(void) 83 { 84 _bus->sendCommand(NT39125_SLPIN); 85 delay(NT39125_SLPIN_DELAY); 86 } 87 88 void Arduino_NT39125::tftInit() 89 { 90 if (_rst != GFX_NOT_DEFINED) 91 { 92 pinMode(_rst, OUTPUT); 93 digitalWrite(_rst, HIGH); 94 delay(100); 95 digitalWrite(_rst, LOW); 96 delay(NT39125_RST_DELAY); 97 digitalWrite(_rst, HIGH); 98 delay(NT39125_RST_DELAY); 99 } 100 else 101 { 102 // Software Rest 103 _bus->sendCommand(NT39125_SWRESET); 104 delay(NT39125_RST_DELAY); 105 } 106 107 _bus->batchOperation(nt39125_init_operations, sizeof(nt39125_init_operations)); 108 109 if (_ips) 110 { 111 _bus->sendCommand(NT39125_INVON); 112 } 113 }