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_R61529.cpp (2611B)
1 /* 2 * start rewrite from: 3 * https://github.com/adafruit/Adafruit-GFX-Library.git 4 * https://github.com/daumemo/IPS_LCD_R61529_FT6236_Arduino_eSPI_Test 5 */ 6 #include "Arduino_R61529.h" 7 8 Arduino_R61529::Arduino_R61529(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips) 9 : Arduino_TFT(bus, rst, r, ips, R61529_TFTWIDTH, R61529_TFTHEIGHT, 0, 0, 0, 0) 10 { 11 } 12 13 bool Arduino_R61529::begin(int32_t speed) 14 { 15 return Arduino_TFT::begin(speed); 16 } 17 18 // Companion code to the above tables. Reads and issues 19 // a series of LCD commands stored in PROGMEM byte array. 20 void Arduino_R61529::tftInit() 21 { 22 if (_rst != GFX_NOT_DEFINED) 23 { 24 pinMode(_rst, OUTPUT); 25 digitalWrite(_rst, HIGH); 26 delay(100); 27 digitalWrite(_rst, LOW); 28 delay(R61529_RST_DELAY); 29 digitalWrite(_rst, HIGH); 30 delay(R61529_RST_DELAY); 31 } 32 else 33 { 34 // Software Rest 35 _bus->sendCommand(R61529_SWRESET); 36 delay(R61529_RST_DELAY); 37 } 38 39 _bus->batchOperation(r61529_init_operations, sizeof(r61529_init_operations)); 40 } 41 42 void Arduino_R61529::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) 43 { 44 if ((x != _currentX) || (w != _currentW)) 45 { 46 _bus->writeC8D16D16Split(R61529_CASET, x + _xStart, x + w - 1 + _xStart); 47 48 _currentX = x; 49 _currentW = w; 50 } 51 if ((y != _currentY) || (h != _currentH)) 52 { 53 _bus->writeC8D16D16Split(R61529_PASET, y + _yStart, y + h - 1 + _yStart); 54 55 _currentY = y; 56 _currentH = h; 57 } 58 59 _bus->writeCommand(R61529_RAMWR); // write to RAM 60 } 61 62 /**************************************************************************/ 63 /*! 64 @brief Set origin of (0,0) and orientation of TFT display 65 @param m The index for rotation, from 0-3 inclusive 66 */ 67 /**************************************************************************/ 68 void Arduino_R61529::setRotation(uint8_t r) 69 { 70 Arduino_TFT::setRotation(r); 71 switch (_rotation) 72 { 73 case 1: 74 r = R61529_MADCTL_MV | R61529_MADCTL_MX | R61529_MADCTL_RGB; 75 break; 76 case 2: 77 r = R61529_MADCTL_RGB | R61529_MADCTL_GS | R61529_MADCTL_MX; 78 break; 79 case 3: 80 r = R61529_MADCTL_MV | R61529_MADCTL_RGB | R61529_MADCTL_GS; 81 break; 82 default: // case 0: 83 r = R61529_MADCTL_RGB; 84 break; 85 } 86 _bus->beginWrite(); 87 _bus->writeCommand(R61529_MADCTL); 88 _bus->write(r); 89 _bus->endWrite(); 90 } 91 92 void Arduino_R61529::invertDisplay(bool i) 93 { 94 _bus->sendCommand(i ? R61529_INVON : R61529_INVOFF); 95 } 96 97 void Arduino_R61529::displayOn(void) 98 { 99 _bus->sendCommand(R61529_SLPOUT); 100 delay(R61529_SLPOUT_DELAY); 101 } 102 103 void Arduino_R61529::displayOff(void) 104 { 105 _bus->sendCommand(R61529_SLPIN); 106 delay(R61529_SLPIN_DELAY); 107 }