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_HX8369A.h (6777B)
1 #ifndef _ARDUINO_HX8369A_H_ 2 #define _ARDUINO_HX8369A_H_ 3 4 #include <Arduino.h> 5 #include <Print.h> 6 #include "../Arduino_GFX.h" 7 #include "../Arduino_TFT.h" 8 9 #define HX8369A_TFTWIDTH 480 // HX8369A max TFT width 10 #define HX8369A_TFTHEIGHT 864 // HX8369A max TFT height 11 12 #define HX8369A_RST_DELAY 150 // delay ms wait for reset finish 13 14 #define HX8369A_NOP 0x00 15 #define HX8369A_SWRESET 0x01 16 #define HX8369A_RDNUMPE 0x05 // Read number of the parity errors 17 #define HX8369A_GET_RED_CHANNEL 0x06 18 #define HX8369A_GET_GREEN_CHANNEL 0x07 19 #define HX8369A_GET_BLUE_CHANNEL 0x08 20 #define HX8369A_GET_POWER_MODE 0x0A 21 #define HX8369A_READ_DISPLAY_MADCTL 0x0B 22 #define HX8369A_GET_PIXEL_FORMAT 0x0C 23 #define HX8369A_GET_DISPLAY_MODE 0x0D 24 #define HX8369A_GET_SIGNAL_MODE 0x0E 25 #define HX8369A_GET_DIAGNOSTIC_RESULT 0x0F 26 #define HX8369A_ENTER_SLEEP_MODE 0x10 27 #define HX8369A_EXIT_SLEEP_MODE 0x11 28 #define HX8369A_ENTER_PARTIAL_MODE 0x12 29 #define HX8369A_ENTER_NORMAL_MODE 0x13 30 #define HX8369A_EXIT_INVERSION_MODE 0x20 31 #define HX8369A_ENTER_INVERSION_MODE 0x21 32 #define HX8369A_SET_GAMMA_CURVE 0x26 33 #define HX8369A_SET_DISPLAY_OFF 0x28 34 #define HX8369A_SET_DISPLAY_ON 0x29 35 #define HX8369A_SET_CLUMN_ADDRESS 0x2A 36 #define HX8369A_SET_PAGE_ADDRESS 0x2B 37 #define HX8369A_WRITE_MEMORY_START 0x2C 38 #define HX8369A_COLOUR_SET 0x2D 39 #define HX8369A_RAED_MEMORY_START 0x2E 40 #define HX8369A_SET_PARTIAL_AREA 0x30 41 #define HX8369A_SET_SCROLL_AREA 0x33 42 #define HX8369A_TEARING_EFFECT_LINE_OFF 0x34 43 #define HX8369A_SET_TEAR_ON 0x35 44 #define HX8369A_SET_ADDRESS_MODE 0x36 45 #define HX8369A_SET_SCROLL_START 0x37 46 #define HX8369A_IDLE_MODE_OFF 0x38 47 #define HX8369A_ENTER_IDLE_MODE 0x39 48 #define HX8369A_SET_PIXEL_FORMAT 0x3A 49 #define HX8369A_WRITE_MEMORY_CONTIUNE 0x3C 50 #define HX8369A_RAED_MEMORY_CONTINUE 0x3E 51 #define HX8369A_SET_TEAR_SCAN_LINES 0x44H 52 #define HX8369A_GET_THE_CURRENT_SCANLINE 0x45 53 #define HX8369A_WRITE_DISPLAY_BRIGHTNESS 0x51 54 #define HX8369A_READ_DISPLAY_BRIGHTNESS_VALUE 0x52 55 #define HX8369A_WRITE_CTRL_DISPLAY 0x53 56 #define HX8369A_READ_CTRL_VALUE_DISPLAY 0x54 57 #define HX8369A_WRITE_CONTENT_ADAPTIVE_BRIGHTNESS_CONTROL 0x55 58 #define HX8369A_READ_CONTENT_ADAPTIVE_BRIGHTNESS_CONTROL 0x56 59 #define HX8369A_WRITE_CABC_MINIMUM_BRIGHTNESS 0x5E 60 #define HX8369A_READ_CABC_MINIMUM_BRIGHTNESS 0x5F 61 #define HX8369A_READ_AUTOMATIC_BRIGHTNESS_CONTROL_SELF_DIAGNOSTIC_RESULT 0x68 62 #define HX8369A_READ_DDB_START 0xA1 63 #define HX8369A_READ_DDB_CONTINUE 0xA8 64 #define HX8369A_READ_ID1 0xDA 65 #define HX8369A_READ_ID2 0xDB 66 #define HX8369A_READ_ID3 0xDC 67 #define HX8369A_SETOSC 0xB0 // Set internal oscillator 68 #define HX8369A_SETPOWER 0xB1 // Set power 69 #define HX8369A_SETDISP 0xB2 // Set display related register 70 #define HX8369A_SETRGBIF 0xB3 // Set RGB interface related register 71 #define HX8369A_SETCYC 0xB4 // Set display waveform cycle 72 #define HX8369A_SETVCOM 0xB6 // Set VCOM voltage 73 #define HX8369A_SETEXTC 0xB9 // Set extension command 74 #define HX8369A_SETMIPI 0xBA 75 #define HX8369A_SETOTP 0xBB // Set OTP 76 #define HX8369A_SETDGCLUT 0xC1 // Set DGC LUT 77 #define HX8369A_SETID 0xC3 // Set ID 78 #define HX8369A_SETPANEL 0xCC 79 #define HX8369A_SETGIP 0xD5 80 #define HX8369A_SETTPSNR 0xD8 81 #define HX8369A_SETGAMMA 0xE0 // Set gamma curve related setting 82 #define HX8369A_SETOTPKEY 0xE9 83 #define HX8369A_GETHXID 0xF4 84 #define HX8369A_SETCNCD_GETCNCD 0xFD 85 #define HX8369A_SET_SPI_READ_INDEX 0xFE 86 #define HX8369A_GETSPIREAD 0xFF // Read command data 87 88 #define HX8369A_MADCTL_MY 0x80 89 #define HX8369A_MADCTL_MX 0x40 90 #define HX8369A_MADCTL_MV 0x20 91 #define HX8369A_MADCTL_ML 0x20 92 #define HX8369A_MADCTL_BGR 0x08 93 #define HX8369A_MADCTL_SS 0x04 94 95 static const uint8_t hx8369a_init_operations_part1[] = { 96 BEGIN_WRITE, 97 WRITE_COMMAND_8, HX8369A_SETEXTC, 98 WRITE_BYTES, 3, 0xFF, 0x83, 0x69, 99 100 WRITE_COMMAND_8, HX8369A_SETPOWER, // Set Power 101 WRITE_BYTES, 19, 102 0x01, 0x00, 0x34, 0x07, 103 0x00, 0x01, 0x0F, 0x2A, 104 0x32, 0x3F, 0x3F, 0x07, 105 0x10, 0x01, 0xE6, 0xE6, 106 0xE6, 0xE6, 0xE6, 107 108 WRITE_COMMAND_8, HX8369A_SETDISP, 109 WRITE_BYTES, 15, 110 0x00, 0x00, 0x03, 0x03, 111 0x70, 0x00, 0xFF, 0x00, 112 0x00, 0x00, 0x00, 0x03, 113 0x03, 0x00, 0x01, 114 115 WRITE_COMMAND_8, HX8369A_SETCYC, 116 WRITE_BYTES, 5, 0x00, 0x0C, 0xA0, 0x0E, 0x06, 117 118 WRITE_C8_D16, HX8369A_SETVCOM, 0x2C, 0x2C, 119 120 WRITE_COMMAND_8, HX8369A_SETGIP, 121 WRITE_BYTES, 26, 122 0x00, 0x05, 0x03, 0x00, 123 0x01, 0x09, 0x10, 0x80, 124 0x37, 0x37, 0x20, 0x31, 125 0x46, 0x8A, 0x57, 0x9B, 126 0x20, 0x31, 0x46, 0x8A, 127 0x57, 0x9B, 0x07, 0x0F, 128 0x02, 0x00, 129 130 WRITE_COMMAND_8, HX8369A_SETGAMMA, 131 WRITE_BYTES, 34, 132 0x00, 0x08, 0x0D, 0x2D, 133 0x34, 0x3F, 0x19, 0x38, 134 0x09, 0x0E, 0x0E, 0x12, 135 0x14, 0x12, 0x14, 0x13, 136 0x19, 0x00, 0x08, 0x0D, 137 0x2D, 0x34, 0x3F, 0x19, 138 0x38, 0x09, 0x0E, 0x0E, 139 0x12, 0x14, 0x12, 0x14, 140 0x13, 0x19, 141 142 WRITE_COMMAND_8, HX8369A_SETDGCLUT, 143 WRITE_BYTES, 127, 144 0x01, 0x02, 0x08, 0x12, 145 0x1A, 0x22, 0x2A, 0x31, 146 0x36, 0x3F, 0x48, 0x51, 147 0x58, 0x60, 0x68, 0x70, 148 0x78, 0x80, 0x88, 0x90, 149 0x98, 0xA0, 0xA7, 0xAF, 150 0xB6, 0xBE, 0xC7, 0xCE, 151 0xD6, 0xDE, 0xE6, 0xEF, 152 0xF5, 0xFB, 0xFC, 0xFE, 153 0x8C, 0xA4, 0x19, 0xEC, 154 0x1B, 0x4C, 0x40, 0x02, 155 0x08, 0x12, 0x1A, 0x22, 156 0x2A, 0x31, 0x36, 0x3F, 157 0x48, 0x51, 0x58, 0x60, 158 0x68, 0x70, 0x78, 0x80, 159 0x88, 0x90, 0x98, 0xA0, 160 0xA7, 0xAF, 0xB6, 0xBE, 161 0xC7, 0xCE, 0xD6, 0xDE, 162 0xE6, 0xEF, 0xF5, 0xFB, 163 0xFC, 0xFE, 0x8C, 0xA4, 164 0x19, 0xEC, 0x1B, 0x4C, 165 0x40, 0x02, 0x08, 0x12, 166 0x1A, 0x22, 0x2A, 0x31, 167 0x36, 0x3F, 0x48, 0x51, 168 0x58, 0x60, 0x68, 0x70, 169 0x78, 0x80, 0x88, 0x90, 170 0x98, 0xA0, 0xA7, 0xAF, 171 0xB6, 0xBE, 0xC7, 0xCE, 172 0xD6, 0xDE, 0xE6, 0xEF, 173 0xF5, 0xFB, 0xFC, 0xFE, 174 0x8C, 0xA4, 0x19, 0xEC, 175 0x1B, 0x4C, 0x40, 176 177 WRITE_COMMAND_8, HX8369A_COLOUR_SET}; 178 179 static const uint8_t hx8369a_init_operations_part2[] = { 180 WRITE_C8_D8, HX8369A_SET_TEAR_ON, 0x00, 181 182 WRITE_C8_D8, HX8369A_SET_PIXEL_FORMAT, 0x55, 183 184 WRITE_COMMAND_8, HX8369A_EXIT_SLEEP_MODE, 185 END_WRITE, 186 187 DELAY, 120, 188 189 BEGIN_WRITE, 190 WRITE_COMMAND_8, HX8369A_SET_DISPLAY_ON, // Display On 191 END_WRITE}; 192 193 class Arduino_HX8369A : public Arduino_TFT 194 { 195 public: 196 Arduino_HX8369A( 197 Arduino_DataBus *bus, int8_t rst = GFX_NOT_DEFINED, uint8_t r = 0, bool ips = false, 198 int16_t w = HX8369A_TFTWIDTH, int16_t h = HX8369A_TFTHEIGHT, 199 uint8_t col_offset1 = 0, uint8_t row_offset1 = 0, uint8_t col_offset2 = 0, uint8_t row_offset2 = 0); 200 201 bool begin(int32_t speed = GFX_NOT_DEFINED) override; 202 203 void setRotation(uint8_t r) override; 204 205 void writeAddrWindow(int16_t x, int16_t y, uint16_t w, uint16_t h) override; 206 207 void invertDisplay(bool) override; 208 void displayOn() override; 209 void displayOff() override; 210 211 protected: 212 void tftInit() override; 213 214 private: 215 }; 216 217 #endif