Skip to content

Commit

Permalink
Migrate CYD2USB to correct display type (#158)
Browse files Browse the repository at this point in the history
Turns out the CYD2USB uses a ST7789V, so fix the examples and config.
  • Loading branch information
TheNitek authored Apr 23, 2024
1 parent 55010e6 commit d55212c
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 65 deletions.
12 changes: 6 additions & 6 deletions DisplayConfig/CYD2USB/User_Setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

// Only define one driver, the other ones must be commented out
// #define ILI9341_DRIVER // Generic driver for common displays
#define ILI9341_2_DRIVER // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
// #define ILI9341_2_DRIVER // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
// #define ST7735_DRIVER // Define additional parameters below for this display
// #define ILI9163_DRIVER // Define additional parameters below for this display
// #define S6D02A1_DRIVER
Expand All @@ -52,7 +52,7 @@
// #define ILI9481_DRIVER
// #define ILI9486_DRIVER
// #define ILI9488_DRIVER // WARNING: Do not connect ILI9488 display SDO to MISO if other devices share the SPI bus (TFT SDO does NOT tristate when CS is high)
// #define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
#define ST7789_DRIVER // Full configuration option, define additional parameters below for this display
// #define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
// #define R61581_DRIVER
// #define RM68140_DRIVER
Expand Down Expand Up @@ -84,11 +84,11 @@
// #define TFT_WIDTH 80
// #define TFT_WIDTH 128
// #define TFT_WIDTH 172 // ST7789 172 x 320
#define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
// #define TFT_WIDTH 240 // ST7789 240 x 240 and 240 x 320
// #define TFT_HEIGHT 160
// #define TFT_HEIGHT 128
// #define TFT_HEIGHT 240 // ST7789 240 x 240
#define TFT_HEIGHT 320 // ST7789 240 x 320
// #define TFT_HEIGHT 320 // ST7789 240 x 320
// #define TFT_HEIGHT 240 // GC9A01 240 x 240

// For ST7735 ONLY, define the type of display, originally this was based on the
Expand All @@ -112,8 +112,8 @@
// If colours are inverted (white shows as black) then uncomment one of the next
// 2 lines try both options, one of the options should correct the inversion.

#define TFT_INVERSION_ON
// #define TFT_INVERSION_OFF
//#define TFT_INVERSION_ON
#define TFT_INVERSION_OFF

// ##################################################################################
//
Expand Down
1 change: 0 additions & 1 deletion Examples/Basics/1-HelloWorld/1-HelloWorld.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ TFT_eSPI tft = TFT_eSPI();
void setup() {
// Start the tft display and set it to black
tft.init();
//tft.invertDisplay(1); //If you have a CYD2USB - https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/cyd.md#my-cyd-has-two-usb-ports
tft.setRotation(1); //This is the display in landscape

// Clear the screen before writing to it
Expand Down
12 changes: 4 additions & 8 deletions Examples/Basics/1-HelloWorld/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ upload_speed = 921600
board_build.partitions=min_spiffs.csv
build_flags =
-DUSER_SETUP_LOADED
-DILI9341_2_DRIVER
-DUSE_HSPI_PORT
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_SCLK=14
Expand All @@ -26,11 +23,10 @@ build_flags =
-DTFT_RST=-1
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_BACKLIGHT_OFF=LOW
-DLOAD_GLCD
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DLOAD_GLCD
-DLOAD_FONT2
-DLOAD_FONT4
-DLOAD_FONT6
Expand All @@ -41,10 +37,10 @@ build_flags =
[env:cyd]
build_flags =
${env.build_flags}
-DTFT_INVERSION_OFF
-DILI9341_2_DRIVER

[env:cyd2usb]
build_flags =
${env.build_flags}
-DTFT_INVERSION_ON

-DST7789_DRIVER
-DTFT_INVERSION_OFF
12 changes: 4 additions & 8 deletions Examples/Basics/2-TouchTest/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ upload_speed = 921600
board_build.partitions=min_spiffs.csv
build_flags =
-DUSER_SETUP_LOADED
-DILI9341_2_DRIVER
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DUSE_HSPI_PORT
-DTFT_MISO=12
-DTFT_MOSI=13
Expand All @@ -27,11 +24,10 @@ build_flags =
-DTFT_RST=-1
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_BACKLIGHT_OFF=LOW
-DLOAD_GLCD
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DLOAD_GLCD
-DLOAD_FONT2
-DLOAD_FONT4
-DLOAD_FONT6
Expand All @@ -42,10 +38,10 @@ build_flags =
[env:cyd]
build_flags =
${env.build_flags}
-DTFT_INVERSION_OFF
-DILI9341_2_DRIVER

[env:cyd2usb]
build_flags =
${env.build_flags}
-DTFT_INVERSION_ON

-DST7789_DRIVER
-DTFT_INVERSION_OFF
15 changes: 6 additions & 9 deletions Examples/Basics/4-BacklightControlTest/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,34 @@ upload_speed = 921600
board_build.partitions=min_spiffs.csv
build_flags =
-DUSER_SETUP_LOADED
-DILI9341_2_DRIVER
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DUSE_HSPI_PORT
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_SCLK=14
-DTFT_CS=15
-DUSE_HSPI_PORT
-DTFT_DC=2
-DTFT_RST=-1
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_BACKLIGHT_OFF=LOW
-DLOAD_GLCD
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DLOAD_GLCD
-DLOAD_FONT2
-DLOAD_FONT4
-DLOAD_FONT6
-DLOAD_FONT7
-DLOAD_FONT8
-DLOAD_GFXFF
-DSMOOTH_FONT=0

[env:cyd]
build_flags =
${env.build_flags}
-DTFT_INVERSION_OFF
-DILI9341_2_DRIVER

[env:cyd2usb]
build_flags =
${env.build_flags}
-DTFT_INVERSION_ON

-DST7789_DRIVER
-DTFT_INVERSION_OFF
15 changes: 6 additions & 9 deletions Examples/Basics/5-LDRTest/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,34 @@ upload_speed = 921600
board_build.partitions=min_spiffs.csv
build_flags =
-DUSER_SETUP_LOADED
-DILI9341_2_DRIVER
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DUSE_HSPI_PORT
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_SCLK=14
-DTFT_CS=15
-DUSE_HSPI_PORT
-DTFT_DC=2
-DTFT_RST=-1
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_BACKLIGHT_OFF=LOW
-DLOAD_GLCD
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DLOAD_GLCD
-DLOAD_FONT2
-DLOAD_FONT4
-DLOAD_FONT6
-DLOAD_FONT7
-DLOAD_FONT8
-DLOAD_GFXFF
-DSMOOTH_FONT=0

[env:cyd]
build_flags =
${env.build_flags}
-DTFT_INVERSION_OFF
-DILI9341_2_DRIVER

[env:cyd2usb]
build_flags =
${env.build_flags}
-DTFT_INVERSION_ON

-DST7789_DRIVER
-DTFT_INVERSION_OFF
15 changes: 6 additions & 9 deletions Examples/Basics/7-HelloRadio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,34 @@ upload_speed = 921600
board_build.partitions=min_spiffs.csv
build_flags =
-DUSER_SETUP_LOADED
-DILI9341_2_DRIVER
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DUSE_HSPI_PORT
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_SCLK=14
-DTFT_CS=15
-DUSE_HSPI_PORT
-DTFT_DC=2
-DTFT_RST=-1
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_BACKLIGHT_OFF=LOW
-DLOAD_GLCD
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
-DLOAD_GLCD
-DLOAD_FONT2
-DLOAD_FONT4
-DLOAD_FONT6
-DLOAD_FONT7
-DLOAD_FONT8
-DLOAD_GFXFF
-DSMOOTH_FONT=0

[env:cyd]
build_flags =
${env.build_flags}
-DTFT_INVERSION_OFF
-DILI9341_2_DRIVER

[env:cyd2usb]
build_flags =
${env.build_flags}
-DTFT_INVERSION_ON

-DST7789_DRIVER
-DTFT_INVERSION_OFF
9 changes: 0 additions & 9 deletions Examples/Showcases/1-Slideshow/1-Slideshow.ino
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ void setup() {
tft.setTextSize(2);
tft.setSwapBytes(true);

// Fix image quality for CYD2USB
#ifdef TFT_INVERSION_ON
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
tft.writedata(2);
delay(120);
tft.writecommand(ILI9341_GAMMASET); //Gamma curve selected
tft.writedata(1);
#endif

ts.begin();

// Initialize SD card
Expand Down
9 changes: 3 additions & 6 deletions Examples/Showcases/1-Slideshow/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ board_build.partitions=min_spiffs.csv
board_build.arduino.upstream_packages = no
build_flags =
-DUSER_SETUP_LOADED
-DILI9341_2_DRIVER
-DTFT_WIDTH=240
-DTFT_HEIGHT=320
-DTFT_MISO=12
-DTFT_MOSI=13
-DTFT_SCLK=14
Expand All @@ -30,7 +27,6 @@ build_flags =
-DTFT_RST=-1
-DTFT_BL=21
-DTFT_BACKLIGHT_ON=HIGH
-DTFT_BACKLIGHT_OFF=LOW
-DSPI_FREQUENCY=55000000
-DSPI_READ_FREQUENCY=20000000
-DSPI_TOUCH_FREQUENCY=2500000
Expand All @@ -46,10 +42,11 @@ build_flags =
[env:cyd]
build_flags =
${env.build_flags}
-DTFT_INVERSION_OFF
-DILI9341_2_DRIVER

[env:cyd2usb]
build_flags =
${env.build_flags}
-DTFT_INVERSION_ON
-DST7789_DRIVER
-DTFT_INVERSION_OFF

0 comments on commit d55212c

Please sign in to comment.