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_HX8357A.h (19834B)

      1 #ifndef _ARDUINO_HX8357A_H_
      2 #define _ARDUINO_HX8357A_H_
      3 
      4 #include <Arduino.h>
      5 #include <Print.h>
      6 #include "../Arduino_GFX.h"
      7 #include "../Arduino_TFT.h"
      8 
      9 #define HX8357A_TFTWIDTH 320  // HX8357A max TFT width
     10 #define HX8357A_TFTHEIGHT 480 // HX8357A max TFT height
     11 
     12 #define HX8357A_RST_DELAY 1200 // delay ms wait for reset finish
     13 
     14 #define HX8357A_HIMAX_ID 0x00                         // Himax ID
     15 #define HX8357A_DISPLAY_MODE_CONTROL 0x01             // Display Mode control
     16 #define HX8357A_COLUMN_ADDRESS_START_2 0x02           // Column address start 2
     17 #define HX8357A_COLUMN_ADDRESS_START_1 0x03           // Column address start 1
     18 #define HX8357A_COLUMN_ADDRESS_END_2 0x04             // Column address end 2
     19 #define HX8357A_COLUMN_ADDRESS_END_1 0x05             // Column address end 1
     20 #define HX8357A_ROW_ADDRESS_START_2 0x06              // Row address start 2
     21 #define HX8357A_ROW_ADDRESS_START_1 0x07              // Row address start 1
     22 #define HX8357A_ROW_ADDRESS_END_2 0x08                // Row address end 2
     23 #define HX8357A_ROW_ADDRESS_END_1 0x09                // Row address end 1
     24 #define HX8357A_PARTIAL_ASREA_START_ROW_2 0x0A        // Partial area start row 2
     25 #define HX8357A_PARTIAL_AREA_START_ROW_1 0x0B         // Partial area start row 1
     26 #define HX8357A_PARTIAL_AREA_END_ROW_2 0x0C           // Partial area end row 2
     27 #define HX8357A_PARTIAL_AREA_END_ROW_1 0x0D           // Partial area end row 1
     28 #define HX8357A_VERTICAL_SCROLL_TOP_FIXED_AREA_2 0x0E // Vertical Scroll Top fixed area 2
     29 #define HX8357A_VERTICAL_SCROLL_TOP_FIXED_AREA_1 0x0F // Vertical Scroll Top fixed area 1
     30 #define HX8357A_VERTICAL_SCROLL_HEIGHT_AREA_2 0x10    // Vertical Scroll height area 2
     31 #define HX8357A_VERTICAL_SCROLL_HEIGHT_AREA_1 0x11    // Vertical Scroll height area 1
     32 #define HX8357A_VERTICAL_SCROLL_BUTTON_AREA_2 0x12    // Vertical Scroll Button area 2
     33 #define HX8357A_VERTICAL_SCROLL_BUTTON_AREA_1 0x13    // Vertical Scroll Button area 1
     34 #define HX8357A_VERTICAL_SCROLL_START_ADDRESS_2 0x14  // Vertical Scroll Start address 2
     35 #define HX8357A_VERTICAL_SCROLL_START_ADDRESS_1 0x15  // Vertical Scroll Start address 1
     36 #define HX8357A_MEMORY_ACCESS_CONTROL 0x16            // Memory Access control
     37 #define HX8357A_COLMOD 0x17                           // COLMOD
     38 #define HX8357A_OSC_CONTROL_1 0x18                    // OSC Control 1
     39 #define HX8357A_OSC_CONTROL_2 0x19                    // OSC Control 2
     40 #define HX8357A_POWER_CONTROL_6 0x1A                  // Power Control 6
     41 #define HX8357A_POWER_CONTROL_5 0x1B                  // Power Control 5
     42 #define HX8357A_POWER_CONTROL_4 0x1C                  // Power Control 4
     43 #define HX8357A_POWER_CONTROL_3 0x1D                  // Power Control 3
     44 #define HX8357A_POWER_CONTROL_2 0x1E                  // Power Control 2
     45 #define HX8357A_POWER_CONTROL_1 0x1F                  // Power Control 1
     46 #define HX8357A_SRAM_CONTROL 0x22                     // SRAM Control
     47 #define HX8357A_VCOM_CONTROL_1 0x23                   // VCOM Control 1
     48 #define HX8357A_VCOM_CONTROL_2 0x24                   // VCOM Control 2
     49 #define HX8357A_VCOM_CONTROL_3 0x25                   // VCOM Control 3
     50 #define HX8357A_DISPLAY_CONTROL_1 0x26                // Display Control 1
     51 #define HX8357A_DISPLAY_CONTROL_2 0x27                // Display Control 2
     52 #define HX8357A_DISPLAY_CONTROL_3 0x28                // Display Control 3
     53 #define HX8357A_FRAME_RATE_CONTROL_1 0x29             // Frame Rate control 1
     54 #define HX8357A_FRAME_RATE_CONTROL_2 0x2A             // Frame Rate Control 2
     55 #define HX8357A_FRAME_RATE_CONTROL_3 0x2B             // Frame Rate Control 3
     56 #define HX8357A_FRAME_RATE_CONTROL_4 0x2C             // Frame Rate Control 4
     57 #define HX8357A_CYCLE_CONTROL_2 0x2D                  // Cycle Control 2
     58 #define HX8357A_CYCLE_CONTROL_3 0x2E                  // Cycle Control 3
     59 #define HX8357A_DISPLAY_INVERSION 0x2F                // Display inversion
     60 #define HX8357A_RGB_INTERFACE_CONTROL_1 0x31          // RGB interface control 1
     61 #define HX8357A_RGB_INTERFACE_CONTROL_2 0x32          // RGB interface control 2
     62 #define HX8357A_RGB_INTERFACE_CONTROL_3 0x33          // RGB interface control 3
     63 #define HX8357A_RGB_INTERFACE_CONTROL_4 0x34          // RGB interface control 4
     64 #define HX8357A_PANEL_CHARACTERIC 0x36                // Panel Characteric
     65 #define HX8357A_OTP_CONTROL_1 0x38                    // OTP Control 1
     66 #define HX8357A_OTP_CONTROL_2 0x39                    // OTP Control 2
     67 #define HX8357A_OTP_CONTROL_3 0x3A                    // OTP Control 3
     68 #define HX8357A_OTP_CONTROL_4 0x3B                    // OTP Control 4
     69 #define HX8357A_CABC_CONTROL_1 0x3C                   // CABC Control 1
     70 #define HX8357A_CABC_CONTROL_2 0x3D                   // CABC Control 2
     71 #define HX8357A_CABC_CONTROL_3 0x3E                   // CABC Control 3
     72 #define HX8357A_CABC_CONTROL_4 0x3F                   // CABC Control 4
     73 #define HX8357A_R1_CONTROL_1 0x40                     // r1 Control (1)
     74 #define HX8357A_R1_CONTROL_2 0x41                     // r1 Control (2)
     75 #define HX8357A_R1_CONTROL_3 0x42                     // r1 Control (3)
     76 #define HX8357A_R1_CONTROL_4 0x43                     // r1 Control (4)
     77 #define HX8357A_R1_CONTROL_5 0x44                     // r1 Control (5)
     78 #define HX8357A_R1_CONTROL_6 0x45                     // r1 Control (6)
     79 #define HX8357A_R1_CONTROL_7 0x46                     // r1 Control (7)
     80 #define HX8357A_R1_CONTROL_8 0x47                     // r1 Control (8)
     81 #define HX8357A_R1_CONTROL_9 0x48                     // r1 Control (9)
     82 #define HX8357A_R1_CONTROL_10 0x49                    // r1 Control (10)
     83 #define HX8357A_R1_CONTROL_11 0x4A                    // r1 Control (11)
     84 #define HX8357A_R1_CONTROL_12 0x4B                    // r1 Control (12)
     85 #define HX8357A_R1_CONTROL_13 0x4C                    // r1 Control (13)
     86 #define HX8357A_R1_CONTROL_18 0x50                    // r1 Control (18)
     87 #define HX8357A_R1_CONTROL_19 0x51                    // r1 Control (19)
     88 #define HX8357A_R1_CONTROL_20 0x52                    // r1 Control (20)
     89 #define HX8357A_R1_CONTROL_21 0x53                    // r1 Control (21)
     90 #define HX8357A_R1_CONTROL_22 0x54                    // r1 Control (22)
     91 #define HX8357A_R1_CONTROL_23 0x55                    // r1 Control (23)
     92 #define HX8357A_R1_CONTROL_24 0x56                    // r1 Control (24)
     93 #define HX8357A_R1_CONTROL_25 0x57                    // r1 Control (25)
     94 #define HX8357A_R1_CONTROL_26 0x58                    // r1 Control (26)
     95 #define HX8357A_R1_CONTROL_27 0x59                    // r1 Control (27)
     96 #define HX8357A_R1_CONTROL_28 0x5A                    // r1 Control (28)
     97 #define HX8357A_R1_CONTROL_29 0x5B                    // r1 Control (29)
     98 #define HX8357A_R1_CONTROL_30 0x5C                    // r1 Control (30)
     99 #define HX8357A_R1_CONTROL_35 0x5D                    // r1 Control (35)
    100 #define HX8357A_TE_CONTROL 0x60                       // TE Control
    101 #define HX8357A_ID1 0x61                              // ID1
    102 #define HX8357A_ID2 0x62                              // ID2
    103 #define HX8357A_ID3 0x63                              // ID3
    104 #define HX8357A_ID4 0x64                              // ID4
    105 #define HX8357A_MDDI_CONTROL_4 0x68                   // MDDI Control 4
    106 #define HX8357A_MDDI_CONTROL_5 0x69                   // MDDI Control 5
    107 #define HX8357A_GPIO_CONTROL_1 0x6B                   // GPIO Control 1
    108 #define HX8357A_GPIO_CONTROL_2 0x6C                   // GPIO Control 2
    109 #define HX8357A_GPIO_CONTROL_3 0x6D                   // GPIO Control 3
    110 #define HX8357A_GPIO_CONTROL_4 0x6E                   // GPIO Control 4
    111 #define HX8357A_GPIO_CONTROL_5 0x6F                   // GPIO Control 5
    112 #define HX8357A_SUB_PANEL_CONTROL_1 0x70              // SUB_PANEL Control 1
    113 #define HX8357A_SUB_PANEL_CONTROL_2 0x71              // SUB_PANEL Control 2
    114 #define HX8357A_SUB_PANEL_CONTROL_3 0x72              // SUB_PANEL Control 3
    115 #define HX8357A_SUB_PANEL_CONTROL_4 0x73              // SUB_PANEL Control 4
    116 #define HX8357A_COLUMN_ADDRESS_COUNTER_2 0x80         // Column address counter 2
    117 #define HX8357A_COLUMN_ADDRESS_COUNTER_1 0x81         // Column address counter 1
    118 #define HX8357A_ROW_ADDRESS_COUNTER_2 0x82            // Row address counter 2
    119 #define HX8357A_ROW_ADDRESS_COUNTER_1 0x83            // Row address counter 1
    120 #define HX8357A_SET_VREF 0xE2                         // Set VREF
    121 #define HX8357A_POWER_SAVING_COUNTER_1 0xE4           // Power saving counter 1
    122 #define HX8357A_POWER_SAVING_COUNTER_2 0xE5           // Power saving counter 2
    123 #define HX8357A_POWER_SAVING_COUNTER_3 0xE6           // Power saving counter 3
    124 #define HX8357A_POWER_SAVING_COUNTER_4 0xE7           // Power saving counter 4
    125 #define HX8357A_OPON_CONTROL_1 0xE8                   // OPON Control 1
    126 #define HX8357A_OPON_CONTROL_2 0xE9                   // OPON Control 2
    127 #define HX8357A_CENON_CONTROL 0xF2                    // GENON Control
    128 #define HX8357A_SET_SPI_RRAD_INDEX 0xFD               // Set SPI Rrad Index
    129 #define HX8357A_GET_SPI_INDEX_DATA 0xFE               // Get SPI Index data
    130 #define HX8357A_PAGE_SELECT 0xFF                      // Page select
    131 
    132 #define HX8357A_MADCTL_MY 0x80  // PAGE ADDRESS ORDER
    133 #define HX8357A_MADCTL_MX 0x40  // COLUMN ADDRESS ORDER
    134 #define HX8357A_MADCTL_MV 0x20  // PAGE/COLUMN SELECTION
    135 #define HX8357A_MADCTL_BGR 0x08 // RGB-BGR ORDER
    136 #define HX8357A_MADCTL_SS 0x02  // SOURCE OUTPUT ORDER
    137 #define HX8357A_MADCTL_GS 0x01  // GATE OUTPUT ORDER
    138 #define HX8357A_INV_ON 0x20     // INV_ON enable
    139 #define HX8357A_INV_OFF 0x00    // INV_ON disable
    140 
    141 static const uint8_t hx8357a_init_operations[] = {
    142     BEGIN_WRITE,
    143     WRITE_C8_D8, HX8357A_PAGE_SELECT, 0x00, // Command page 0
    144     END_WRITE,
    145     DELAY, 15,
    146     BEGIN_WRITE,
    147     WRITE_C8_D8, HX8357A_POWER_CONTROL_6, 0x04, // VGH VGL VCL  DDVDH
    148     WRITE_C8_D8, HX8357A_POWER_CONTROL_5, 0x1C,
    149     // Power Settng
    150     WRITE_C8_D8, HX8357A_VCOM_CONTROL_1, 0x94, // Set VCOM offset, VMF=0x52
    151     WRITE_C8_D8, HX8357A_VCOM_CONTROL_2, 0x69, // Set VCOMH voltage, VHH=0x64
    152     WRITE_C8_D8, HX8357A_VCOM_CONTROL_3, 0x63, // Set VCOML voltage, VML=0x71
    153     WRITE_C8_D8, HX8357A_OSC_CONTROL_2, 0x01,
    154     END_WRITE,
    155     DELAY, 10,
    156     BEGIN_WRITE,
    157     WRITE_C8_D8, HX8357A_POWER_CONTROL_6, 0x00,      // VGH VGL VCL  DDVDH
    158     WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0x8A,      //
    159     WRITE_C8_D8, HX8357A_DISPLAY_MODE_CONTROL, 0x00, //
    160     WRITE_C8_D8, HX8357A_POWER_CONTROL_4, 0x05,      //
    161     WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0x82,      //
    162     END_WRITE,
    163     DELAY, 10,
    164     BEGIN_WRITE,
    165     WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0x92, //
    166     END_WRITE,
    167     DELAY, 10,
    168     BEGIN_WRITE,
    169     WRITE_C8_D8, HX8357A_POWER_CONTROL_1, 0xD4, //
    170 
    171     WRITE_C8_D8, HX8357A_COLMOD, 0x55,          // 16-bit/pixel
    172     WRITE_C8_D8, HX8357A_OSC_CONTROL_1, 0x21,   // Fosc=130%*5.2MHZ   21
    173     WRITE_C8_D8, HX8357A_POWER_CONTROL_3, 0x00, // FS0[1:0]=01, Set the operating frequency of the step-up circuit 1
    174     WRITE_C8_D8, HX8357A_POWER_CONTROL_2, 0x00,
    175     WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_1, 0x33,
    176     WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_2, 0x01,
    177     WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_1, 0x00,
    178     WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_2, 0x00,
    179     WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_3, 0x01, // 0A
    180     WRITE_C8_D8, HX8357A_FRAME_RATE_CONTROL_4, 0x0A,
    181     WRITE_C8_D8, HX8357A_CYCLE_CONTROL_2, 0x20,
    182     WRITE_C8_D8, HX8357A_CYCLE_CONTROL_3, 0xA3,
    183     WRITE_C8_D8, HX8357A_DISPLAY_INVERSION, 0x00, // 00 100416
    184 
    185     WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_1, 0x00, // RGB MODE1  0X03=RGB MODE2
    186     WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_2, 0x00,
    187     WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_3, 0x08,
    188     WRITE_C8_D8, HX8357A_RGB_INTERFACE_CONTROL_4, 0x08,
    189     WRITE_C8_D8, HX8357A_PANEL_CHARACTERIC, 0x02, // REV
    190 
    191     // Gamma
    192     WRITE_C8_D8, HX8357A_R1_CONTROL_1, 0x01,
    193     WRITE_C8_D8, HX8357A_R1_CONTROL_2, 0x0F,
    194     WRITE_C8_D8, HX8357A_R1_CONTROL_3, 0x0F,
    195     WRITE_C8_D8, HX8357A_R1_CONTROL_4, 0x26,
    196     WRITE_C8_D8, HX8357A_R1_CONTROL_5, 0x2C,
    197     WRITE_C8_D8, HX8357A_R1_CONTROL_6, 0x3C,
    198     WRITE_C8_D8, HX8357A_R1_CONTROL_7, 0x0B,
    199     WRITE_C8_D8, HX8357A_R1_CONTROL_8, 0x5F,
    200     WRITE_C8_D8, HX8357A_R1_CONTROL_9, 0x00,
    201     WRITE_C8_D8, HX8357A_R1_CONTROL_10, 0x06,
    202     WRITE_C8_D8, HX8357A_R1_CONTROL_11, 0x09,
    203     WRITE_C8_D8, HX8357A_R1_CONTROL_12, 0x0E,
    204     WRITE_C8_D8, HX8357A_R1_CONTROL_13, 0x16,
    205 
    206     WRITE_C8_D8, HX8357A_R1_CONTROL_18, 0x01,
    207     WRITE_C8_D8, HX8357A_R1_CONTROL_19, 0x1D,
    208     WRITE_C8_D8, HX8357A_R1_CONTROL_20, 0x21,
    209     WRITE_C8_D8, HX8357A_R1_CONTROL_21, 0x3A,
    210     WRITE_C8_D8, HX8357A_R1_CONTROL_22, 0x39,
    211     WRITE_C8_D8, HX8357A_R1_CONTROL_23, 0x3F,
    212     WRITE_C8_D8, HX8357A_R1_CONTROL_24, 0x2D,
    213     WRITE_C8_D8, HX8357A_R1_CONTROL_25, 0x7F,
    214     WRITE_C8_D8, HX8357A_R1_CONTROL_26, 0x02,
    215     WRITE_C8_D8, HX8357A_R1_CONTROL_27, 0x15,
    216     WRITE_C8_D8, HX8357A_R1_CONTROL_28, 0x1B,
    217     WRITE_C8_D8, HX8357A_R1_CONTROL_29, 0x1B,
    218     WRITE_C8_D8, HX8357A_R1_CONTROL_30, 0x1A,
    219     WRITE_C8_D8, HX8357A_R1_CONTROL_35, 0x55,
    220 
    221     // #if 1
    222 
    223     WRITE_C8_D8, 0xff, 0x01,
    224     WRITE_C8_D8, 0x00, 0x01,
    225     WRITE_C8_D8, 0x01, 0x00,
    226     WRITE_C8_D8, 0x02, 0x01,
    227     WRITE_C8_D8, 0x03, 0x03,
    228     WRITE_C8_D8, 0x04, 0x05,
    229     WRITE_C8_D8, 0x05, 0x06,
    230     WRITE_C8_D8, 0x06, 0x08,
    231     WRITE_C8_D8, 0x07, 0x0C,
    232     WRITE_C8_D8, 0x08, 0x0E,
    233     WRITE_C8_D8, 0x09, 0x11,
    234     WRITE_C8_D8, 0x0A, 0x12,
    235     WRITE_C8_D8, 0x0B, 0x14,
    236     WRITE_C8_D8, 0x0C, 0x1B,
    237     WRITE_C8_D8, 0x0D, 0x23,
    238     WRITE_C8_D8, 0x0E, 0x29,
    239     WRITE_C8_D8, 0x0F, 0x2F,
    240     WRITE_C8_D8, 0x10, 0x34,
    241     WRITE_C8_D8, 0x11, 0x39,
    242     WRITE_C8_D8, 0x12, 0x3E,
    243     WRITE_C8_D8, 0x13, 0x43,
    244     WRITE_C8_D8, 0x14, 0x48,
    245     WRITE_C8_D8, 0x15, 0x4C,
    246     WRITE_C8_D8, 0x16, 0x51,
    247     WRITE_C8_D8, 0x17, 0x55,
    248     WRITE_C8_D8, 0x18, 0x59,
    249     WRITE_C8_D8, 0x19, 0x5D,
    250     WRITE_C8_D8, 0x1A, 0x60,
    251     WRITE_C8_D8, 0x1B, 0x64,
    252     WRITE_C8_D8, 0x1C, 0x68,
    253     WRITE_C8_D8, 0x1D, 0x6C,
    254     WRITE_C8_D8, 0x1E, 0x70,
    255     WRITE_C8_D8, 0x1F, 0x73,
    256     WRITE_C8_D8, 0x20, 0x77,
    257     WRITE_C8_D8, 0x21, 0x7B,
    258     WRITE_C8_D8, 0x22, 0x7F,
    259     WRITE_C8_D8, 0x23, 0x83,
    260     WRITE_C8_D8, 0x24, 0x87,
    261     WRITE_C8_D8, 0x25, 0x8A,
    262     WRITE_C8_D8, 0x26, 0x8E,
    263     WRITE_C8_D8, 0x27, 0x92,
    264     WRITE_C8_D8, 0x28, 0x96,
    265     WRITE_C8_D8, 0x29, 0x9A,
    266     WRITE_C8_D8, 0x2A, 0x9F,
    267     WRITE_C8_D8, 0x2B, 0xA3,
    268     WRITE_C8_D8, 0x2C, 0xA7,
    269     WRITE_C8_D8, 0x2D, 0xAC,
    270     WRITE_C8_D8, 0x2E, 0xAF,
    271     WRITE_C8_D8, 0x2F, 0xB3,
    272     WRITE_C8_D8, 0x30, 0xB7,
    273     WRITE_C8_D8, 0x31, 0xBA,
    274     WRITE_C8_D8, 0x32, 0xBE,
    275     WRITE_C8_D8, 0x33, 0xC3,
    276     WRITE_C8_D8, 0x34, 0xC7,
    277     WRITE_C8_D8, 0x35, 0xCC,
    278     WRITE_C8_D8, 0x36, 0xD1,
    279     WRITE_C8_D8, 0x37, 0xD7,
    280     WRITE_C8_D8, 0x38, 0xDD,
    281     WRITE_C8_D8, 0x39, 0xE3,
    282     WRITE_C8_D8, 0x3A, 0xE8,
    283     WRITE_C8_D8, 0x3B, 0xEA,
    284     WRITE_C8_D8, 0x3C, 0xEC,
    285     WRITE_C8_D8, 0x3D, 0xEF,
    286     WRITE_C8_D8, 0x3E, 0xF3,
    287     WRITE_C8_D8, 0x3F, 0xF6,
    288     WRITE_C8_D8, 0x40, 0xFE,
    289     WRITE_C8_D8, 0x41, 0x00,
    290     WRITE_C8_D8, 0x42, 0x01,
    291     WRITE_C8_D8, 0x43, 0x03,
    292     WRITE_C8_D8, 0x44, 0x05,
    293     WRITE_C8_D8, 0x45, 0x06,
    294     WRITE_C8_D8, 0x46, 0x08,
    295     WRITE_C8_D8, 0x47, 0x0C,
    296     WRITE_C8_D8, 0x48, 0x0E,
    297     WRITE_C8_D8, 0x49, 0x11,
    298     WRITE_C8_D8, 0x4A, 0x12,
    299     WRITE_C8_D8, 0x4B, 0x14,
    300     WRITE_C8_D8, 0x4C, 0x1B,
    301     WRITE_C8_D8, 0x4D, 0x23,
    302     WRITE_C8_D8, 0x4E, 0x29,
    303     WRITE_C8_D8, 0x4F, 0x2F,
    304     WRITE_C8_D8, 0x50, 0x34,
    305     WRITE_C8_D8, 0x51, 0x39,
    306     WRITE_C8_D8, 0x52, 0x3E,
    307     WRITE_C8_D8, 0x53, 0x43,
    308     WRITE_C8_D8, 0x54, 0x48,
    309     WRITE_C8_D8, 0x55, 0x4C,
    310     WRITE_C8_D8, 0x56, 0x51,
    311     WRITE_C8_D8, 0x57, 0x55,
    312     WRITE_C8_D8, 0x58, 0x59,
    313     WRITE_C8_D8, 0x59, 0x5D,
    314     WRITE_C8_D8, 0x5A, 0x60,
    315     WRITE_C8_D8, 0x5B, 0x64,
    316     WRITE_C8_D8, 0x5C, 0x68,
    317     WRITE_C8_D8, 0x5D, 0x6C,
    318     WRITE_C8_D8, 0x5E, 0x70,
    319     WRITE_C8_D8, 0x5F, 0x73,
    320     WRITE_C8_D8, 0x60, 0x77,
    321     WRITE_C8_D8, 0x61, 0x7B,
    322     WRITE_C8_D8, 0x62, 0x7F,
    323     WRITE_C8_D8, 0x63, 0x83,
    324     WRITE_C8_D8, 0x64, 0x87,
    325     WRITE_C8_D8, 0x65, 0x8A,
    326     WRITE_C8_D8, 0x66, 0x8E,
    327     WRITE_C8_D8, 0x67, 0x92,
    328     WRITE_C8_D8, 0x68, 0x96,
    329     WRITE_C8_D8, 0x69, 0x9A,
    330     WRITE_C8_D8, 0x6A, 0x9F,
    331     WRITE_C8_D8, 0x6B, 0xA3,
    332     WRITE_C8_D8, 0x6C, 0xA7,
    333     WRITE_C8_D8, 0x6D, 0xAC,
    334     WRITE_C8_D8, 0x6E, 0xAF,
    335     WRITE_C8_D8, 0x6F, 0xB3,
    336     WRITE_C8_D8, 0x70, 0xB7,
    337     WRITE_C8_D8, 0x71, 0xBA,
    338     WRITE_C8_D8, 0x72, 0xBE,
    339     WRITE_C8_D8, 0x73, 0xC3,
    340     WRITE_C8_D8, 0x74, 0xC7,
    341     WRITE_C8_D8, 0x75, 0xCC,
    342     WRITE_C8_D8, 0x76, 0xD1,
    343     WRITE_C8_D8, 0x77, 0xD7,
    344     WRITE_C8_D8, 0x78, 0xDD,
    345     WRITE_C8_D8, 0x79, 0xE3,
    346     WRITE_C8_D8, 0x7A, 0xE8,
    347     WRITE_C8_D8, 0x7B, 0xEA,
    348     WRITE_C8_D8, 0x7C, 0xEC,
    349     WRITE_C8_D8, 0x7D, 0xEF,
    350     WRITE_C8_D8, 0x7E, 0xF3,
    351     WRITE_C8_D8, 0x7F, 0xF6,
    352     WRITE_C8_D8, 0x80, 0xFE,
    353     WRITE_C8_D8, 0x81, 0x00,
    354     WRITE_C8_D8, 0x82, 0x01,
    355     WRITE_C8_D8, 0x83, 0x03,
    356     WRITE_C8_D8, 0x84, 0x05,
    357     WRITE_C8_D8, 0x85, 0x06,
    358     WRITE_C8_D8, 0x86, 0x08,
    359     WRITE_C8_D8, 0x87, 0x0C,
    360     WRITE_C8_D8, 0x88, 0x0E,
    361     WRITE_C8_D8, 0x89, 0x11,
    362     WRITE_C8_D8, 0x8A, 0x12,
    363     WRITE_C8_D8, 0x8B, 0x14,
    364     WRITE_C8_D8, 0x8C, 0x1B,
    365     WRITE_C8_D8, 0x8D, 0x23,
    366     WRITE_C8_D8, 0x8E, 0x29,
    367     WRITE_C8_D8, 0x8F, 0x2F,
    368     WRITE_C8_D8, 0x90, 0x34,
    369     WRITE_C8_D8, 0x91, 0x39,
    370     WRITE_C8_D8, 0x92, 0x3E,
    371     WRITE_C8_D8, 0x93, 0x43,
    372     WRITE_C8_D8, 0x94, 0x48,
    373     WRITE_C8_D8, 0x95, 0x4C,
    374     WRITE_C8_D8, 0x96, 0x51,
    375     WRITE_C8_D8, 0x97, 0x55,
    376     WRITE_C8_D8, 0x98, 0x59,
    377     WRITE_C8_D8, 0x99, 0x5D,
    378     WRITE_C8_D8, 0x9A, 0x60,
    379     WRITE_C8_D8, 0x9B, 0x64,
    380     WRITE_C8_D8, 0x9C, 0x68,
    381     WRITE_C8_D8, 0x9D, 0x6C,
    382     WRITE_C8_D8, 0x9E, 0x70,
    383     WRITE_C8_D8, 0x9F, 0x73,
    384     WRITE_C8_D8, 0xA0, 0x77,
    385     WRITE_C8_D8, 0xA1, 0x7B,
    386     WRITE_C8_D8, 0xA2, 0x7F,
    387     WRITE_C8_D8, 0xA3, 0x83,
    388     WRITE_C8_D8, 0xA4, 0x87,
    389     WRITE_C8_D8, 0xA5, 0x8A,
    390     WRITE_C8_D8, 0xA6, 0x8E,
    391     WRITE_C8_D8, 0xA7, 0x92,
    392     WRITE_C8_D8, 0xA8, 0x96,
    393     WRITE_C8_D8, 0xA9, 0x9A,
    394     WRITE_C8_D8, 0xAA, 0x9F,
    395     WRITE_C8_D8, 0xAB, 0xA3,
    396     WRITE_C8_D8, 0xAC, 0xA7,
    397     WRITE_C8_D8, 0xAD, 0xAC,
    398     WRITE_C8_D8, 0xAE, 0xAF,
    399     WRITE_C8_D8, 0xAF, 0xB3,
    400     WRITE_C8_D8, 0xB0, 0xB7,
    401     WRITE_C8_D8, 0xB1, 0xBA,
    402     WRITE_C8_D8, 0xB2, 0xBE,
    403     WRITE_C8_D8, 0xB3, 0xC3,
    404     WRITE_C8_D8, 0xB4, 0xC7,
    405     WRITE_C8_D8, 0xB5, 0xCC,
    406     WRITE_C8_D8, 0xB6, 0xD1,
    407     WRITE_C8_D8, 0xB7, 0xD7,
    408     WRITE_C8_D8, 0xB8, 0xDD,
    409     WRITE_C8_D8, 0xB9, 0xE3,
    410     WRITE_C8_D8, 0xBA, 0xE8,
    411     WRITE_C8_D8, 0xBB, 0xEA,
    412     WRITE_C8_D8, 0xBC, 0xEC,
    413     WRITE_C8_D8, 0xBD, 0xEF,
    414     WRITE_C8_D8, 0xBE, 0xF3,
    415     WRITE_C8_D8, 0xBF, 0xF6,
    416     WRITE_C8_D8, 0xC0, 0xFE,
    417 
    418     WRITE_C8_D8, 0xff, 0x00,
    419     WRITE_C8_D8, HX8357A_TE_CONTROL, 0x08,
    420     WRITE_C8_D8, HX8357A_CENON_CONTROL, 0x00,
    421     WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_1, 0x1F, // EQVCI_M1=0x00
    422     WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_2, 0x1F, // EQGND_M1=0x1C
    423     WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_3, 0x20, // EQVCI_M0=0x1C
    424     WRITE_C8_D8, HX8357A_POWER_SAVING_COUNTER_4, 0x00, // EQGND_M0=0x1C
    425     WRITE_C8_D8, HX8357A_OPON_CONTROL_1, 0xD1,
    426     WRITE_C8_D8, HX8357A_OPON_CONTROL_2, 0xC0,
    427     WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_3, 0x38,
    428     END_WRITE,
    429     DELAY, 80,
    430     BEGIN_WRITE,
    431     WRITE_C8_D8, HX8357A_DISPLAY_CONTROL_3, 0x3C, // GON=1, DTE=1, D[1:0]=11
    432     END_WRITE,
    433     DELAY, 100};
    434 
    435 class Arduino_HX8357A : public Arduino_TFT
    436 {
    437 public:
    438   Arduino_HX8357A(Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false);
    439 
    440   bool begin(int32_t speed = GFX_NOT_DEFINED) override;
    441 
    442   void setRotation(uint8_t r) override;
    443 
    444   void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override;
    445 
    446   void invertDisplay(bool) override;
    447   void displayOn() override;
    448   void displayOff() override;
    449 
    450 protected:
    451   void tftInit() override;
    452 
    453 private:
    454 };
    455 
    456 #endif