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

ST7789_Init.h (5476B)

      1 
      2 // This is the command sequence that initialises the ST7789 driver
      3 //
      4 // This setup information uses simple 8 bit SPI writecommand() and writedata() functions
      5 //
      6 // See ST7735_Setup.h file for an alternative format
      7 
      8 #ifndef INIT_SEQUENCE_3
      9 {
     10   writecommand(ST7789_SLPOUT);   // Sleep out
     11   delay(120);
     12 
     13   writecommand(ST7789_NORON);    // Normal display mode on
     14 
     15   //------------------------------display and color format setting--------------------------------//
     16   writecommand(ST7789_MADCTL);
     17   //writedata(0x00);
     18   writedata(TFT_MAD_COLOR_ORDER);
     19 
     20   // JLX240 display datasheet
     21   writecommand(0xB6);
     22   writedata(0x0A);
     23   writedata(0x82);
     24 
     25   writecommand(ST7789_RAMCTRL);
     26   writedata(0x00);
     27   writedata(0xE0); // 5 to 6 bit conversion: r0 = r5, b0 = b5
     28 
     29   writecommand(ST7789_COLMOD);
     30   writedata(0x55);
     31   delay(10);
     32 
     33   //--------------------------------ST7789V Frame rate setting----------------------------------//
     34   writecommand(ST7789_PORCTRL);
     35   writedata(0x0c);
     36   writedata(0x0c);
     37   writedata(0x00);
     38   writedata(0x33);
     39   writedata(0x33);
     40 
     41   writecommand(ST7789_GCTRL);      // Voltages: VGH / VGL
     42   writedata(0x35);
     43 
     44   //---------------------------------ST7789V Power setting--------------------------------------//
     45   writecommand(ST7789_VCOMS);
     46   writedata(0x28);		// JLX240 display datasheet
     47 
     48   writecommand(ST7789_LCMCTRL);
     49   writedata(0x0C);
     50 
     51   writecommand(ST7789_VDVVRHEN);
     52   writedata(0x01);
     53   writedata(0xFF);
     54 
     55   writecommand(ST7789_VRHS);       // voltage VRHS
     56   writedata(0x10);
     57 
     58   writecommand(ST7789_VDVSET);
     59   writedata(0x20);
     60 
     61   writecommand(ST7789_FRCTR2);
     62   writedata(0x0f);
     63 
     64   writecommand(ST7789_PWCTRL1);
     65   writedata(0xa4);
     66   writedata(0xa1);
     67 
     68   //--------------------------------ST7789V gamma setting---------------------------------------//
     69   writecommand(ST7789_PVGAMCTRL);
     70   writedata(0xd0);
     71   writedata(0x00);
     72   writedata(0x02);
     73   writedata(0x07);
     74   writedata(0x0a);
     75   writedata(0x28);
     76   writedata(0x32);
     77   writedata(0x44);
     78   writedata(0x42);
     79   writedata(0x06);
     80   writedata(0x0e);
     81   writedata(0x12);
     82   writedata(0x14);
     83   writedata(0x17);
     84 
     85   writecommand(ST7789_NVGAMCTRL);
     86   writedata(0xd0);
     87   writedata(0x00);
     88   writedata(0x02);
     89   writedata(0x07);
     90   writedata(0x0a);
     91   writedata(0x28);
     92   writedata(0x31);
     93   writedata(0x54);
     94   writedata(0x47);
     95   writedata(0x0e);
     96   writedata(0x1c);
     97   writedata(0x17);
     98   writedata(0x1b);
     99   writedata(0x1e);
    100 
    101   writecommand(ST7789_INVON);
    102 
    103   writecommand(ST7789_CASET);    // Column address set
    104   writedata(0x00);
    105   writedata(0x00);
    106   writedata(0x00);
    107   writedata(0xEF);    // 239
    108 
    109   writecommand(ST7789_RASET);    // Row address set
    110   writedata(0x00);
    111   writedata(0x00);
    112   writedata(0x01);
    113   writedata(0x3F);    // 319
    114 
    115 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    116 
    117   end_tft_write();
    118   delay(120);
    119   begin_tft_write();
    120 
    121   writecommand(ST7789_DISPON);    //Display on
    122   delay(120);
    123 
    124 #ifdef TFT_BL
    125   // Turn on the back-light LED
    126   digitalWrite(TFT_BL, HIGH);
    127   pinMode(TFT_BL, OUTPUT);
    128 #endif
    129 }
    130 
    131 
    132 #else
    133 // TTGO ESP32 S3 T-Display
    134 {
    135   writecommand(ST7789_SLPOUT);   // Sleep out
    136   delay(120);
    137 
    138   writecommand(ST7789_NORON);    // Normal display mode on
    139 
    140   //------------------------------display and color format setting--------------------------------//
    141   writecommand(ST7789_MADCTL);
    142   writedata(TFT_MAD_COLOR_ORDER);
    143 
    144  // writecommand(ST7789_RAMCTRL);
    145  // writedata(0x00);
    146  // writedata(0xE0); // 5 to 6 bit conversion: r0 = r5, b0 = b5
    147 
    148   writecommand(ST7789_COLMOD);
    149   writedata(0x55);
    150   delay(10);
    151 
    152   //--------------------------------ST7789V Frame rate setting----------------------------------//
    153   writecommand(ST7789_PORCTRL);
    154   writedata(0x0b);
    155   writedata(0x0b);
    156   writedata(0x00);
    157   writedata(0x33);
    158   writedata(0x33);
    159 
    160   writecommand(ST7789_GCTRL);      // Voltages: VGH / VGL
    161   writedata(0x75);
    162 
    163   //---------------------------------ST7789V Power setting--------------------------------------//
    164   writecommand(ST7789_VCOMS);
    165   writedata(0x28);		// JLX240 display datasheet
    166 
    167   writecommand(ST7789_LCMCTRL);
    168   writedata(0x2C);
    169 
    170   writecommand(ST7789_VDVVRHEN);
    171   writedata(0x01);
    172 
    173   writecommand(ST7789_VRHS);       // voltage VRHS
    174   writedata(0x1F);
    175 
    176   writecommand(ST7789_FRCTR2);
    177   writedata(0x13);
    178 
    179   writecommand(ST7789_PWCTRL1);
    180   writedata(0xa7);
    181 
    182   writecommand(ST7789_PWCTRL1);
    183   writedata(0xa4);
    184   writedata(0xa1);
    185 
    186   writecommand(0xD6);
    187   writedata(0xa1);
    188 
    189   //--------------------------------ST7789V gamma setting---------------------------------------//
    190   writecommand(ST7789_PVGAMCTRL);
    191   writedata(0xf0);
    192   writedata(0x05);
    193   writedata(0x0a);
    194   writedata(0x06);
    195   writedata(0x06);
    196   writedata(0x03);
    197   writedata(0x2b);
    198   writedata(0x32);
    199   writedata(0x43);
    200   writedata(0x36);
    201   writedata(0x11);
    202   writedata(0x10);
    203   writedata(0x2b);
    204   writedata(0x32);
    205 
    206   writecommand(ST7789_NVGAMCTRL);
    207   writedata(0xf0);
    208   writedata(0x08);
    209   writedata(0x0c);
    210   writedata(0x0b);
    211   writedata(0x09);
    212   writedata(0x24);
    213   writedata(0x2b);
    214   writedata(0x22);
    215   writedata(0x43);
    216   writedata(0x38);
    217   writedata(0x15);
    218   writedata(0x16);
    219   writedata(0x2f);
    220   writedata(0x37);
    221 
    222 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    223 
    224   end_tft_write();
    225   delay(120);
    226   begin_tft_write();
    227 
    228   writecommand(ST7789_DISPON);    //Display on
    229   delay(120);
    230 
    231 #ifdef TFT_BL
    232   // Turn on the back-light LED
    233   digitalWrite(TFT_BL, HIGH);
    234   pinMode(TFT_BL, OUTPUT);
    235 #endif
    236 }
    237 #endif