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_ILI9806.h (6536B)

      1 #ifndef _ARDUINO_ILI9806_H_
      2 #define _ARDUINO_ILI9806_H_
      3 
      4 #include <Arduino.h>
      5 #include <Print.h>
      6 #include "../Arduino_GFX.h"
      7 #include "../Arduino_TFT.h"
      8 
      9 #define ILI9806_TFTWIDTH 480  ///< ILI9806 max TFT width
     10 #define ILI9806_TFTHEIGHT 854 ///< ILI9806 max TFT height
     11 
     12 #define ILI9806_RST_DELAY 120    ///< delay ms wait for reset finish
     13 #define ILI9806_SLPIN_DELAY 120  ///< delay ms wait for sleep in finish
     14 #define ILI9806_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
     15 
     16 #define ILI9806_NOP 0x00     ///< No-op register
     17 #define ILI9806_SWRESET 0x01 ///< Software reset register
     18 #define ILI9806_RDDID 0x04   ///< Read display identification information
     19 #define ILI9806_RDDST 0x09   ///< Read Display Status
     20 
     21 #define ILI9806_SLPIN 0x10  ///< Enter Sleep Mode
     22 #define ILI9806_SLPOUT 0x11 ///< Sleep Out
     23 #define ILI9806_PTLON 0x12  ///< Partial Mode ON
     24 #define ILI9806_NORON 0x13  ///< Normal Display Mode ON
     25 
     26 #define ILI9806_RDMODE 0x0A     ///< Read Display Power Mode
     27 #define ILI9806_RDMADCTL 0x0B   ///< Read Display MADCTL
     28 #define ILI9806_RDPIXFMT 0x0C   ///< Read Display Pixel Format
     29 #define ILI9806_RDIMGFMT 0x0D   ///< Read Display Image Format
     30 #define ILI9806_RDSELFDIAG 0x0F ///< Read Display Self-Diagnostic Result
     31 
     32 #define ILI9806_INVOFF 0x20   ///< Display Inversion OFF
     33 #define ILI9806_INVON 0x21    ///< Display Inversion ON
     34 #define ILI9806_GAMMASET 0x26 ///< Gamma Set
     35 #define ILI9806_DISPOFF 0x28  ///< Display OFF
     36 #define ILI9806_DISPON 0x29   ///< Display ON
     37 
     38 #define ILI9806_CASET 0x2A ///< Column Address Set
     39 #define ILI9806_PASET 0x2B ///< Page Address Set
     40 #define ILI9806_RAMWR 0x2C ///< Memory Write
     41 #define ILI9806_RAMRD 0x2E ///< Memory Read
     42 
     43 #define ILI9806_PTLAR 0x30    ///< Partial Area
     44 #define ILI9806_VSCRDEF 0x33  ///< Vertical Scrolling Definition
     45 #define ILI9806_MADCTL 0x36   ///< Memory Access Control
     46 #define ILI9806_VSCRSADD 0x37 ///< Vertical Scrolling Start Address
     47 #define ILI9806_PIXFMT 0x3A   ///< COLMOD: Pixel Format Set
     48 
     49 #define ILI9806_FRMCTR1 0xB1 ///< Frame Rate Control (In Normal Mode/Full Colors)
     50 #define ILI9806_FRMCTR2 0xB2 ///< Frame Rate Control (In Idle Mode/8 colors)
     51 #define ILI9806_FRMCTR3 0xB3 ///< Frame Rate control (In Partial Mode/Full Colors)
     52 #define ILI9806_INVCTR 0xB4  ///< Display Inversion Control
     53 #define ILI9806_DFUNCTR 0xB6 ///< Display Function Control
     54 
     55 #define ILI9806_PWCTR1 0xC0 ///< Power Control 1
     56 #define ILI9806_PWCTR2 0xC1 ///< Power Control 2
     57 #define ILI9806_PWCTR3 0xC2 ///< Power Control 3
     58 #define ILI9806_PWCTR4 0xC3 ///< Power Control 4
     59 #define ILI9806_PWCTR5 0xC4 ///< Power Control 5
     60 #define ILI9806_VMCTR1 0xC5 ///< VCOM Control 1
     61 #define ILI9806_VMCTR2 0xC7 ///< VCOM Control 2
     62 
     63 #define ILI9806_RDID1 0xDA ///< Read ID 1
     64 #define ILI9806_RDID2 0xDB ///< Read ID 2
     65 #define ILI9806_RDID3 0xDC ///< Read ID 3
     66 #define ILI9806_RDID4 0xDD ///< Read ID 4
     67 
     68 #define ILI9806_GMCTRP1 0xE0 ///< Positive Gamma Correction
     69 #define ILI9806_GMCTRN1 0xE1 ///< Negative Gamma Correction
     70 #define ILI9806_PWCTR6 0xFC
     71 
     72 #define ILI9806_MADCTL_MY 0x80  ///< Bottom to top
     73 #define ILI9806_MADCTL_MX 0x40  ///< Right to left
     74 #define ILI9806_MADCTL_MV 0x20  ///< Reverse Mode
     75 #define ILI9806_MADCTL_ML 0x10  ///< LCD refresh Bottom to top
     76 #define ILI9806_MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
     77 #define ILI9806_MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
     78 #define ILI9806_MADCTL_MH 0x04  ///< LCD refresh right to left
     79 
     80 static const uint8_t ili9806_init_operations[] = {
     81     BEGIN_WRITE,
     82     WRITE_COMMAND_8, 0xFF, // EXTC Command Set enable register
     83     WRITE_BYTES, 3, 0xFF, 0x98, 0x06,
     84 
     85     WRITE_C8_D8, 0xBA, 0x60, // SPI Interface Setting
     86 
     87     WRITE_COMMAND_8, 0xBC, // GIP 1
     88     WRITE_BYTES, 21,
     89     0x01, 0x10, 0x00, 0x00, 0x01,
     90     0x01, 0x0B, 0x11, 0x32, 0x10,
     91     0x00, 0x00, 0x01, 0x01, 0x01,
     92     0x01, 0x50, 0x52, 0x01, 0x00,
     93     0x40,
     94 
     95     WRITE_COMMAND_8, 0xBD, // GIP 2
     96     WRITE_BYTES, 8,
     97     0x01, 0x23, 0x45, 0x67, 0x01,
     98     0x23, 0x45, 0x67,
     99 
    100     WRITE_COMMAND_8, 0xBE, // GIP 3
    101     WRITE_BYTES, 9,
    102     0x00, 0x21, 0xAB, 0x60, 0x22,
    103     0x22, 0x22, 0x22, 0x22,
    104 
    105     WRITE_C8_D8, 0xC7, 0x30, // VCOM Control
    106 
    107     WRITE_COMMAND_8, 0xED, // EN_volt_reg
    108     WRITE_BYTES, 3, 0x7F, 0x0F, 0x00,
    109 
    110     WRITE_COMMAND_8, 0xC0,            // Power Control 1
    111     WRITE_BYTES, 3, 0x03, 0x0B, 0x0C, // 0A VGH VGL
    112 
    113     WRITE_COMMAND_8, 0xFD, // External Power Selection Set
    114     WRITE_BYTES, 2, 0x0A, 0x00,
    115 
    116     WRITE_C8_D8, 0xFC, 0x08, // LVGL
    117 
    118     WRITE_COMMAND_8, 0xDF, // Engineering Setting
    119     WRITE_BYTES, 6,
    120     0x00, 0x00, 0x00, 0x00, 0x00,
    121     0x20,
    122 
    123     WRITE_C8_D8, 0xF3, 0x74, // DVDD Voltage Setting
    124 
    125     WRITE_COMMAND_8, 0xB4, // Display Inversion Control
    126     WRITE_BYTES, 3, 0x00, 0x00, 0x00,
    127 
    128     WRITE_COMMAND_8, 0xB5, // Blanking Porch Control
    129     WRITE_BYTES, 2, 0x08, 0x15,
    130 
    131     WRITE_C8_D8, 0xF7, 0x81, // 480x854
    132 
    133     WRITE_COMMAND_8, 0xB1, // Frame Rate Control
    134     WRITE_BYTES, 3, 0x00, 0x13, 0x13,
    135 
    136     WRITE_COMMAND_8, 0xF2, // Panel Timing Control
    137     WRITE_BYTES, 4, 0x80, 0x04, 0x40, 0x28,
    138 
    139     WRITE_COMMAND_8, 0xC1, // Power Control 2
    140     WRITE_BYTES, 3,
    141     0x17,
    142     0x71, // VGMP
    143     0x71, // VGMN
    144 
    145     WRITE_COMMAND_8, 0xE0, // P_Gamma
    146     WRITE_BYTES, 16,
    147     0x00, // P1
    148     0x13, // P2
    149     0x1A, // P3
    150     0x0C, // P4
    151     0x0E, // P5
    152     0x0B, // P6
    153     0x07, // P7
    154     0x05, // P8
    155     0x05, // P9
    156     0x0A, // P10
    157     0x0F, // P11
    158     0x0F, // P12
    159     0x0E, // P13
    160     0x1C, // P14
    161     0x16, // P15
    162     0x00, // P16
    163 
    164     WRITE_COMMAND_8, 0xE1, // N_Gamma
    165     WRITE_BYTES, 16,
    166     0x00, // P1
    167     0x13, // P2
    168     0x1A, // P3
    169     0x0C, // P4
    170     0x0E, // P5
    171     0x0B, // P6
    172     0x07, // P7
    173     0x05, // P8
    174     0x05, // P9
    175     0x0A, // P10
    176     0x0F, // P11
    177     0x0F, // P12
    178     0x0E, // P13
    179     0x1C, // P14
    180     0x16, // P15
    181     0x00, // P16
    182 
    183     WRITE_C8_D8, 0x3A, 0x55, // 55-16BIT,66-18BIT,77-24BIT
    184 
    185     WRITE_COMMAND_8, 0x11,
    186     END_WRITE,
    187 
    188     DELAY, ILI9806_SLPOUT_DELAY,
    189 
    190     BEGIN_WRITE,
    191     WRITE_COMMAND_8, 0x29,
    192     END_WRITE,
    193 
    194     DELAY, 25,
    195 
    196     BEGIN_WRITE,
    197     WRITE_COMMAND_8, 0x2C,
    198     END_WRITE};
    199 
    200 class Arduino_ILI9806 : public Arduino_TFT
    201 {
    202 public:
    203   Arduino_ILI9806(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
    204 
    205   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    206 
    207   void setRotation(uint8_t r) override;
    208 
    209   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    210 
    211   void invertDisplay(bool) override;
    212   void displayOn() override;
    213   void displayOff() override;
    214 
    215 protected:
    216   void tftInit() override;
    217 
    218 private:
    219 };
    220 
    221 #endif