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_GC9106.h (3337B)

      1 #ifndef _ARDUINO_GC9106_H_
      2 #define _ARDUINO_GC9106_H_
      3 
      4 #include <Arduino.h>
      5 #include <Print.h>
      6 #include "./Arduino_GFX.h"
      7 #include "../Arduino_TFT.h"
      8 
      9 #define GC9106_TFTWIDTH 80
     10 #define GC9106_TFTHEIGHT 160
     11 
     12 #define GC9106_RST_DELAY 120    ///< delay ms wait for reset finish
     13 #define GC9106_SLPIN_DELAY 120  ///< delay ms wait for sleep in finish
     14 #define GC9106_SLPOUT_DELAY 120 ///< delay ms wait for sleep out finish
     15 
     16 #define GC9106_NOP 0x00
     17 #define GC9106_SWRESET 0x01
     18 #define GC9106_RDDID 0x04
     19 #define GC9106_RDDST 0x09
     20 
     21 #define GC9106_SLPIN 0x10
     22 #define GC9106_SLPOUT 0x11
     23 #define GC9106_PTLON 0x12
     24 #define GC9106_NORON 0x13
     25 
     26 #define GC9106_INVOFF 0x20
     27 #define GC9106_INVON 0x21
     28 #define GC9106_DISPOFF 0x28
     29 #define GC9106_DISPON 0x29
     30 
     31 #define GC9106_CASET 0x2A
     32 #define GC9106_RASET 0x2B
     33 #define GC9106_RAMWR 0x2C
     34 #define GC9106_RAMRD 0x2E
     35 
     36 #define GC9106_PTLAR 0x30
     37 #define GC9106_TELON 0x35
     38 #define GC9106_MADCTL 0x36
     39 #define GC9106_COLMOD 0x3A
     40 #define GC9106_SCANLSET 0x44
     41 
     42 #define GC9106_FRMCTR1 0xB1
     43 #define GC9106_FRMCTR2 0xB2
     44 #define GC9106_FRMCTR3 0xB3
     45 
     46 #define GC9106_INVCTR 0xB4
     47 #define GC9106_VREG1CTL 0xE6
     48 #define GC9106_VREG2CTL 0xE7
     49 #define GC9106_GAMMA1 0xF0
     50 #define GC9106_GAMMA2 0xF1
     51 #define GC9106_INTERRE1 0xFE
     52 #define GC9106_INTERRE2 0xEF
     53 
     54 #define GC9106_MADCTL_MY 0x80
     55 #define GC9106_MADCTL_MX 0x40
     56 #define GC9106_MADCTL_MV 0x20
     57 #define GC9106_MADCTL_ML 0x10
     58 #define GC9106_MADCTL_BGR 0x08
     59 #define GC9106_MADCTL_MH 0x04
     60 #define GC9106_MADCTL_RGB 0x00
     61 
     62 static const uint8_t GC9106_init_operations[] = {
     63     BEGIN_WRITE,
     64 
     65     WRITE_COMMAND_8, GC9106_INTERRE1,
     66     WRITE_COMMAND_8, GC9106_INTERRE1,
     67     WRITE_COMMAND_8, GC9106_INTERRE1,
     68     WRITE_COMMAND_8, GC9106_INTERRE2,
     69 
     70     WRITE_C8_D8, GC9106_FRMCTR3, 0x03,
     71 
     72     WRITE_C8_D8, GC9106_MADCTL, 0xD8,
     73 
     74     WRITE_C8_D8, GC9106_COLMOD, 0x05,
     75 
     76     WRITE_C8_D8, 0xB6, 0x11,
     77     WRITE_C8_D8, 0xAC, 0x0B,
     78 
     79     WRITE_C8_D8, GC9106_INVCTR, 0x21,
     80 
     81     WRITE_C8_D8, GC9106_FRMCTR1, 0xC0,
     82 
     83     WRITE_C8_D16, GC9106_VREG1CTL, 0x50, 0x43,
     84     WRITE_C8_D16, GC9106_VREG2CTL, 0x56, 0x43,
     85 
     86     WRITE_COMMAND_8, GC9106_GAMMA1,
     87     WRITE_BYTES, 14, 0x1F, 0x41, 0x1B, 0x55, 0x36, 0x3D, 0x3E,
     88     0x00, 0x16, 0x08, 0x09, 0x15, 0x14, 0x0F,
     89 
     90     WRITE_COMMAND_8, GC9106_GAMMA2,
     91     WRITE_BYTES, 14, 0x1F, 0x41, 0x1B, 0x55, 0x36, 0x3D, 0x3E,
     92     0x00, 0x16, 0x08, 0x09, 0x15, 0x14, 0x0F,
     93 
     94     WRITE_COMMAND_8, GC9106_INTERRE1,
     95     WRITE_COMMAND_8, 0xFF,
     96 
     97     WRITE_C8_D8, GC9106_TELON, 0x00,
     98     WRITE_C8_D8, GC9106_SCANLSET, 0x00,
     99 
    100     WRITE_COMMAND_8, GC9106_SLPOUT,
    101     END_WRITE,
    102 
    103     DELAY, GC9106_SLPOUT_DELAY,
    104 
    105     BEGIN_WRITE,
    106     WRITE_COMMAND_8, GC9106_DISPON, // Display on
    107     END_WRITE,
    108 
    109     DELAY, 20};
    110 
    111 class Arduino_GC9106 : public Arduino_TFT
    112 {
    113 public:
    114   Arduino_GC9106(
    115       Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0,
    116       bool ips = false, int16_t w = GC9106_TFTWIDTH, int16_t h = GC9106_TFTHEIGHT,
    117       uint8_t col_offset1 = 24, uint8_t row_offset1 = 0, uint8_t col_offset2 = 24, uint8_t row_offset2 = 0);
    118 
    119   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    120   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    121   void setRotation(uint8_t r) override;
    122   void invertDisplay(bool) override;
    123   void displayOn() override;
    124   void displayOff() override;
    125 
    126 protected:
    127   void tftInit() override;
    128 
    129 private:
    130 };
    131 
    132 #endif