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 |
ST7735_Init.h (9619B)
1 2 // This is the command sequence that initialises the ST7735 driver 3 // 4 // This setup information is in a format accepted by the commandList() function 5 // which reduces FLASH space, but on an ESP8266 there is plenty available! 6 // 7 // See ILI9341_Setup.h file for an alternative simpler format 8 9 { 10 // Initialization commands for ST7735 screens 11 static const uint8_t PROGMEM 12 Bcmd[] = { // Initialization commands for 7735B screens 13 18, // 18 commands in list: 14 ST7735_SWRESET, TFT_INIT_DELAY, // 1: Software reset, no args, w/delay 15 50, // 50 ms delay 16 ST7735_SLPOUT , TFT_INIT_DELAY, // 2: Out of sleep mode, no args, w/delay 17 255, // 255 = 500 ms delay 18 ST7735_COLMOD , 1+TFT_INIT_DELAY, // 3: Set color mode, 1 arg + delay: 19 0x05, // 16-bit color 20 10, // 10 ms delay 21 ST7735_FRMCTR1, 3+TFT_INIT_DELAY, // 4: Frame rate control, 3 args + delay: 22 0x00, // fastest refresh 23 0x06, // 6 lines front porch 24 0x03, // 3 lines back porch 25 10, // 10 ms delay 26 ST7735_MADCTL , 1 , // 5: Memory access ctrl (directions), 1 arg: 27 0x40 | TFT_MAD_COLOR_ORDER, // Row addr/col addr, bottom to top refresh 28 ST7735_DISSET5, 2 , // 6: Display settings #5, 2 args, no delay: 29 0x15, // 1 clk cycle nonoverlap, 2 cycle gate 30 // rise, 3 cycle osc equalize 31 0x02, // Fix on VTL 32 ST7735_INVCTR , 1 , // 7: Display inversion control, 1 arg: 33 0x0, // Line inversion 34 ST7735_PWCTR1 , 2+TFT_INIT_DELAY, // 8: Power control, 2 args + delay: 35 0x02, // GVDD = 4.7V 36 0x70, // 1.0uA 37 10, // 10 ms delay 38 ST7735_PWCTR2 , 1 , // 9: Power control, 1 arg, no delay: 39 0x05, // VGH = 14.7V, VGL = -7.35V 40 ST7735_PWCTR3 , 2 , // 10: Power control, 2 args, no delay: 41 0x01, // Opamp current small 42 0x02, // Boost frequency 43 ST7735_VMCTR1 , 2+TFT_INIT_DELAY, // 11: Power control, 2 args + delay: 44 0x3C, // VCOMH = 4V 45 0x38, // VCOML = -1.1V 46 10, // 10 ms delay 47 ST7735_PWCTR6 , 2 , // 12: Power control, 2 args, no delay: 48 0x11, 0x15, 49 ST7735_GMCTRP1,16 , // 13: Magical unicorn dust, 16 args, no delay: 50 0x09, 0x16, 0x09, 0x20, // (seriously though, not sure what 51 0x21, 0x1B, 0x13, 0x19, // these config values represent) 52 0x17, 0x15, 0x1E, 0x2B, 53 0x04, 0x05, 0x02, 0x0E, 54 ST7735_GMCTRN1,16+TFT_INIT_DELAY, // 14: Sparkles and rainbows, 16 args + delay: 55 0x0B, 0x14, 0x08, 0x1E, // (ditto) 56 0x22, 0x1D, 0x18, 0x1E, 57 0x1B, 0x1A, 0x24, 0x2B, 58 0x06, 0x06, 0x02, 0x0F, 59 10, // 10 ms delay 60 ST7735_CASET , 4 , // 15: Column addr set, 4 args, no delay: 61 0x00, 0x02, // XSTART = 2 62 0x00, 0x81, // XEND = 129 63 ST7735_RASET , 4 , // 16: Row addr set, 4 args, no delay: 64 0x00, 0x02, // XSTART = 1 65 0x00, 0x81, // XEND = 160 66 ST7735_NORON , TFT_INIT_DELAY, // 17: Normal display on, no args, w/delay 67 10, // 10 ms delay 68 ST7735_DISPON , TFT_INIT_DELAY, // 18: Main screen turn on, no args, w/delay 69 255 }, // 255 = 500 ms delay 70 71 Rcmd1[] = { // Init for 7735R, part 1 (red or green tab) 72 15, // 15 commands in list: 73 ST7735_SWRESET, TFT_INIT_DELAY, // 1: Software reset, 0 args, w/delay 74 150, // 150 ms delay 75 ST7735_SLPOUT , TFT_INIT_DELAY, // 2: Out of sleep mode, 0 args, w/delay 76 255, // 500 ms delay 77 ST7735_FRMCTR1, 3 , // 3: Frame rate ctrl - normal mode, 3 args: 78 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) 79 ST7735_FRMCTR2, 3 , // 4: Frame rate control - idle mode, 3 args: 80 0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D) 81 ST7735_FRMCTR3, 6 , // 5: Frame rate ctrl - partial mode, 6 args: 82 0x01, 0x2C, 0x2D, // Dot inversion mode 83 0x01, 0x2C, 0x2D, // Line inversion mode 84 ST7735_INVCTR , 1 , // 6: Display inversion ctrl, 1 arg, no delay: 85 0x07, // No inversion 86 ST7735_PWCTR1 , 3 , // 7: Power control, 3 args, no delay: 87 0xA2, 88 0x02, // -4.6V 89 0x84, // AUTO mode 90 ST7735_PWCTR2 , 1 , // 8: Power control, 1 arg, no delay: 91 0xC5, // VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD 92 ST7735_PWCTR3 , 2 , // 9: Power control, 2 args, no delay: 93 0x0A, // Opamp current small 94 0x00, // Boost frequency 95 ST7735_PWCTR4 , 2 , // 10: Power control, 2 args, no delay: 96 0x8A, // BCLK/2, Opamp current small & Medium low 97 0x2A, 98 ST7735_PWCTR5 , 2 , // 11: Power control, 2 args, no delay: 99 0x8A, 0xEE, 100 ST7735_VMCTR1 , 1 , // 12: Power control, 1 arg, no delay: 101 0x0E, 102 ST7735_INVOFF , 0 , // 13: Don't invert display, no args, no delay 103 ST7735_MADCTL , 1 , // 14: Memory access control (directions), 1 arg: 104 0xC0 | TFT_MAD_COLOR_ORDER, // row addr/col addr, bottom to top refresh 105 ST7735_COLMOD , 1 , // 15: set color mode, 1 arg, no delay: 106 0x05 }, // 16-bit color 107 108 Rcmd2green[] = { // Init for 7735R, part 2 (green tab only) 109 2, // 2 commands in list: 110 ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 111 0x00, 0x02, // XSTART = 0 112 0x00, 0x7F+0x02, // XEND = 127 113 ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 114 0x00, 0x01, // XSTART = 0 115 0x00, 0x9F+0x01 }, // XEND = 159 116 117 Rcmd2red[] = { // Init for 7735R, part 2 (red tab only) 118 2, // 2 commands in list: 119 ST7735_CASET , 4 , // 1: Column addr set, 4 args, no delay: 120 0x00, 0x00, // XSTART = 0 121 0x00, 0x7F, // XEND = 127 122 ST7735_RASET , 4 , // 2: Row addr set, 4 args, no delay: 123 0x00, 0x00, // XSTART = 0 124 0x00, 0x9F }, // XEND = 159 125 126 // Frame control init for RobotLCD, taken from https://github.com/arduino-libraries/TFT, Adafruit_ST7735.cpp l. 263, commit 61b8a7e 127 Rcmd3RobotLCD[] = { 128 3, 129 ST7735_FRMCTR1, 2 , // 1: Frame rate ctrl - normal mode, 2 args 130 0x0B, 0x14, 131 ST7735_FRMCTR2, 2 , // 2: Frame rate ctrl - idle mode, 2 args 132 0x0B, 0x14, 133 ST7735_FRMCTR3, 4 , // 3: Frame rate ctrl - partial mode, 4 args 134 0x0B, 0x14, 135 0x0B, 0x14 }, 136 137 Rcmd3[] = { // Init for 7735R, part 3 (red or green tab) 138 4, // 4 commands in list: 139 ST7735_GMCTRP1, 16 , // 1: 16 args, no delay: 140 0x02, 0x1c, 0x07, 0x12, 141 0x37, 0x32, 0x29, 0x2d, 142 0x29, 0x25, 0x2B, 0x39, 143 0x00, 0x01, 0x03, 0x10, 144 ST7735_GMCTRN1, 16 , // 2: 16 args, no delay: 145 0x03, 0x1d, 0x07, 0x06, 146 0x2E, 0x2C, 0x29, 0x2D, 147 0x2E, 0x2E, 0x37, 0x3F, 148 0x00, 0x00, 0x02, 0x10, 149 ST7735_NORON , TFT_INIT_DELAY, // 3: Normal display on, no args, w/delay 150 10, // 10 ms delay 151 ST7735_DISPON , TFT_INIT_DELAY, // 4: Main screen turn on, no args w/delay 152 100 }; // 100 ms delay 153 154 if (tabcolor == INITB) 155 { 156 commandList(Bcmd); 157 } 158 else 159 { 160 commandList(Rcmd1); 161 162 if (tabcolor == INITR_GREENTAB) 163 { 164 commandList(Rcmd2green); 165 colstart = 2; 166 rowstart = 1; 167 } 168 else if (tabcolor == INITR_GREENTAB2) 169 { 170 commandList(Rcmd2green); 171 writecommand(ST7735_MADCTL); 172 writedata(0xC0 | TFT_MAD_COLOR_ORDER); 173 colstart = 2; 174 rowstart = 1; 175 } 176 else if (tabcolor == INITR_GREENTAB3) 177 { 178 commandList(Rcmd2green); 179 colstart = 2; 180 rowstart = 3; 181 } 182 else if (tabcolor == INITR_GREENTAB128) 183 { 184 commandList(Rcmd2green); 185 colstart = 0; 186 rowstart = 32; 187 } 188 else if (tabcolor == INITR_GREENTAB160x80) 189 { 190 commandList(Rcmd2green); 191 writecommand(TFT_INVON); 192 colstart = 26; 193 rowstart = 1; 194 } 195 else if (tabcolor == INITR_ROBOTLCD) 196 { 197 commandList(Rcmd2green); 198 commandList(Rcmd3RobotLCD); 199 } 200 else if (tabcolor == INITR_REDTAB160x80) 201 { 202 commandList(Rcmd2green); 203 colstart = 24; 204 rowstart = 0; 205 } 206 else if (tabcolor == INITR_REDTAB) 207 { 208 commandList(Rcmd2red); 209 } 210 else if (tabcolor == INITR_BLACKTAB) 211 { 212 writecommand(ST7735_MADCTL); 213 writedata(0xC0 | TFT_MAD_COLOR_ORDER); 214 } 215 216 commandList(Rcmd3); 217 } 218 }