Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32 CYD: fillScreen "deletes" only 1 of 2 drawRoundRect areas #3425

Closed
Ozy3537 opened this issue Jul 31, 2024 · 1 comment
Closed

esp32 CYD: fillScreen "deletes" only 1 of 2 drawRoundRect areas #3425

Ozy3537 opened this issue Jul 31, 2024 · 1 comment

Comments

@Ozy3537
Copy link

Ozy3537 commented Jul 31, 2024

Just receives a CYD (Cheap Yellow Display) and started with some first code for the new hardware and here I am ;)

My very simple code does

  • clear screen = fillScreen(Grey)
  • draw box no.1 = drawRoundRect
  • draw box no.2 = drawRoundRect
  • clear screen = fillScreen(Black)
    The screen should now be one black area,
    but the first roundrect stays visible (no change).
    The area around the first box gets also filled black.

Hardware:
esp32-2432S028 (v3?) CYD2USB (with 2 USB connectors, micro and type-c)

  • esp32 wroom
  • 2,8" TFT with ST7789 (afaik) - but I selected "#define ILI9341_2_DRIVER" in User_setup file
    no additional Hardware connected

IDE: PlatformIO
Libs: bodmer/TFT_eSPI@^2.5.43
paulstoffregen/XPT2046_Touchscreen

#include <Arduino.h>
#include <SPI.h>

//	DISPLAY
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
//	User_Setup.h:  
//	D:\Dokumente\PlatformIO\Projects\CYD_First_Test\.pio\libdeps\esp32-2432S028Rv3\TFT_eSPI\User_Setups\Setup900_esp32_2432S028Rv3.h

//	TOUCHSCREEN
#include <XPT2046_Touchscreen.h>
#define XPT2046_IRQ 36   // T_IRQ
#define XPT2046_MOSI 32  // T_DIN
#define XPT2046_MISO 39  // T_OUT
#define XPT2046_CLK 25   // T_CLK
#define XPT2046_CS 33    // T_CS
SPIClass touchscreenSPI = SPIClass(VSPI);
XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);

#define CFG_BOX_BORDER		TFT_DARKGREY
#define CFG_BOX_BG_COLOR	TFT_BLUE
#define CFG_BOX_TX_COLOR	TFT_WHITE

bool dspDrawXYaxis(bool clearBG=true)		
{
	uint32_t	colorBG 	= TFT_BLACK;
	uint32_t	colorXaxis	= TFT_DARKGREY;
	uint32_t	colorYaxis	= TFT_DARKGREY;

	//	distances to display bordes
	int16_t		leftSpace	= 20;
	int16_t		topSpace	= 20;
	int16_t		buttomSpace	= 15;
	int16_t		rightSpace	= 10;

	if (clearBG) tft.fillScreen(colorBG);

	//	draw y + x axis
	tft.drawLine(leftSpace, topSpace, leftSpace, buttomSpace, colorYaxis);
	tft.drawLine(leftSpace, buttomSpace, rightSpace, buttomSpace, colorYaxis);

}

void dspDrawBoxAir()
{
	uint16_t	boxX = 5; 
	uint16_t	boxY = 5;
	uint16_t	boxW = tft.width() - (2*boxX); 
	uint16_t	boxH = 200;
	
	tft.drawRoundRect(boxX,boxY,boxW,boxH,5,TFT_YELLOW);
	tft.fillRoundRect(boxX,boxY,boxW,boxH,5,TFT_CYAN);
}

void dspDrawBoxGround()
{
	uint16_t	boxX = 5; 
	uint16_t	boxY = 210;
	uint16_t	boxW = tft.width() - (2*boxX) ; 
	uint16_t	boxH = tft.height() - (boxY + boxX);
	
	tft.drawRoundRect(boxX,boxY,boxW,boxH,5,TFT_BLACK);
	tft.fillRoundRect(boxX,boxY,boxW,boxH,5,TFT_BROWN);
}

void dspDrawBG_CuerrentValues()
{
	dspDrawBoxAir();
	dspDrawBoxGround();
}

//
//	SETUP
//

void initDisplay()
{
	tft.init();

	//	***DEBUG
	//	check if TFT config was loaded
	if (TFT_SETUP_900) Serial.println("TFT-SETUP-900 was loaded");
	else Serial.println("TFT-SETUP-900 was NOT loaded");

	//	display rotation (0=portrait 1=landscape)
	tft.setRotation(0); 

	// Clear the screen before writing to it
	tft.fillScreen(TFT_LIGHTGREY);
	tft.setTextColor(TFT_WHITE, TFT_BLACK);

}

void setup() 
{
	//	serial monitor
	Serial.begin(115200);
	Serial.println("Hello World for ESP32-2432S028 v3 (CYD2USB)");
	
	initDisplay();
	
	//	screen design
	dspDrawBG_CuerrentValues();
	delay(3000);
	dspDrawXYaxis();
	
}

void loop() 
{


}
@Ozy3537 Ozy3537 closed this as completed Jul 31, 2024
@Ozy3537
Copy link
Author

Ozy3537 commented Jul 31, 2024

Sorry - No lib problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant