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_GC9107.h (4718B)

      1 #ifndef _ARDUINO_GC9107_H_
      2 #define _ARDUINO_GC9107_H_
      3 
      4 #include <Arduino.h>
      5 #include <Print.h>
      6 #include "./Arduino_GFX.h"
      7 #include "../Arduino_TFT.h"
      8 
      9 #define GC9107_TFTWIDTH 128
     10 #define GC9107_TFTHEIGHT 128
     11 
     12 #define GC9107_RST_DELAY 120    ///< delay ms wait for reset finish
     13 #define GC9107_SLPIN_DELAY 120  ///< delay ms wait for sleep in finish
     14 #define GC9107_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
     15 
     16 #define GC9107_NOP 0x00
     17 #define GC9107_SWRESET 0x01
     18 #define GC9107_RDDID 0x04
     19 #define GC9107_RDDST 0x09
     20 
     21 #define GC9107_SLPIN 0x10
     22 #define GC9107_SLPOUT 0x11
     23 #define GC9107_PTLON 0x12
     24 #define GC9107_NORON 0x13
     25 
     26 #define GC9107_INVOFF 0x20
     27 #define GC9107_INVON 0x21
     28 #define GC9107_DISPOFF 0x28
     29 #define GC9107_DISPON 0x29
     30 
     31 #define GC9107_CASET 0x2A
     32 #define GC9107_RASET 0x2B
     33 #define GC9107_RAMWR 0x2C
     34 #define GC9107_RAMRD 0x2E
     35 
     36 #define GC9107_PTLAR 0x30
     37 #define GC9107_TELON 0x35
     38 #define GC9107_MADCTL 0x36
     39 #define GC9107_COLMOD 0x3A
     40 #define GC9107_SCANLSET 0x44
     41 
     42 #define GC9107_FRMCTR1 0xB1
     43 #define GC9107_FRMCTR2 0xB2
     44 #define GC9107_FRMCTR3 0xB3
     45 
     46 #define GC9107_INVCTR 0xB4
     47 #define GC9107_VREG1CTL 0xE6
     48 #define GC9107_VREG2CTL 0xE7
     49 #define GC9107_GAMMA1 0xF0
     50 #define GC9107_GAMMA2 0xF1
     51 #define GC9107_INTERRE1 0xFE
     52 #define GC9107_INTERRE2 0xEF
     53 
     54 #define GC9107_MADCTL_MY 0x80
     55 #define GC9107_MADCTL_MX 0x40
     56 #define GC9107_MADCTL_MV 0x20
     57 #define GC9107_MADCTL_ML 0x10
     58 #define GC9107_MADCTL_BGR 0x08
     59 #define GC9107_MADCTL_MH 0x04
     60 #define GC9107_MADCTL_RGB 0x00
     61 
     62 static const uint8_t GC9107_init_operations[] = {
     63     BEGIN_WRITE,
     64     WRITE_COMMAND_8, 0xEF,
     65     WRITE_C8_D8, 0xEB, 0x14,
     66     WRITE_COMMAND_8, 0xFE,
     67     WRITE_COMMAND_8, 0xEF,
     68     WRITE_C8_D8, 0xEB, 0x14,
     69     WRITE_C8_D8, 0x84, 0x40,
     70     WRITE_C8_D8, 0x85, 0xFF,
     71     WRITE_C8_D8, 0x86, 0xFF,
     72     WRITE_C8_D8, 0x87, 0xFF,
     73     WRITE_C8_D8, 0x88, 0x0A,
     74     WRITE_C8_D8, 0x89, 0x21,
     75     WRITE_C8_D8, 0x8A, 0x00,
     76     WRITE_C8_D8, 0x8B, 0x80,
     77     WRITE_C8_D8, 0x8C, 0x01,
     78     WRITE_C8_D8, 0x8D, 0x01,
     79     WRITE_C8_D8, 0x8E, 0xFF,
     80     WRITE_C8_D8, 0x8F, 0xFF,
     81     WRITE_C8_D16, 0xB6, 0x00, 0x20,
     82     WRITE_C8_D8, 0x3A, 0x05,
     83 
     84     WRITE_COMMAND_8, 0x90,
     85     WRITE_BYTES, 4, 0x08, 0x08, 0x08, 0x08,
     86 
     87     WRITE_C8_D8, 0xBD, 0x06,
     88     WRITE_C8_D8, 0xBC, 0x00,
     89 
     90     WRITE_COMMAND_8, 0xFF,
     91     WRITE_BYTES, 3, 0x60, 0x01, 0x04,
     92 
     93     WRITE_C8_D8, 0xC3, 0x13,
     94     WRITE_C8_D8, 0xC4, 0x13,
     95     WRITE_C8_D8, 0xC9, 0x22,
     96     WRITE_C8_D8, 0xBE, 0x11,
     97     WRITE_C8_D16, 0xE1, 0x10, 0x0E,
     98 
     99     WRITE_COMMAND_8, 0xDF,
    100     WRITE_BYTES, 3, 0x21, 0x0c, 0x02,
    101 
    102     WRITE_COMMAND_8, 0xF0,
    103     WRITE_BYTES, 6,
    104     0x45, 0x09, 0x08, 0x08,
    105     0x26, 0x2A,
    106 
    107     WRITE_COMMAND_8, 0xF1,
    108     WRITE_BYTES, 6,
    109     0x43, 0x70, 0x72, 0x36,
    110     0x37, 0x6F,
    111 
    112     WRITE_COMMAND_8, 0xF2,
    113     WRITE_BYTES, 6,
    114     0x45, 0x09, 0x08, 0x08,
    115     0x26, 0x2A,
    116 
    117     WRITE_COMMAND_8, 0xF3,
    118     WRITE_BYTES, 6,
    119     0x43, 0x70, 0x72, 0x36,
    120     0x37, 0x6F,
    121 
    122     WRITE_C8_D16, 0xED, 0x1B, 0x0B,
    123     WRITE_C8_D8, 0xAE, 0x77,
    124     WRITE_C8_D8, 0xCD, 0x63,
    125 
    126     WRITE_COMMAND_8, 0x70,
    127     WRITE_BYTES, 9,
    128     0x07, 0x07, 0x04, 0x0E,
    129     0x0F, 0x09, 0x07, 0x08,
    130     0x03,
    131 
    132     WRITE_C8_D8, 0xE8, 0x34,
    133 
    134     WRITE_COMMAND_8, 0x62,
    135     WRITE_BYTES, 12,
    136     0x18, 0x0D, 0x71, 0xED,
    137     0x70, 0x70, 0x18, 0x0F,
    138     0x71, 0xEF, 0x70, 0x70,
    139 
    140     WRITE_COMMAND_8, 0x63,
    141     WRITE_BYTES, 12,
    142     0x18, 0x11, 0x71, 0xF1,
    143     0x70, 0x70, 0x18, 0x13,
    144     0x71, 0xF3, 0x70, 0x70,
    145 
    146     WRITE_COMMAND_8, 0x64,
    147     WRITE_BYTES, 7,
    148     0x28, 0x29, 0xF1, 0x01,
    149     0xF1, 0x00, 0x07,
    150 
    151     WRITE_COMMAND_8, 0x66,
    152     WRITE_BYTES, 10,
    153     0x3C, 0x00, 0xCD, 0x67,
    154     0x45, 0x45, 0x10, 0x00,
    155     0x00, 0x00,
    156 
    157     WRITE_COMMAND_8, 0x67,
    158     WRITE_BYTES, 10,
    159     0x00, 0x3C, 0x00, 0x00,
    160     0x00, 0x01, 0x54, 0x10,
    161     0x32, 0x98,
    162 
    163     WRITE_COMMAND_8, 0x74,
    164     WRITE_BYTES, 7,
    165     0x10, 0x85, 0x80, 0x00,
    166     0x00, 0x4E, 0x00,
    167 
    168     WRITE_C8_D16, 0x98, 0x3e, 0x07,
    169     WRITE_COMMAND_8, 0x35,
    170     WRITE_COMMAND_8, 0x21,
    171 
    172     WRITE_COMMAND_8, 0x11,
    173     END_WRITE,
    174 
    175     DELAY, 120,
    176 
    177     BEGIN_WRITE,
    178     WRITE_COMMAND_8, 0x29,
    179     END_WRITE,
    180 
    181     DELAY, 20};
    182 
    183 class Arduino_GC9107 : public Arduino_TFT
    184 {
    185 public:
    186   Arduino_GC9107(
    187       Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
    188       bool ips = false, int16_t w = GC9107_TFTWIDTH, int16_t h = GC9107_TFTHEIGHT,
    189       uint8_t col_offset1 = 2, uint8_t row_offset1 = 1, uint8_t col_offset2 = 2, uint8_t row_offset2 = 1);
    190 
    191   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    192   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    193   void setRotation(uint8_t r) override;
    194   void invertDisplay(bool) override;
    195   void displayOn() override;
    196   void displayOff() override;
    197 
    198 protected:
    199   void tftInit() override;
    200 
    201 private:
    202 };
    203 
    204 #endif