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_GC9A01.h (4457B)

      1 #ifndef _ARDUINO_GC9A01_H_
      2 #define _ARDUINO_GC9A01_H_
      3 
      4 #include <Arduino.h>
      5 #include <Print.h>
      6 #include "./Arduino_GFX.h"
      7 #include "../Arduino_TFT.h"
      8 
      9 #define GC9A01_TFTWIDTH 240
     10 #define GC9A01_TFTHEIGHT 240
     11 
     12 #define GC9A01_RST_DELAY 120    ///< delay ms wait for reset finish
     13 #define GC9A01_SLPIN_DELAY 120  ///< delay ms wait for sleep in finish
     14 #define GC9A01_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
     15 
     16 #define GC9A01_NOP 0x00
     17 #define GC9A01_SWRESET 0x01
     18 #define GC9A01_RDDID 0x04
     19 #define GC9A01_RDDST 0x09
     20 
     21 #define GC9A01_SLPIN 0x10
     22 #define GC9A01_SLPOUT 0x11
     23 #define GC9A01_PTLON 0x12
     24 #define GC9A01_NORON 0x13
     25 
     26 #define GC9A01_INVOFF 0x20
     27 #define GC9A01_INVON 0x21
     28 #define GC9A01_DISPOFF 0x28
     29 #define GC9A01_DISPON 0x29
     30 
     31 #define GC9A01_CASET 0x2A
     32 #define GC9A01_RASET 0x2B
     33 #define GC9A01_RAMWR 0x2C
     34 #define GC9A01_RAMRD 0x2E
     35 
     36 #define GC9A01_PTLAR 0x30
     37 #define GC9A01_COLMOD 0x3A
     38 #define GC9A01_MADCTL 0x36
     39 
     40 #define GC9A01_MADCTL_MY 0x80
     41 #define GC9A01_MADCTL_MX 0x40
     42 #define GC9A01_MADCTL_MV 0x20
     43 #define GC9A01_MADCTL_ML 0x10
     44 #define GC9A01_MADCTL_RGB 0x00
     45 
     46 #define GC9A01_RDID1 0xDA
     47 #define GC9A01_RDID2 0xDB
     48 #define GC9A01_RDID3 0xDC
     49 #define GC9A01_RDID4 0xDD
     50 
     51 static const uint8_t gc9a01_init_operations[] = {
     52     BEGIN_WRITE,
     53 
     54     WRITE_COMMAND_8, 0xEF,
     55     WRITE_C8_D8, 0xEB, 0x14,
     56 
     57     WRITE_COMMAND_8, 0xFE,
     58     WRITE_COMMAND_8, 0xEF,
     59 
     60     WRITE_C8_D8, 0xEB, 0x14,
     61 
     62     WRITE_C8_D8, 0x84, 0x40,
     63 
     64     WRITE_C8_D8, 0x85, 0xFF,
     65 
     66     WRITE_C8_D8, 0x86, 0xFF,
     67 
     68     WRITE_C8_D8, 0x87, 0xFF,
     69 
     70     WRITE_C8_D8, 0x88, 0x0A,
     71 
     72     WRITE_C8_D8, 0x89, 0x21,
     73 
     74     WRITE_C8_D8, 0x8A, 0x00,
     75 
     76     WRITE_C8_D8, 0x8B, 0x80,
     77 
     78     WRITE_C8_D8, 0x8C, 0x01,
     79 
     80     WRITE_C8_D8, 0x8D, 0x01,
     81 
     82     WRITE_C8_D8, 0x8E, 0xFF,
     83 
     84     WRITE_C8_D8, 0x8F, 0xFF,
     85 
     86     WRITE_C8_D16, 0xB6, 0x00, 0x20,
     87 
     88     WRITE_C8_D8, 0x3A, 0x05,
     89 
     90     WRITE_COMMAND_8, 0x90,
     91     WRITE_BYTES, 4, 0x08, 0x08, 0x08, 0x08,
     92 
     93     WRITE_C8_D8, 0xBD, 0x06,
     94 
     95     WRITE_C8_D8, 0xBC, 0x00,
     96 
     97     WRITE_COMMAND_8, 0xFF,
     98     WRITE_BYTES, 3, 0x60, 0x01, 0x04,
     99 
    100     WRITE_C8_D8, 0xC3, 0x13,
    101     WRITE_C8_D8, 0xC4, 0x13,
    102 
    103     WRITE_C8_D8, 0xC9, 0x22,
    104 
    105     WRITE_C8_D8, 0xBE, 0x11,
    106 
    107     WRITE_C8_D16, 0xE1, 0x10, 0x0E,
    108 
    109     WRITE_COMMAND_8, 0xDF,
    110     WRITE_BYTES, 3, 0x21, 0x0c, 0x02,
    111 
    112     WRITE_COMMAND_8, 0xF0,
    113     WRITE_BYTES, 6,
    114     0x45, 0x09, 0x08, 0x08, 0x26,
    115     0x2A,
    116 
    117     WRITE_COMMAND_8, 0xF1,
    118     WRITE_BYTES, 6,
    119     0x43, 0x70, 0x72, 0x36, 0x37,
    120     0x6F,
    121 
    122     WRITE_COMMAND_8, 0xF2,
    123     WRITE_BYTES, 6,
    124     0x45, 0x09, 0x08, 0x08, 0x26,
    125     0x2A,
    126 
    127     WRITE_COMMAND_8, 0xF3,
    128     WRITE_BYTES, 6,
    129     0x43, 0x70, 0x72, 0x36, 0x37,
    130     0x6F,
    131 
    132     WRITE_C8_D16, 0xED, 0x1B, 0x0B,
    133 
    134     WRITE_C8_D8, 0xAE, 0x77,
    135 
    136     WRITE_C8_D8, 0xCD, 0x63,
    137 
    138     WRITE_COMMAND_8, 0x70,
    139     WRITE_BYTES, 9,
    140     0x07, 0x07, 0x04, 0x0E, 0x0F,
    141     0x09, 0x07, 0x08, 0x03,
    142 
    143     WRITE_C8_D8, 0xE8, 0x34,
    144 
    145     WRITE_COMMAND_8, 0x62,
    146     WRITE_BYTES, 12,
    147     0x18, 0x0D, 0x71, 0xED, 0x70,
    148     0x70, 0x18, 0x0F, 0x71, 0xEF,
    149     0x70, 0x70,
    150 
    151     WRITE_COMMAND_8, 0x63,
    152     WRITE_BYTES, 12,
    153     0x18, 0x11, 0x71, 0xF1, 0x70,
    154     0x70, 0x18, 0x13, 0x71, 0xF3,
    155     0x70, 0x70,
    156 
    157     WRITE_COMMAND_8, 0x64,
    158     WRITE_BYTES, 7,
    159     0x28, 0x29, 0xF1, 0x01, 0xF1,
    160     0x00, 0x07,
    161 
    162     WRITE_COMMAND_8, 0x66,
    163     WRITE_BYTES, 10,
    164     0x3C, 0x00, 0xCD, 0x67, 0x45,
    165     0x45, 0x10, 0x00, 0x00, 0x00,
    166 
    167     WRITE_COMMAND_8, 0x67,
    168     WRITE_BYTES, 10,
    169     0x00, 0x3C, 0x00, 0x00, 0x00,
    170     0x01, 0x54, 0x10, 0x32, 0x98,
    171 
    172     WRITE_COMMAND_8, 0x74,
    173     WRITE_BYTES, 7,
    174     0x10, 0x85, 0x80, 0x00, 0x00,
    175     0x4E, 0x00,
    176 
    177     WRITE_C8_D16, 0x98, 0x3e, 0x07,
    178 
    179     WRITE_COMMAND_8, 0x35,
    180 
    181     WRITE_COMMAND_8, GC9A01_SLPOUT,
    182     END_WRITE,
    183 
    184     DELAY, GC9A01_SLPOUT_DELAY,
    185 
    186     BEGIN_WRITE,
    187     WRITE_COMMAND_8, GC9A01_DISPON, // Display on
    188     END_WRITE,
    189 
    190     DELAY, 20};
    191 
    192 class Arduino_GC9A01 : public Arduino_TFT
    193 {
    194 public:
    195   Arduino_GC9A01(
    196       Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
    197       bool ips = false, int16_t w = GC9A01_TFTWIDTH, int16_t h = GC9A01_TFTHEIGHT,
    198       uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0);
    199 
    200   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    201   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    202   void setRotation(uint8_t r) override;
    203   void invertDisplay(bool) override;
    204   void displayOn() override;
    205   void displayOff() override;
    206 
    207 protected:
    208   void tftInit() override;
    209 
    210 private:
    211 };
    212 
    213 #endif