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 |
PDQgraphicstest.ino (53254B)
1 /* 2 Adapted from the Adafruit and Xark's PDQ graphicstest sketch. 3 4 See end of file for original header text and MIT license info. 5 */ 6 7 /******************************************************************************* 8 * Start of Arduino_GFX setting 9 ******************************************************************************/ 10 /* Arduino_GFX try to find the settings depends on selected board in Arduino IDE */ 11 /* Or you can define the dev kit cannot find in board list */ 12 #include <Arduino_GFX_Library.h> 13 14 // #define DRAGON_RADAR 15 // #define ESP32_1732S019 16 // #define ESP32_2424012 17 // #define ESP32_2432S028 18 // #define ESP32_3248S035 19 // #define ESP32_4827A043 20 // #define ESP32_4827S043 21 // #define ESP32_8048S070 22 // #define ESP32_LCDKIT_SPI 23 // #define ESP32_LCDKIT_PAR8A 24 // #define ESP32_LCDKIT_PAR8B 25 // #define ESP32_LCDKIT_PAR16 26 // #define ESP32_S3_EYE 27 // #define ESP32_S3_RGB 28 // #define ESP32_S3_RPI_DPI 29 // #define ESP32S3_2_1_TP 30 // #define LILYGO_T_DISPLAY 31 // #define LILYGO_T_DISPLAY_S3 32 // #define LILYGO_T_RGB 33 // #define LILYGO_T_QT 34 // #define LILYGO_T_WATCH_2021 35 // #define MAKERFABS_TFT_TOUCH_3_5 36 // #define MAKERFABS_ESP32_S3_TFT_4_0 37 // #define MAKERFABS_ESP32_S3_TFT_4_3_v1_3 38 // #define WT32_SC01 39 // #define ZX2D10GE10R_V4848 40 // #define ZX3D50CE02S // or called "WT32-SC01 PLUS" 41 // #define ZX3D95CE01S_AR 42 43 #if defined(DRAGON_RADAR) 44 #define GFX_BL 38 45 Arduino_DataBus *bus = new Arduino_SWSPI( 46 GFX_NOT_DEFINED /* DC */, 39 /* CS */, 47 48 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 48 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 49 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 50 11 /* R0 */, 12 /* R1 */, 13 /* R2 */, 45 /* R3 */, 0 /* R4 */, 51 8 /* G0 */, 19 /* G1 */, 20 /* G2 */, 46 /* G3 */, 9 /* G4 */, 10 /* G5 */, 52 4 /* B0 */, 5 /* B1 */, 6 /* B2 */, 7 /* B3 */, 15 /* B4 */, 53 1 /* hsync_polarity */, 22 /* hsync_front_porch */, 3 /* hsync_pulse_width */, 45 /* hsync_back_porch */, 54 1 /* vsync_polarity */, 4 /* vsync_front_porch */, 12 /* vsync_pulse_width */, 40 /* vsync_back_porch */); 55 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 56 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 57 bus, GFX_NOT_DEFINED /* RST */, st7701_type6_init_operations, sizeof(st7701_type6_init_operations)); 58 59 #elif defined(ESP32_1732S019) 60 #define GFX_BL 14 61 Arduino_DataBus *bus = new Arduino_ESP32SPI(11 /* DC */, 10 /* CS */, 12 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 62 Arduino_GFX *gfx = new Arduino_ST7789(bus, 1 /* RST */, 0 /* rotation */, true /* IPS */, 170 /* width */, 320 /* height */, 35 /* col offset 1 */, 0 /* row offset 1 */, 35 /* col offset 2 */, 0 /* row offset 2 */); 63 64 #elif defined(ESP32_2424012) 65 #define GFX_BL 8 66 Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 10 /* CS */, 6 /* SCK */, 7 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 67 Arduino_GFX *gfx = new Arduino_GC9A01(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */); 68 69 #elif defined(ESP32_2432S028) 70 #define GFX_BL 21 71 Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */); 72 Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */); 73 74 #elif defined(ESP32_3248S035) 75 #define GFX_BL 27 76 Arduino_DataBus *bus = new Arduino_ESP32SPI(2 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */, HSPI /* spi_num */); 77 Arduino_GFX *gfx = new Arduino_ST7796(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */); 78 79 #elif defined(ESP32_4827A043) 80 #define GFX_BL 2 81 Arduino_DataBus *bus = new Arduino_ESP32LCD16( 82 48 /* DC */, 45 /* CS */, 47 /* WR */, 21 /* RD */, 83 5 /* D0 */, 6 /* D1 */, 7 /* D2 */, 15 /* D3 */, 16 /* D4 */, 4 /* D5 */, 8 /* D6 */, 3 /* D7 */, 84 46 /* D8 */, 9 /* D9 */, 1 /* D10 */, 42 /* D11 */, 39 /* D12 */, 41 /* D13 */, 40 /* D14 */, 14 /* D15 */); 85 Arduino_GFX *gfx = new Arduino_NV3041A(bus, 17 /* RST */, 0 /* rotation */, true /* IPS */); 86 87 #elif defined(ESP32_4827S043) 88 #define GFX_BL 2 89 // option 1: 90 // Uncomment for ILI6485 LCD 480x272 91 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 92 40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */, 93 45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */, 94 5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */, 95 8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */, 96 0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 43 /* hsync_back_porch */, 97 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 12 /* vsync_back_porch */, 98 1 /* pclk_active_neg */, 9000000 /* prefer_speed */, 99 1 /* de_idle_high */, 1 /* pclk_idle_high */); 100 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 101 480 /* width */, 272 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */); 102 // option 2: 103 // Uncomment for ST7262 IPS LCD 800x480 104 // Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 105 // 40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */, 106 // 45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */, 107 // 5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */, 108 // 8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */, 109 // 0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 8 /* hsync_back_porch */, 110 // 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 8 /* vsync_back_porch */, 111 // 1 /* pclk_active_neg */, 16000000 /* prefer_speed */); 112 // Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 113 // 800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */); 114 // option 3: 115 // Uncomment for RPi DPI 1024x600 116 // Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 117 // 40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */, 118 // 45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */, 119 // 5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */, 120 // 8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */, 121 // 0 /* hsync_polarity */, 8 /* hsync_front_porch */, 4 /* hsync_pulse_width */, 43 /* hsync_back_porch */, 122 // 0 /* vsync_polarity */, 8 /* vsync_front_porch */, 4 /* vsync_pulse_width */, 12 /* vsync_back_porch */, 123 // 1 /* pclk_active_neg */, 9000000 /* prefer_speed */); 124 // Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 125 // 1024 /* width */, 600 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */); 126 127 #elif defined(ESP32_8048S070) 128 #define GFX_BL 2 129 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 130 41 /* DE */, 40 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */, 131 14 /* R0 */, 21 /* R1 */, 47 /* R2 */, 48 /* R3 */, 45 /* R4 */, 132 9 /* G0 */, 46 /* G1 */, 3 /* G2 */, 8 /* G3 */, 16 /* G4 */, 1 /* G5 */, 133 15 /* B0 */, 7 /* B1 */, 6 /* B2 */, 5 /* B3 */, 4 /* B4 */, 134 0 /* hsync_polarity */, 180 /* hsync_front_porch */, 30 /* hsync_pulse_width */, 16 /* hsync_back_porch */, 135 0 /* vsync_polarity */, 12 /* vsync_front_porch */, 13 /* vsync_pulse_width */, 10 /* vsync_back_porch */); 136 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 137 800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */); 138 139 #elif defined(ESP32_LCDKIT_SPI) 140 #define GFX_BL 23 141 Arduino_DataBus *bus = new Arduino_ESP32SPI(19 /* DC */, 5 /* CS */, 22 /* SCK */, 21 /* MOSI */, 27 /* MISO */); 142 Arduino_GFX *gfx = new Arduino_ILI9341(bus, 18 /* RST */, 1 /* rotation */); 143 144 #elif defined(ESP32_LCDKIT_PAR8A) 145 Arduino_DataBus *bus = new Arduino_ESP32PAR8(5 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, GFX_NOT_DEFINED /* RD */, 19 /* D0 */, 21 /* D1 */, 0 /* D2 */, 22 /* D3 */, 23 /* D4 */, 33 /* D5 */, 32 /* D6 */, 27 /* D7 */); 146 Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */); 147 148 #elif defined(ESP32_LCDKIT_PAR8B) 149 Arduino_DataBus *bus = new Arduino_ESP32PAR8(5 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, GFX_NOT_DEFINED /* RD */, 25 /* D0 */, 26 /* D1 */, 12 /* D2 */, 13 /* D3 */, 14 /* D4 */, 15 /* D5 */, 2 /* D6 */, 4 /* D7 */); 150 Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */); 151 152 #elif defined(ESP32_LCDKIT_PAR16) 153 Arduino_DataBus *bus = new Arduino_ESP32PAR16( 154 5 /* DC */, GFX_NOT_DEFINED /* CS */, 18 /* WR */, GFX_NOT_DEFINED /* RD */, 155 19 /* D0 */, 21 /* D1 */, 0 /* D2 */, 22 /* D3 */, 23 /* D4 */, 33 /* D5 */, 32 /* D6 */, 27 /* D7 */, 156 25 /* D8 */, 26 /* D9 */, 12 /* D10 */, 13 /* D11 */, 14 /* D12 */, 15 /* D13 */, 2 /* D14 */, 4 /* D15 */); 157 Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */); 158 159 #elif defined(ESP32_S3_EYE) 160 #define GFX_BL 48 161 Arduino_DataBus *bus = new Arduino_ESP32SPI(43 /* DC */, 44 /* CS */, 21 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 162 Arduino_GFX *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */, 240 /* width */, 240 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 80 /* row offset 2 */); 163 164 #elif defined(ESP32_S3_RGB) 165 #define GFX_BL 38 166 Arduino_DataBus *bus = new Arduino_SWSPI( 167 GFX_NOT_DEFINED /* DC */, 39 /* CS */, 168 48 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 169 170 // option 1: 171 // Uncomment for 4" rect display 172 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 173 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 174 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */, 175 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */, 176 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */, 177 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */, 178 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */); 179 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 180 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 181 bus, GFX_NOT_DEFINED /* RST */, st7701_type1_init_operations, sizeof(st7701_type1_init_operations)); 182 183 // option 2: 184 // Uncomment for 2.1" round display 185 // Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 186 // 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 187 // 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */, 188 // 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */, 189 // 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */, 190 // 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */, 191 // 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */); 192 // Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 193 // 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 194 // bus, GFX_NOT_DEFINED /* RST */, st7701_type5_init_operations, sizeof(st7701_type5_init_operations)); 195 196 // option 3: 197 // Uncomment for 2.8" round display 198 // Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 199 // 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 200 // 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */, 201 // 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */, 202 // 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */, 203 // 1 /* hsync_polarity */, 22 /* hsync_front_porch */, 3 /* hsync_pulse_width */, 45 /* hsync_back_porch */, 204 // 1 /* vsync_polarity */, 4 /* vsync_front_porch */, 12 /* vsync_pulse_width */, 40 /* vsync_back_porch */); 205 // Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 206 // 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 207 // bus, GFX_NOT_DEFINED /* RST */, st7701_type6_init_operations, sizeof(st7701_type6_init_operations)); 208 209 // option 4: 210 // Uncomment for 2.0" display 211 // Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 212 // 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 213 // 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */, 214 // 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */, 215 // 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */, 216 // 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */, 217 // 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */); 218 // Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 219 // 480 /* width */, 360 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 220 // bus, GFX_NOT_DEFINED /* RST */, st7701_type8_init_operations, sizeof(st7701_type8_init_operations)); 221 222 #elif defined(ESP32_S3_RPI_DPI) 223 // #define GFX_BL 38 224 225 // e.g. Waveshare 7" RPi DPI LCD: https://www.waveshare.com/wiki/7inch_LCD_for_Pi 226 // dpi_timings=1024 1 40 48 128 600 1 13 3 45 0 0 0 60 0 37000000 6 227 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 228 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 229 4 /* R0 */, 3 /* R1 */, 2 /* R2 */, 1 /* R3 */, 0 /* R4 */, 230 10 /* G0 */, 9 /* G1 */, 8 /* G2 */, 7 /* G3 */, 6 /* G4 */, 5 /* G5 */, 231 15 /* B0 */, 14 /* B1 */, 13 /* B2 */, 12 /* B3 */, 11 /* B4 */, 232 1 /* hsync_polarity */, 40 /* hsync_front_porch */, 48 /* hsync_pulse_width */, 128 /* hsync_back_porch */, 233 1 /* vsync_polarity */, 13 /* vsync_front_porch */, 3 /* vsync_pulse_width */, 45 /* vsync_back_porch */); 234 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 235 1024 /* width */, 600 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */); 236 237 #elif defined(ESP32S3_2_1_TP) 238 #define GFX_BL 38 239 Arduino_DataBus *bus = new Arduino_SWSPI( 240 GFX_NOT_DEFINED /* DC */, 39 /* CS */, 241 48 /* SCK */, 47 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 242 243 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 244 18 /* DE */, 17 /* VSYNC */, 16 /* HSYNC */, 21 /* PCLK */, 245 4 /* R0 */, 5 /* R1 */, 6 /* R2 */, 7 /* R3 */, 15 /* R4 */, 246 8 /* G0 */, 20 /* G1 */, 3 /* G2 */, 46 /* G3 */, 9 /* G4 */, 10 /* G5 */, 247 11 /* B0 */, 12 /* B1 */, 13 /* B2 */, 14 /* B3 */, 0 /* B4 */, 248 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */, 249 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */); 250 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 251 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 252 bus, GFX_NOT_DEFINED /* RST */, st7701_type5_init_operations, sizeof(st7701_type5_init_operations)); 253 254 #elif defined(LILYGO_T_DISPLAY) 255 #define GFX_BL 4 256 Arduino_DataBus *bus = new Arduino_ESP32SPI(16 /* DC */, 5 /* CS */, 18 /* SCK */, 19 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 257 Arduino_GFX *gfx = new Arduino_ST7789(bus, 23 /* RST */, 0 /* rotation */, true /* IPS */, 135 /* width */, 240 /* height */, 52 /* col offset 1 */, 40 /* row offset 1 */, 53 /* col offset 2 */, 40 /* row offset 2 */); 258 259 #elif defined(LILYGO_T_DISPLAY_S3) 260 #define GFX_EXTRA_PRE_INIT() \ 261 { \ 262 pinMode(15 /* PWD */, OUTPUT); \ 263 digitalWrite(15 /* PWD */, HIGH); \ 264 } 265 #define GFX_BL 38 266 Arduino_DataBus *bus = new Arduino_ESP32LCD8( 267 7 /* DC */, 6 /* CS */, 8 /* WR */, 9 /* RD */, 268 39 /* D0 */, 40 /* D1 */, 41 /* D2 */, 42 /* D3 */, 45 /* D4 */, 46 /* D5 */, 47 /* D6 */, 48 /* D7 */); 269 Arduino_GFX *gfx = new Arduino_ST7789(bus, 5 /* RST */, 0 /* rotation */, true /* IPS */, 170 /* width */, 320 /* height */, 35 /* col offset 1 */, 0 /* row offset 1 */, 35 /* col offset 2 */, 0 /* row offset 2 */); 270 271 #elif defined(LILYGO_T_RGB) 272 #include <Wire.h> 273 #define GFX_EXTRA_PRE_INIT() \ 274 { \ 275 Wire.begin(8 /* SDA */, 48 /* SCL */, 800000L /* speed */); \ 276 } 277 #define GFX_BL 46 278 Arduino_DataBus *bus = new Arduino_XL9535SWSPI(8 /* SDA */, 48 /* SCL */, 2 /* XL PWD */, 3 /* XL CS */, 5 /* XL SCK */, 4 /* XL MOSI */); 279 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 280 45 /* DE */, 41 /* VSYNC */, 47 /* HSYNC */, 42 /* PCLK */, 281 21 /* R0 */, 18 /* R1 */, 17 /* R2 */, 16 /* R3 */, 15 /* R4 */, 282 14 /* G0 */, 13 /* G1 */, 12 /* G2 */, 11 /* G3 */, 10 /* G4 */, 9 /* G5 */, 283 7 /* B0 */, 6 /* B1 */, 5 /* B2 */, 3 /* B3 */, 2 /* B4 */, 284 1 /* hsync_polarity */, 50 /* hsync_front_porch */, 1 /* hsync_pulse_width */, 30 /* hsync_back_porch */, 285 1 /* vsync_polarity */, 20 /* vsync_front_porch */, 1 /* vsync_pulse_width */, 30 /* vsync_back_porch */, 286 1 /* pclk_active_neg */); 287 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 288 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 289 bus, GFX_NOT_DEFINED /* RST */, st7701_type4_init_operations, sizeof(st7701_type4_init_operations)); 290 291 #elif defined(LILYGO_T_QT) 292 #define GFX_EXTRA_PRE_INIT() \ 293 { \ 294 pinMode(10 /* BL */, OUTPUT); \ 295 digitalWrite(10 /* BL */, LOW); \ 296 } 297 Arduino_DataBus *bus = new Arduino_ESP32SPI(6 /* DC */, 5 /* CS */, 3 /* SCK */, 2 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 298 Arduino_GFX *gfx = new Arduino_GC9107(bus, 1 /* RST */, 0 /* rotation */, true /* IPS */); 299 300 #elif defined(LILYGO_T_WATCH_2021) 301 #define GFX_BL 21 302 Arduino_DataBus *bus = new Arduino_ESP32SPI(19 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 303 Arduino_GFX *gfx = new Arduino_GC9A01(bus, 27 /* RST */, 0 /* rotation */, true /* IPS */); 304 305 #elif defined(MAKERFABS_TFT_TOUCH_3_5) 306 Arduino_DataBus *bus = new Arduino_ESP32SPI(33 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, 12 /* MISO */); 307 Arduino_GFX *gfx = new Arduino_ILI9488_18bit(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */); 308 309 #elif defined(MAKERFABS_ESP32_S3_TFT_4_0) 310 Arduino_DataBus *bus = new Arduino_SWSPI( 311 GFX_NOT_DEFINED /* DC */, 1 /* CS */, 312 12 /* SCK */, 11 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 313 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 314 45 /* DE */, 4 /* VSYNC */, 5 /* HSYNC */, 21 /* PCLK */, 315 39 /* R0 */, 40 /* R1 */, 41 /* R2 */, 42 /* R3 */, 2 /* R4 */, 316 0 /* G0 */, 9 /* G1 */, 14 /* G2 */, 47 /* G3 */, 48 /* G4 */, 3 /* G5 */, 317 6 /* B0 */, 7 /* B1 */, 15 /* B2 */, 16 /* B3 */, 8 /* B4 */, 318 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */, 319 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */); 320 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 321 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 322 bus, GFX_NOT_DEFINED /* RST */, st7701_type1_init_operations, sizeof(st7701_type1_init_operations)); 323 324 #elif defined(MAKERFABS_ESP32_S3_TFT_4_3_v1_3) 325 #define GFX_BL 2 326 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 327 40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */, 328 45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */, 329 5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */, 330 8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */, 331 0 /* hsync_polarity */, 40 /* hsync_front_porch */, 48 /* hsync_pulse_width */, 88 /* hsync_back_porch */, 332 0 /* vsync_polarity */, 13 /* vsync_front_porch */, 3 /* vsync_pulse_width */, 32 /* vsync_back_porch */, 333 1 /* pclk_active_neg */, 16000000 /* prefer_speed */); 334 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 335 800 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */); 336 337 #elif defined(WT32_SC01) 338 #define GFX_BL 23 339 Arduino_DataBus *bus = new Arduino_ESP32SPI(21 /* DC */, 15 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 340 Arduino_GFX *gfx = new Arduino_ST7796(bus, 22 /* RST */, 3 /* rotation */); 341 342 #elif defined(ZX2D10GE10R_V4848) 343 #define GFX_BL 38 344 Arduino_DataBus *bus = new Arduino_SWSPI( 345 GFX_NOT_DEFINED /* DC */, 21 /* CS */, 346 47 /* SCK */, 41 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 347 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 348 39 /* DE */, 48 /* VSYNC */, 40 /* HSYNC */, 45 /* PCLK */, 349 10 /* R0 */, 16 /* R1 */, 9 /* R2 */, 15 /* R3 */, 46 /* R4 */, 350 8 /* G0 */, 13 /* G1 */, 18 /* G2 */, 12 /* G3 */, 11 /* G4 */, 17 /* G5 */, 351 47 /* B0 */, 41 /* B1 */, 0 /* B2 */, 42 /* B3 */, 14 /* B4 */, 352 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 10 /* hsync_pulse_width */, 10 /* hsync_back_porch */, 353 1 /* vsync_polarity */, 14 /* vsync_front_porch */, 2 /* vsync_pulse_width */, 12 /* vsync_back_porch */); 354 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 355 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 356 bus, GFX_NOT_DEFINED /* RST */, st7701_type7_init_operations, sizeof(st7701_type7_init_operations)); 357 358 #elif defined(ZX3D50CE02S) 359 #define GFX_BL 45 360 Arduino_DataBus *bus = new Arduino_ESP32LCD8( 361 0 /* DC */, GFX_NOT_DEFINED /* CS */, 47 /* WR */, GFX_NOT_DEFINED /* RD */, 362 9 /* D0 */, 46 /* D1 */, 3 /* D2 */, 8 /* D3 */, 18 /* D4 */, 17 /* D5 */, 16 /* D6 */, 15 /* D7 */); 363 Arduino_GFX *gfx = new Arduino_ST7796(bus, 4 /* RST */, 0 /* rotation */, true /* IPS */); 364 365 #elif defined(ZX3D95CE01S_AR) 366 #define GFX_BL 45 367 Arduino_DataBus *bus = new Arduino_SWSPI( 368 GFX_NOT_DEFINED /* DC */, 0 /* CS */, 369 10 /* SCK */, 9 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 370 Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel( 371 13 /* DE */, 12 /* VSYNC */, 11 /* HSYNC */, 14 /* PCLK */, 372 2 /* R0 */, 17 /* R1 */, 16 /* R2 */, 1 /* R3 */, 15 /* R4 */, 373 41 /* G0 */, 46 /* G1 */, 3 /* G2 */, 42 /* G3 */, 8 /* G4 */, 18 /* G5 */, 374 10 /* B0 */, 9 /* B1 */, 40 /* B2 */, 20 /* B3 */, 19 /* B4 */, 375 1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */, 376 1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */); 377 Arduino_RGB_Display *gfx = new Arduino_RGB_Display( 378 480 /* width */, 480 /* height */, rgbpanel, 0 /* rotation */, true /* auto_flush */, 379 bus, GFX_NOT_DEFINED /* RST */, gc9503v_type1_init_operations, sizeof(gc9503v_type1_init_operations)); 380 381 /* Wio Terminal */ 382 #elif defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS) 383 // #define GFX_BL LCD_BACKLIGHT 384 Arduino_DataBus *bus = new Arduino_HWSPI(LCD_DC /* DC */, LCD_SS_PIN /* CS */); 385 Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */); 386 387 /* ESP32-S3-BOX */ 388 #elif defined(ARDUINO_ESP32_S3_BOX) 389 #define GFX_BL 45 390 Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_CLK, TFT_MOSI, TFT_MISO); 391 Arduino_GFX *gfx = new Arduino_ILI9342(bus, TFT_RST, 0 /* rotation */); 392 393 /* M5Stack */ 394 #elif defined(ARDUINO_M5Stack_Core_ESP32) || defined(ARDUINO_M5STACK_FIRE) 395 // #define GFX_BL 32 396 Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 14 /* CS */, SCK, MOSI, MISO); 397 Arduino_GFX *gfx = new Arduino_ILI9342(bus, 33 /* RST */, 2 /* rotation */); 398 399 /* Odroid-Go */ 400 #elif defined(ARDUINO_ODROID_ESP32) 401 // #define GFX_BL 14 402 Arduino_DataBus *bus = new Arduino_ESP32SPI(21 /* DC */, 5 /* CS */, SCK, MOSI, MISO); 403 Arduino_GFX *gfx = new Arduino_ILI9341(bus, GFX_NOT_DEFINED /* RST */, 3 /* rotation */); 404 // Arduino_ST7789 *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 3 /* rotation */, true /* IPS */); 405 406 /* LILYGO T-Watch */ 407 #elif defined(ARDUINO_T) || defined(ARDUINO_TWATCH_BASE) || defined(ARDUINO_TWATCH_2020_V1) || defined(ARDUINO_TWATCH_2020_V2) 408 #define GFX_BL 12 409 Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 5 /* CS */, 18 /* SCK */, 19 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 410 Arduino_GFX *gfx = new Arduino_ST7789(bus, GFX_NOT_DEFINED /* RST */, 0 /* rotation */, true /* IPS */, 240 /* width */, 240 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 80 /* row offset 2 */); 411 412 /* Waveshare RP2040-LCD-1.28 */ 413 #elif defined(ARDUINO_WAVESHARE_RP2040_LCD_1_28) 414 #define GFX_BL 25 415 Arduino_DataBus *bus = new Arduino_RPiPicoSPI(8 /* DC */, 9 /* CS */, 10 /* SCK */, 11 /* MOSI */, 12 /* MISO */, spi1 /* spi */); 416 Arduino_GFX *gfx = new Arduino_GC9A01(bus, 12 /* RST */, 0 /* rotation */, true /* IPS */); 417 418 #else /* not selected specific hardware */ 419 420 #if defined(__IMXRT1052__) || defined(__IMXRT1062__) 421 // PJRC Teensy 4.x 422 #define TFT_CS 39 // GFX_NOT_DEFINED for display without CS pin 423 #define TFT_DC 41 424 #define TFT_RST 40 425 #define GFX_BL 22 426 #elif defined(ARDUINO_BLACKPILL_F411CE) 427 #define TFT_CS 4 // GFX_NOT_DEFINED for display without CS pin 428 #define TFT_DC 3 429 #define TFT_RST 2 430 #define GFX_BL 1 431 #elif defined(TARGET_RP2040) 432 #define TFT_CS 17 // GFX_NOT_DEFINED for display without CS pin 433 #define TFT_DC 27 434 #define TFT_RST 26 435 #define GFX_BL 28 436 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32) 437 #define TFT_CS 5 // GFX_NOT_DEFINED for display without CS pin 438 #define TFT_DC 27 // GFX_NOT_DEFINED for display without DC pin (9-bit SPI) 439 #define TFT_RST 33 440 #define GFX_BL 22 441 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S2) 442 #define TFT_CS 34 // GFX_NOT_DEFINED for display without CS pin 443 #define TFT_DC 38 444 #define TFT_RST 33 445 #define GFX_BL 21 446 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3) 447 #define TFT_CS 40 // GFX_NOT_DEFINED for display without CS pin 448 #define TFT_DC 41 449 #define TFT_RST 42 450 #define GFX_BL 48 451 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32C3) 452 #define TFT_CS 7 // GFX_NOT_DEFINED for display without CS pin 453 #define TFT_DC 2 454 #define TFT_RST 1 455 #define GFX_BL 3 456 #elif defined(ESP8266) 457 #define TFT_CS 15 // GFX_NOT_DEFINED for display without CS pin 458 #define TFT_DC 4 459 #define TFT_RST 2 460 #define GFX_BL 5 461 #elif defined(RTL8722DM) 462 #if defined(BOARD_RTL8720DN_BW16) 463 #define TFT_CS 9 464 #define TFT_DC 8 465 #define TFT_RST 6 466 #define GFX_BL 3 467 #elif defined(BOARD_RTL8722DM) 468 #define TFT_CS 18 469 #define TFT_DC 17 470 #define TFT_RST 22 471 #define GFX_BL 23 472 #elif defined(BOARD_RTL8722DM_MINI) 473 #define TFT_CS 12 474 #define TFT_DC 14 475 #define TFT_RST 15 476 #define GFX_BL 13 477 #else // old version 478 #define TFT_CS 18 // GFX_NOT_DEFINED for display without CS pin 479 #define TFT_DC 17 480 #define TFT_RST 2 481 #define GFX_BL 23 482 #endif 483 #elif defined(SEEED_XIAO_M0) 484 #define TFT_CS 3 // GFX_NOT_DEFINED for display without CS pin 485 #define TFT_DC 2 486 #define TFT_RST 1 487 #define GFX_BL 0 488 #else 489 #define TFT_CS 9 // GFX_NOT_DEFINED for display without CS pin 490 #define TFT_DC 8 491 #define TFT_RST 7 492 #define GFX_BL 6 493 #endif 494 495 /* 496 * Step 1: Initize one databus for your display 497 */ 498 499 // General software SPI 500 // Arduino_DataBus *bus = new Arduino_SWSPI(TFT_DC, TFT_CS, 18 /* SCK */, 23 /* MOSI */, GFX_NOT_DEFINED /* MISO */); 501 502 // hardware SPI 503 #if defined(ARDUINO_ARCH_NRF52840) 504 // Arduino_DataBus *bus = new Arduino_mbedSPI(TFT_DC, TFT_CS); 505 Arduino_DataBus *bus = new Arduino_NRFXSPI(TFT_DC, TFT_CS, 13 /* SCK */, 11 /* MOSI */, 12 /* MISO */); 506 #elif defined(TARGET_RP2040) 507 Arduino_DataBus *bus = new Arduino_RPiPicoSPI(TFT_DC /* DC */, TFT_CS /* CS */, 18 /* SCK */, 19 /* MOSI */, 16 /* MISO */, spi0 /* spi */); 508 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32) 509 Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, 18 /* SCK */, 23 /* MOSI */, GFX_NOT_DEFINED /* MISO */, VSPI /* spi_num */); 510 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3) 511 Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, 36 /* SCK */, 35 /* MOSI */, GFX_NOT_DEFINED /* MISO */, HSPI /* spi_num */); 512 #elif defined(ESP32) && (CONFIG_IDF_TARGET_ESP32C3) 513 Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, 4 /* SCK */, 6 /* MOSI */, GFX_NOT_DEFINED /* MISO */, FSPI /* spi_num */); 514 #elif defined(ESP8266) 515 Arduino_DataBus *bus = new Arduino_ESP8266SPI(TFT_DC, TFT_CS); 516 #else 517 // General hardware SPI 518 Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS); 519 #endif 520 521 // General Software parallel 8-bit 522 // Arduino_DataBus *bus = new Arduino_SWPAR8(TFT_DC, TFT_CS, 25 /* WR */, 32 /* RD */, 23 /* D0 */, 19 /* D1 */, 18 /* D2 */, 26 /* D3 */, 21 /* D4 */, 4 /* D5 */, 0 /* D6 */, 2 /* D7 */); 523 524 // General Software parallel 16-bit 525 // Arduino_DataBus *bus = new Arduino_SWPAR16(32 /* DC */, GFX_NOT_DEFINED /* CS */, 21 /* WR */, GFX_NOT_DEFINED /* RD */, 19 /* D0 */, 23 /* D1 */, 18 /* D2 */, 5 /* D3 */, 17 /* D4 */, 16 /* D5 */, 25 /* D6 */, 26 /* D7 */, 27 /* D8 */, 14 /* D9 */, 12 /* D10 */, 13 /* D11 */, 15 /* D12 */, 2 /* D13 */, 0 /* D14 */, 4 /* D15 */); 526 527 // AVR parallel 8-bit 528 // Arduino Pro Micro port 2(PB): 17, 15, 16, 14, 8, 9, 10, 11 529 // Arduino_DataBus *bus = new Arduino_AVRPAR8(4 /* DC */, 5 /* CS */, 18 /* WR */, 19 /* RD */, 2 /* PORT */); 530 531 // AVR parallel 16-bit 532 // Arduino MEGA 2560 533 // port 3(PC): 37, 36, 35, 34, 33, 32, 31, 30 534 // port 1(PA): 22, 23, 24, 25, 26, 27, 28, 29 535 // Arduino_DataBus *bus = new Arduino_AVRPAR16(38 /* DC */, 40 /* CS */, 39 /* WR */, 43 /* RD */, 3 /* PORT LOW */, 1 /* PORT HIGH */); 536 537 // ESP32 parallel 8-bit 538 // Arduino_DataBus *bus = new Arduino_ESP32PAR8(TFT_DC, TFT_CS, 25 /* WR */, 32 /* RD */, 23 /* D0 */, 19 /* D1 */, 18 /* D2 */, 26 /* D3 */, 21 /* D4 */, 4 /* D5 */, 0 /* D6 */, 2 /* D7 */); 539 540 // ESP32 parallel 16-bit 541 // Almost all GPIO 0-31 used up for 16-bit and WR, disable PSRAM to gain 16 and 17 but still no GPIOs remain for CS and RD. 542 // CS connect to GND (enable); RD connect to Vcc (disable). 543 // Arduino_DataBus *bus = new Arduino_ESP32PAR16( 544 // 32 /* DC */, GFX_NOT_DEFINED /* CS */, 21 /* WR */, GFX_NOT_DEFINED /* RD */, 545 // 19 /* D0 */, 23 /* D1 */, 18 /* D2 */, 5 /* D3 */, 17 /* D4 */, 16 /* D5 */, 25 /* D6 */, 26 /* D7 */, 546 // 27 /* D8 */, 14 /* D9 */, 12 /* D10 */, 13 /* D11 */, 15 /* D12 */, 2 /* D13 */, 0 /* D14 */, 4 /* D15 */); 547 548 // ESP32S2 parallel 8-bit 549 // Display D0-D7 connect to GPIO 0-7 550 // Arduino_DataBus *bus = new Arduino_ESP32S2PAR8(TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */); 551 552 // ESP32S2 parallel 16-bit 553 // Display D0-D15 connect to GPIO 0-15 554 // Arduino_DataBus *bus = new Arduino_ESP32S2PAR16(TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */); 555 556 // ESP32S3 i80 LCD parallel 8-bit 557 // Arduino_DataBus *bus = new Arduino_ESP32LCD8( 558 // TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */, 559 // 0 /* D0 */, 1 /* D1 */, 2 /* D2 */, 3 /* D3 */, 4 /* D4 */, 5 /* D5 */, 6 /* D6 */, 7 /* D7 */); 560 561 // ESP32S3 i80 LCD parallel 16-bit 562 // Arduino_DataBus *bus = new Arduino_ESP32LCD16( 563 // TFT_DC, TFT_CS, 16 /* WR */, 17 /* RD */, 564 // 0 /* D0 */, 1 /* D1 */, 2 /* D2 */, 3 /* D3 */, 4 /* D4 */, 5 /* D5 */, 6 /* D6 */, 7 /* D7 */, 565 // 8 /* D8 */, 9 /* D9 */, 10 /* D10 */, 11 /* D11 */, 12 /* D12 */, 13 /* D13 */, 14 /* D14 */, 15 /* D15 */); 566 567 // Raspberry Pi Pico parallel 8-bit 568 // Display D0-D7 connect to GPIO 0-7 569 // Arduino_DataBus *bus = new Arduino_RPiPicoPAR8(TFT_DC, TFT_CS, 18 /* WR */, 19 /* RD */); 570 571 // Raspberry Pi Pico parallel 16-bit 572 // Display D0-D15 connect to GPIO 0-15 573 // Arduino_DataBus *bus = new Arduino_RPiPicoPAR16(TFT_DC, TFT_CS, 18 /* WR */, 19 /* RD */); 574 575 // RTL8722 parallel 8-bit 576 // Reduce GPIO usage: CS connect to GND (enable); RD connect to Vcc (disable); No Backlight pins. 577 // Arduino_DataBus *bus = new Arduino_RTLPAR8(0 /* DC */, GFX_NOT_DEFINED /* CS */, 1 /* WR */, GFX_NOT_DEFINED /* RD */, 18 /* D0 */, 22 /* D1 */, 17 /* D2 */, 20 /* D3 */, 19 /* D4 */, 23 /* D5 */, 21 /* D6 */, 16 /* D7 */); 578 579 /* 580 * Step 2: Initize one driver for your display 581 */ 582 583 /*************************************** 584 * Start of Canvas (framebuffer) 585 **************************************/ 586 // 16-bit color Canvas (240x320 resolution only works for ESP32 with PSRAM) 587 // Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 588 // Arduino_GFX *gfx = new Arduino_Canvas(240 /* width */, 320 /* height */, output_display); 589 590 // Indexed color Canvas, mask_level: 0-2, larger mask level mean less color variation but can have faster index mapping 591 // Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 592 // Arduino_GFX *gfx = new Arduino_Canvas_Indexed(240 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */, MAXMASKLEVEL /* mask_level */); 593 594 // 3-bit color Canvas, R1G1B1, 8 colors 595 // Arduino_G *output_display = new Arduino_ILI9488_3bit(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */); 596 // Arduino_GFX *gfx = new Arduino_Canvas_3bit(480 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */); 597 598 // Mono color Canvas 599 // Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 600 // Arduino_GFX *gfx = new Arduino_Canvas_Mono(240 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */); 601 /*************************************** 602 * End of Canvas (framebuffer) 603 **************************************/ 604 605 // GC9A01 IPS LCD 240x240 606 // Arduino_GFX *gfx = new Arduino_GC9A01(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 607 608 // GC9106 IPS LCD 80x160 609 // Arduino_GFX *gfx = new Arduino_GC9106(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 610 611 // GC9107 IPS LCD 128x128 612 // Arduino_GFX *gfx = new Arduino_GC9107(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 613 614 // HX8347C IPS LCD 240x320 615 // Arduino_GFX *gfx = new Arduino_HX8347C(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 616 617 // HX8347D IPS LCD 240x320 618 // Arduino_GFX *gfx = new Arduino_HX8347D(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 619 620 // HX8352C IPS LCD 240x400 621 // Arduino_GFX *gfx = new Arduino_HX8352C(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 622 623 // HX8357A IPS LCD 320x480 (currently only portrait works, i.e. rotation 0 and 2) 624 // Arduino_GFX *gfx = new Arduino_HX8357A(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 625 626 // HX8357B IPS LCD 320x480 627 // Arduino_GFX *gfx = new Arduino_HX8357B(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 628 629 // HX8369A LCD 480x800 630 // Arduino_GFX *gfx = new Arduino_HX8369A(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 480, 800, 0, 7, 0, 57); 631 632 // ILI9225 LCD 176x220 633 // Arduino_GFX *gfx = new Arduino_ILI9225(bus, TFT_RST); 634 635 // ILI9341 LCD 240x320 636 Arduino_GFX *gfx = new Arduino_ILI9341(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 637 638 // ILI9342 LCD 320x240 639 // Arduino_GFX *gfx = new Arduino_ILI9342(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 640 641 // ILI9481 parallel 16-bit LCD 320x480 642 // Arduino_GFX *gfx = new Arduino_ILI9481(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 643 644 // ILI9481 SPI LCD 320x480 645 // Arduino_GFX *gfx = new Arduino_ILI9481_18bit(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 646 647 // ILI9486 parallel 16-bit LCD 320x480 648 // Arduino_GFX *gfx = new Arduino_ILI9486(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 649 650 // ILI9486 SPI LCD 320x480 651 // Arduino_GFX *gfx = new Arduino_ILI9486_18bit(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 652 653 // ILI9488 parallel 16-bit LCD 320x480 654 // Arduino_GFX *gfx = new Arduino_ILI9488(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 655 656 // ILI9488 SPI LCD 320x480 657 // Arduino_GFX *gfx = new Arduino_ILI9488_18bit(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 658 659 // ILI9806 LCD 480x854 660 // Arduino_GFX *gfx = new Arduino_ILI9806(bus, TFT_RST, 0 /* rotation */, false /* IPS */); 661 662 // JBT6K71 LCD 240x320 663 // Arduino_GFX *gfx = new Arduino_JBT6K71(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 240, 320, 0, 0, 16, 0); 664 665 // NT35310 LCD 320x480 666 // Arduino_GFX *gfx = new Arduino_NT35310(bus, TFT_RST, 0 /* rotation */); 667 668 // NT35510 LCD 480x800 669 // Arduino_GFX *gfx = new Arduino_NT35510(bus, TFT_RST, 0 /* rotation */); 670 671 // NT39125 LCD 240x376 672 // Arduino_GFX *gfx = new Arduino_NT39125(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 240, 376, 0, 0, 0, 56); 673 674 // NV3041A IPS LCD 675 // Arduino_GFX *gfx = new Arduino_NV3041A(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 676 677 // OTM8009A LCD 480x800 678 // Arduino_GFX *gfx = new Arduino_OTM8009A(bus, TFT_RST, 0 /* rotation */); 679 680 // R61529 IPS LCD 320x480 681 // Arduino_GFX *gfx = new Arduino_R61529(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 682 683 // SEPS525 OLED 160x128 684 // Arduino_GFX *gfx = new Arduino_SEPS525(bus, TFT_RST, 0 /* rotation */); 685 686 // SSD1283A OLED 130x130 687 // Arduino_GFX *gfx = new Arduino_SSD1283A(bus, TFT_RST, 0 /* rotation */); 688 689 // SSD1331 OLED 96x64 690 // Arduino_GFX *gfx = new Arduino_SSD1331(bus, TFT_RST, 0 /* rotation */); 691 692 // SSD1351 OLED 128x128 693 // Arduino_GFX *gfx = new Arduino_SSD1351(bus, TFT_RST, 0 /* rotation */); 694 695 // ST7735 LCD 696 // 1.8" REDTAB 128x160 697 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */); 698 // 1.8" BLACKTAB 128x160 699 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 2 /* col offset 1 */, 1 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */, false /* BGR */); 700 // 1.8" GREENTAB A 128x160 701 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 2 /* col offset 1 */, 1 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */); 702 // 1.8" GREENTAB B 128x160 703 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 2 /* col offset 1 */, 3 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */); 704 // 1.8" Wide angle LCD 128x160 705 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 160 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 0 /* row offset 2 */, false /* BGR */); 706 // 1.5" GREENTAB B 128x128 707 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 128 /* height */, 2 /* col offset 1 */, 3 /* row offset 1 */, 2 /* col offset 2 */, 1 /* row offset 2 */); 708 // 1.5" GREENTAB C 128x128 709 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, false /* IPS */, 128 /* width */, 128 /* height */, 0 /* col offset 1 */, 32 /* row offset 1 */); 710 // 0.96" IPS LCD 80x160 711 // Arduino_GFX *gfx = new Arduino_ST7735(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 80 /* width */, 160 /* height */, 26 /* col offset 1 */, 1 /* row offset 1 */, 26 /* col offset 2 */, 1 /* row offset 2 */); 712 713 // ST7789 LCD 714 // 2.4" LCD 240x320 715 // Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */); 716 // 2.4" IPS LCD 240x320 717 // Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 718 // 1.69" IPS round corner LCD 240x280 719 // Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 240 /* width */, 280 /* height */, 0 /* col offset 1 */, 20 /* row offset 1 */, 0 /* col offset 2 */, 20 /* row offset 2 */); 720 // 1.3"/1.5" square IPS LCD 240x240 721 // Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 240 /* width */, 240 /* height */, 0 /* col offset 1 */, 0 /* row offset 1 */, 0 /* col offset 2 */, 80 /* row offset 2 */); 722 // 1.14" IPS LCD 135x240 723 // Arduino_GFX *gfx = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */, 135 /* width */, 240 /* height */, 52 /* col offset 1 */, 40 /* row offset 1 */, 53 /* col offset 2 */, 40 /* row offset 2 */); 724 725 // ST7796 LCD 726 // 4" LCD 320x480 727 // Arduino_GFX *gfx = new Arduino_ST7796(bus, TFT_RST, 0 /* rotation */); 728 // 4" IPS LCD 320x480 729 // Arduino_GFX *gfx = new Arduino_ST7796(bus, TFT_RST, 0 /* rotation */, true /* IPS */); 730 731 #endif /* not selected specific hardware */ 732 /******************************************************************************* 733 * End of Arduino_GFX setting 734 ******************************************************************************/ 735 736 int32_t w, h, n, n1, cx, cy, cx1, cy1, cn, cn1; 737 uint8_t tsa, tsb, tsc, ds; 738 739 void setup() 740 { 741 Serial.begin(115200); 742 // Serial.setDebugOutput(true); 743 // while(!Serial); 744 Serial.println("Arduino_GFX library Test!"); 745 746 #ifdef GFX_EXTRA_PRE_INIT 747 GFX_EXTRA_PRE_INIT(); 748 #endif 749 750 gfx->begin(); 751 // gfx->begin(80000000); /* specify data bus speed */ 752 753 w = gfx->width(); 754 h = gfx->height(); 755 n = min(w, h); 756 n1 = n - 1; 757 cx = w / 2; 758 cy = h / 2; 759 cx1 = cx - 1; 760 cy1 = cy - 1; 761 cn = min(cx1, cy1); 762 cn1 = cn - 1; 763 tsa = ((w <= 176) || (h <= 160)) ? 1 : (((w <= 240) || (h <= 240)) ? 2 : 3); // text size A 764 tsb = ((w <= 272) || (h <= 220)) ? 1 : 2; // text size B 765 tsc = ((w <= 220) || (h <= 220)) ? 1 : 2; // text size C 766 ds = (w <= 160) ? 9 : 12; // digit size 767 768 #ifdef GFX_BL 769 pinMode(GFX_BL, OUTPUT); 770 digitalWrite(GFX_BL, HIGH); 771 #endif 772 } 773 774 static inline uint32_t micros_start() __attribute__((always_inline)); 775 static inline uint32_t micros_start() 776 { 777 uint8_t oms = millis(); 778 while ((uint8_t)millis() == oms) 779 ; 780 return micros(); 781 } 782 783 void loop(void) 784 { 785 Serial.println(F("Benchmark\tmicro-secs")); 786 787 int32_t usecFillScreen = testFillScreen(); 788 serialOut(F("Screen fill\t"), usecFillScreen, 100, true); 789 790 int32_t usecText = testText(); 791 serialOut(F("Text\t"), usecText, 3000, true); 792 793 int32_t usecPixels = testPixels(); 794 serialOut(F("Pixels\t"), usecPixels, 100, true); 795 796 int32_t usecLines = testLines(); 797 serialOut(F("Lines\t"), usecLines, 100, true); 798 799 int32_t usecFastLines = testFastLines(); 800 serialOut(F("Horiz/Vert Lines\t"), usecFastLines, 100, true); 801 802 int32_t usecFilledRects = testFilledRects(); 803 serialOut(F("Rectangles (filled)\t"), usecFilledRects, 100, false); 804 805 int32_t usecRects = testRects(); 806 serialOut(F("Rectangles (outline)\t"), usecRects, 100, true); 807 808 int32_t usecFilledTrangles = testFilledTriangles(); 809 serialOut(F("Triangles (filled)\t"), usecFilledTrangles, 100, false); 810 811 int32_t usecTriangles = testTriangles(); 812 serialOut(F("Triangles (outline)\t"), usecTriangles, 100, true); 813 814 int32_t usecFilledCircles = testFilledCircles(10); 815 serialOut(F("Circles (filled)\t"), usecFilledCircles, 100, false); 816 817 int32_t usecCircles = testCircles(10); 818 serialOut(F("Circles (outline)\t"), usecCircles, 100, true); 819 820 int32_t usecFilledArcs = testFillArcs(); 821 serialOut(F("Arcs (filled)\t"), usecFilledArcs, 100, false); 822 823 int32_t usecArcs = testArcs(); 824 serialOut(F("Arcs (outline)\t"), usecArcs, 100, true); 825 826 int32_t usecFilledRoundRects = testFilledRoundRects(); 827 serialOut(F("Rounded rects (filled)\t"), usecFilledRoundRects, 100, false); 828 829 int32_t usecRoundRects = testRoundRects(); 830 serialOut(F("Rounded rects (outline)\t"), usecRoundRects, 100, true); 831 832 #ifdef CANVAS 833 uint32_t start = micros_start(); 834 gfx->flush(); 835 int32_t usecFlush = micros() - start; 836 serialOut(F("flush (Canvas only)\t"), usecFlush, 0, false); 837 #endif 838 839 Serial.println(F("Done!")); 840 841 uint16_t c = 4; 842 int8_t d = 1; 843 for (int32_t i = 0; i < h; i++) 844 { 845 gfx->drawFastHLine(0, i, w, c); 846 c += d; 847 if (c <= 4 || c >= 11) 848 { 849 d = -d; 850 } 851 } 852 853 gfx->setCursor(0, 0); 854 855 gfx->setTextSize(tsa); 856 gfx->setTextColor(MAGENTA); 857 gfx->println(F("Arduino GFX PDQ")); 858 859 if (h > w) 860 { 861 gfx->setTextSize(tsb); 862 gfx->setTextColor(GREEN); 863 gfx->print(F("\nBenchmark ")); 864 gfx->setTextSize(tsc); 865 if (ds == 12) 866 { 867 gfx->print(F(" ")); 868 } 869 gfx->println(F("micro-secs")); 870 } 871 872 printnice(F("Screen fill "), usecFillScreen); 873 printnice(F("Text "), usecText); 874 printnice(F("Pixels "), usecPixels); 875 printnice(F("Lines "), usecLines); 876 printnice(F("H/V Lines "), usecFastLines); 877 printnice(F("Rectangles F"), usecFilledRects); 878 printnice(F("Rectangles "), usecRects); 879 printnice(F("Triangles F "), usecFilledTrangles); 880 printnice(F("Triangles "), usecTriangles); 881 printnice(F("Circles F "), usecFilledCircles); 882 printnice(F("Circles "), usecCircles); 883 printnice(F("Arcs F "), usecFilledArcs); 884 printnice(F("Arcs "), usecArcs); 885 printnice(F("RoundRects F"), usecFilledRoundRects); 886 printnice(F("RoundRects "), usecRoundRects); 887 888 if ((h > w) || (h > 240)) 889 { 890 gfx->setTextSize(tsc); 891 gfx->setTextColor(GREEN); 892 gfx->print(F("\nBenchmark Complete!")); 893 } 894 895 #ifdef CANVAS 896 gfx->flush(); 897 #endif 898 899 delay(60 * 1000L); 900 } 901 902 #ifdef ESP32 903 void serialOut(const char *item, int32_t v, uint32_t d, bool clear) 904 #else 905 void serialOut(const __FlashStringHelper *item, int32_t v, uint32_t d, bool clear) 906 #endif 907 { 908 #ifdef CANVAS 909 gfx->flush(); 910 #endif 911 Serial.print(item); 912 if (v < 0) 913 { 914 Serial.println(F("N/A")); 915 } 916 else 917 { 918 Serial.println(v); 919 } 920 delay(d); 921 if (clear) 922 { 923 gfx->fillScreen(BLACK); 924 } 925 } 926 927 #ifdef ESP32 928 void printnice(const char *item, long int v) 929 #else 930 void printnice(const __FlashStringHelper *item, long int v) 931 #endif 932 { 933 gfx->setTextSize(tsb); 934 gfx->setTextColor(CYAN); 935 gfx->print(item); 936 937 gfx->setTextSize(tsc); 938 gfx->setTextColor(YELLOW); 939 if (v < 0) 940 { 941 gfx->println(F(" N / A")); 942 } 943 else 944 { 945 char str[32] = {0}; 946 #ifdef RTL8722DM 947 sprintf(str, "%d", (int)v); 948 #else 949 sprintf(str, "%ld", v); 950 #endif 951 for (char *p = (str + strlen(str)) - 3; p > str; p -= 3) 952 { 953 memmove(p + 1, p, strlen(p) + 1); 954 *p = ','; 955 } 956 while (strlen(str) < ds) 957 { 958 memmove(str + 1, str, strlen(str) + 1); 959 *str = ' '; 960 } 961 gfx->println(str); 962 } 963 } 964 965 int32_t testFillScreen() 966 { 967 uint32_t start = micros_start(); 968 // Shortened this tedious test! 969 gfx->fillScreen(WHITE); 970 gfx->fillScreen(RED); 971 gfx->fillScreen(GREEN); 972 gfx->fillScreen(BLUE); 973 gfx->fillScreen(BLACK); 974 975 return micros() - start; 976 } 977 978 int32_t testText() 979 { 980 uint32_t start = micros_start(); 981 gfx->setCursor(0, 0); 982 983 gfx->setTextSize(1); 984 gfx->setTextColor(WHITE, BLACK); 985 gfx->println(F("Hello World!")); 986 987 gfx->setTextSize(2); 988 gfx->setTextColor(gfx->color565(0xff, 0x00, 0x00)); 989 gfx->print(F("RED ")); 990 gfx->setTextColor(gfx->color565(0x00, 0xff, 0x00)); 991 gfx->print(F("GREEN ")); 992 gfx->setTextColor(gfx->color565(0x00, 0x00, 0xff)); 993 gfx->println(F("BLUE")); 994 995 gfx->setTextSize(tsa); 996 gfx->setTextColor(YELLOW); 997 gfx->println(1234.56); 998 999 gfx->setTextColor(WHITE); 1000 gfx->println((w > 128) ? 0xDEADBEEF : 0xDEADBEE, HEX); 1001 1002 gfx->setTextColor(CYAN, WHITE); 1003 gfx->println(F("Groop,")); 1004 1005 gfx->setTextSize(tsc); 1006 gfx->setTextColor(MAGENTA, WHITE); 1007 gfx->println(F("I implore thee,")); 1008 1009 gfx->setTextSize(1); 1010 gfx->setTextColor(NAVY, WHITE); 1011 gfx->println(F("my foonting turlingdromes.")); 1012 1013 gfx->setTextColor(DARKGREEN, WHITE); 1014 gfx->println(F("And hooptiously drangle me")); 1015 1016 gfx->setTextColor(DARKCYAN, WHITE); 1017 gfx->println(F("with crinkly bindlewurdles,")); 1018 1019 gfx->setTextColor(MAROON, WHITE); 1020 gfx->println(F("Or I will rend thee")); 1021 1022 gfx->setTextColor(PURPLE, WHITE); 1023 gfx->println(F("in the gobberwartsb")); 1024 1025 gfx->setTextColor(OLIVE, WHITE); 1026 gfx->println(F("with my blurglecruncheon,")); 1027 1028 gfx->setTextColor(DARKGREY, WHITE); 1029 gfx->println(F("see if I don't!")); 1030 1031 gfx->setTextSize(2); 1032 gfx->setTextColor(RED); 1033 gfx->println(F("Size 2")); 1034 1035 gfx->setTextSize(3); 1036 gfx->setTextColor(ORANGE); 1037 gfx->println(F("Size 3")); 1038 1039 gfx->setTextSize(4); 1040 gfx->setTextColor(YELLOW); 1041 gfx->println(F("Size 4")); 1042 1043 gfx->setTextSize(5); 1044 gfx->setTextColor(GREENYELLOW); 1045 gfx->println(F("Size 5")); 1046 1047 gfx->setTextSize(6); 1048 gfx->setTextColor(GREEN); 1049 gfx->println(F("Size 6")); 1050 1051 gfx->setTextSize(7); 1052 gfx->setTextColor(BLUE); 1053 gfx->println(F("Size 7")); 1054 1055 gfx->setTextSize(8); 1056 gfx->setTextColor(PURPLE); 1057 gfx->println(F("Size 8")); 1058 1059 gfx->setTextSize(9); 1060 gfx->setTextColor(PINK); 1061 gfx->println(F("Size 9")); 1062 1063 return micros() - start; 1064 } 1065 1066 int32_t testPixels() 1067 { 1068 uint32_t start = micros_start(); 1069 1070 for (int16_t y = 0; y < h; y++) 1071 { 1072 for (int16_t x = 0; x < w; x++) 1073 { 1074 gfx->drawPixel(x, y, gfx->color565(x << 3, y << 3, x * y)); 1075 } 1076 #ifdef ESP8266 1077 yield(); // avoid long run triggered ESP8266 WDT restart 1078 #endif 1079 } 1080 1081 return micros() - start; 1082 } 1083 1084 int32_t testLines() 1085 { 1086 uint32_t start; 1087 int32_t x1, y1, x2, y2; 1088 1089 start = micros_start(); 1090 1091 x1 = y1 = 0; 1092 y2 = h - 1; 1093 for (x2 = 0; x2 < w; x2 += 6) 1094 { 1095 gfx->drawLine(x1, y1, x2, y2, BLUE); 1096 } 1097 #ifdef ESP8266 1098 yield(); // avoid long run triggered ESP8266 WDT restart 1099 #endif 1100 1101 x2 = w - 1; 1102 for (y2 = 0; y2 < h; y2 += 6) 1103 { 1104 gfx->drawLine(x1, y1, x2, y2, BLUE); 1105 } 1106 #ifdef ESP8266 1107 yield(); // avoid long run triggered ESP8266 WDT restart 1108 #endif 1109 1110 x1 = w - 1; 1111 y1 = 0; 1112 y2 = h - 1; 1113 for (x2 = 0; x2 < w; x2 += 6) 1114 { 1115 gfx->drawLine(x1, y1, x2, y2, BLUE); 1116 } 1117 #ifdef ESP8266 1118 yield(); // avoid long run triggered ESP8266 WDT restart 1119 #endif 1120 1121 x2 = 0; 1122 for (y2 = 0; y2 < h; y2 += 6) 1123 { 1124 gfx->drawLine(x1, y1, x2, y2, BLUE); 1125 } 1126 #ifdef ESP8266 1127 yield(); // avoid long run triggered ESP8266 WDT restart 1128 #endif 1129 1130 x1 = 0; 1131 y1 = h - 1; 1132 y2 = 0; 1133 for (x2 = 0; x2 < w; x2 += 6) 1134 { 1135 gfx->drawLine(x1, y1, x2, y2, BLUE); 1136 } 1137 #ifdef ESP8266 1138 yield(); // avoid long run triggered ESP8266 WDT restart 1139 #endif 1140 1141 x2 = w - 1; 1142 for (y2 = 0; y2 < h; y2 += 6) 1143 { 1144 gfx->drawLine(x1, y1, x2, y2, BLUE); 1145 } 1146 #ifdef ESP8266 1147 yield(); // avoid long run triggered ESP8266 WDT restart 1148 #endif 1149 1150 x1 = w - 1; 1151 y1 = h - 1; 1152 y2 = 0; 1153 for (x2 = 0; x2 < w; x2 += 6) 1154 { 1155 gfx->drawLine(x1, y1, x2, y2, BLUE); 1156 } 1157 #ifdef ESP8266 1158 yield(); // avoid long run triggered ESP8266 WDT restart 1159 #endif 1160 1161 x2 = 0; 1162 for (y2 = 0; y2 < h; y2 += 6) 1163 { 1164 gfx->drawLine(x1, y1, x2, y2, BLUE); 1165 } 1166 #ifdef ESP8266 1167 yield(); // avoid long run triggered ESP8266 WDT restart 1168 #endif 1169 1170 return micros() - start; 1171 } 1172 1173 int32_t testFastLines() 1174 { 1175 uint32_t start; 1176 int32_t x, y; 1177 1178 start = micros_start(); 1179 1180 for (y = 0; y < h; y += 5) 1181 { 1182 gfx->drawFastHLine(0, y, w, RED); 1183 } 1184 for (x = 0; x < w; x += 5) 1185 { 1186 gfx->drawFastVLine(x, 0, h, BLUE); 1187 } 1188 1189 return micros() - start; 1190 } 1191 1192 int32_t testFilledRects() 1193 { 1194 uint32_t start; 1195 int32_t i, i2; 1196 1197 start = micros_start(); 1198 1199 for (i = n; i > 0; i -= 6) 1200 { 1201 i2 = i / 2; 1202 1203 gfx->fillRect(cx - i2, cy - i2, i, i, gfx->color565(i, i, 0)); 1204 } 1205 1206 return micros() - start; 1207 } 1208 1209 int32_t testRects() 1210 { 1211 uint32_t start; 1212 int32_t i, i2; 1213 1214 start = micros_start(); 1215 for (i = 2; i < n; i += 6) 1216 { 1217 i2 = i / 2; 1218 gfx->drawRect(cx - i2, cy - i2, i, i, GREEN); 1219 } 1220 1221 return micros() - start; 1222 } 1223 1224 int32_t testFilledCircles(uint8_t radius) 1225 { 1226 uint32_t start; 1227 int32_t x, y, r2 = radius * 2; 1228 1229 start = micros_start(); 1230 1231 for (x = radius; x < w; x += r2) 1232 { 1233 for (y = radius; y < h; y += r2) 1234 { 1235 gfx->fillCircle(x, y, radius, MAGENTA); 1236 } 1237 } 1238 1239 return micros() - start; 1240 } 1241 1242 int32_t testCircles(uint8_t radius) 1243 { 1244 uint32_t start; 1245 int32_t x, y, r2 = radius * 2; 1246 int32_t w1 = w + radius; 1247 int32_t h1 = h + radius; 1248 1249 // Screen is not cleared for this one -- this is 1250 // intentional and does not affect the reported time. 1251 start = micros_start(); 1252 1253 for (x = 0; x < w1; x += r2) 1254 { 1255 for (y = 0; y < h1; y += r2) 1256 { 1257 gfx->drawCircle(x, y, radius, WHITE); 1258 } 1259 } 1260 1261 return micros() - start; 1262 } 1263 1264 int32_t testFillArcs() 1265 { 1266 int16_t i, r = 360 / cn; 1267 uint32_t start = micros_start(); 1268 1269 for (i = 6; i < cn; i += 6) 1270 { 1271 gfx->fillArc(cx1, cy1, i, i - 3, 0, i * r, RED); 1272 } 1273 1274 return micros() - start; 1275 } 1276 1277 int32_t testArcs() 1278 { 1279 int16_t i, r = 360 / cn; 1280 uint32_t start = micros_start(); 1281 1282 for (i = 6; i < cn; i += 6) 1283 { 1284 gfx->drawArc(cx1, cy1, i, i - 3, 0, i * r, WHITE); 1285 } 1286 1287 return micros() - start; 1288 } 1289 1290 int32_t testFilledTriangles() 1291 { 1292 uint32_t start; 1293 int32_t i; 1294 1295 start = micros_start(); 1296 1297 for (i = cn1; i > 10; i -= 5) 1298 { 1299 gfx->fillTriangle(cx1, cy1 - i, cx1 - i, cy1 + i, cx1 + i, cy1 + i, 1300 gfx->color565(0, i, i)); 1301 } 1302 1303 return micros() - start; 1304 } 1305 1306 int32_t testTriangles() 1307 { 1308 uint32_t start; 1309 int32_t i; 1310 1311 start = micros_start(); 1312 1313 for (i = 0; i < cn; i += 5) 1314 { 1315 gfx->drawTriangle( 1316 cx1, cy1 - i, // peak 1317 cx1 - i, cy1 + i, // bottom left 1318 cx1 + i, cy1 + i, // bottom right 1319 gfx->color565(0, 0, i)); 1320 } 1321 1322 return micros() - start; 1323 } 1324 1325 int32_t testFilledRoundRects() 1326 { 1327 uint32_t start; 1328 int32_t i, i2; 1329 1330 start = micros_start(); 1331 1332 for (i = n1; i > 20; i -= 6) 1333 { 1334 i2 = i / 2; 1335 gfx->fillRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(0, i, 0)); 1336 } 1337 1338 return micros() - start; 1339 } 1340 1341 int32_t testRoundRects() 1342 { 1343 uint32_t start; 1344 int32_t i, i2; 1345 1346 start = micros_start(); 1347 1348 for (i = 20; i < n1; i += 6) 1349 { 1350 i2 = i / 2; 1351 gfx->drawRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(i, 0, 0)); 1352 } 1353 1354 return micros() - start; 1355 } 1356 1357 /*************************************************** 1358 Original sketch text: 1359 1360 This is an example sketch for the Adafruit 2.2" SPI display. 1361 This library works with the Adafruit 2.2" TFT Breakout w/SD card 1362 ----> http://www.adafruit.com/products/1480 1363 1364 Check out the links above for our tutorials and wiring diagrams 1365 These displays use SPI to communicate, 4 or 5 pins are required to 1366 interface (RST is optional) 1367 Adafruit invests time and resources providing this open source code, 1368 please support Adafruit and open-source hardware by purchasing 1369 products from Adafruit! 1370 1371 Written by Limor Fried/Ladyada for Adafruit Industries. 1372 MIT license, all text above must be included in any redistribution 1373 ****************************************************/