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_ILI9488_18bit.cpp (2754B)

      1 #include "Arduino_ILI9488_18bit.h"
      2 
      3 Arduino_ILI9488_18bit::Arduino_ILI9488_18bit(Arduino_DataBus *bus, int8_t rst, uint8_t r, bool ips)
      4     : Arduino_TFT_18bit(bus, rst, r, ips, ILI9488_TFTWIDTH, ILI9488_TFTHEIGHT, 0, 0, 0, 0)
      5 {
      6 }
      7 
      8 bool Arduino_ILI9488_18bit::begin(int32_t speed)
      9 {
     10   return Arduino_TFT::begin(speed);
     11 }
     12 
     13 /**************************************************************************/
     14 /*!
     15     @brief   Set origin of (0,0) and orientation of TFT display
     16     @param   m  The index for rotation, from 0-3 inclusive
     17 */
     18 /**************************************************************************/
     19 void Arduino_ILI9488_18bit::setRotation(uint8_t r)
     20 {
     21   Arduino_TFT::setRotation(r);
     22   switch (_rotation)
     23   {
     24   case 1:
     25     r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV);
     26     break;
     27   case 2:
     28     r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MY);
     29     break;
     30   case 3:
     31     r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MV | ILI9488_MADCTL_MX | ILI9488_MADCTL_MY);
     32     break;
     33   default: // case 0:
     34     r = (ILI9488_MADCTL_BGR | ILI9488_MADCTL_MX);
     35     break;
     36   }
     37   _bus->beginWrite();
     38   _bus->writeC8D8(ILI9488_MADCTL, r);
     39   _bus->endWrite();
     40 }
     41 
     42 void Arduino_ILI9488_18bit::writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h)
     43 {
     44   if ((x != _currentX) || (w != _currentW))
     45   {
     46     _currentX = x;
     47     _currentW = w;
     48     x += _xStart;
     49     _bus->writeC8D16D16(ILI9488_CASET, x, x + w - 1);
     50   }
     51   if ((y != _currentY) || (h != _currentH))
     52   {
     53     _currentY = y;
     54     _currentH = h;
     55     y += _yStart;
     56     _bus->writeC8D16D16(ILI9488_PASET, y, y + h - 1);
     57   }
     58 
     59   _bus->writeCommand(ILI9488_RAMWR); // write to RAM
     60 }
     61 
     62 void Arduino_ILI9488_18bit::invertDisplay(bool i)
     63 {
     64   _bus->sendCommand(i ? ILI9488_INVON : ILI9488_INVOFF);
     65 }
     66 
     67 void Arduino_ILI9488_18bit::displayOn(void)
     68 {
     69   _bus->sendCommand(ILI9488_SLPOUT);
     70   delay(ILI9488_SLPOUT_DELAY);
     71 }
     72 
     73 void Arduino_ILI9488_18bit::displayOff(void)
     74 {
     75   _bus->sendCommand(ILI9488_SLPIN);
     76   delay(ILI9488_SLPIN_DELAY);
     77 }
     78 
     79 // Companion code to the above tables.  Reads and issues
     80 // a series of LCD commands stored in PROGMEM byte array.
     81 void Arduino_ILI9488_18bit::tftInit()
     82 {
     83   if (_rst != GFX_NOT_DEFINED)
     84   {
     85     pinMode(_rst, OUTPUT);
     86     digitalWrite(_rst, HIGH);
     87     delay(100);
     88     digitalWrite(_rst, LOW);
     89     delay(ILI9488_RST_DELAY);
     90     digitalWrite(_rst, HIGH);
     91     delay(ILI9488_RST_DELAY);
     92   }
     93   else
     94   {
     95     // Software Rest
     96     _bus->sendCommand(ILI9488_SWRESET);
     97     delay(ILI9488_RST_DELAY);
     98   }
     99 
    100   _bus->batchOperation(ili9488_init_operations, sizeof(ili9488_init_operations));
    101 
    102   _bus->beginWrite();
    103   _bus->writeC8D8(0x3A, 0x66); // Interface Pixel Format, 18 bit
    104   _bus->endWrite();
    105 
    106   if (_ips)
    107   {
    108     _bus->sendCommand(ILI9488_INVON);
    109   }
    110   else
    111   {
    112     _bus->sendCommand(ILI9488_INVOFF);
    113   }
    114 }