Wt32 sc01 simple touch example - Detailed explanation with LovyanGFX
#Wt32sc01 #esp32project
Wt32Sc01_TwoButton-Simulation.ino
/*
Simple Touch Drawing sample for WT32-SC01
*/
#define LGFX_AUTODETECT // Autodetect board
#define LGFX_USE_V1 // set to use new version of library
#include <LovyanGFX.hpp> // main library
static LGFX lcd; // declare display variable
// Variables for touch x,y
static int32_t x, y;
static int32_t xBox = 20, yBox = 20, xWidth = 80, yHeight = 40, marginRight = 30;
bool btn1Clicked = true;
const int noOfButton = 2; //2
boolean btn1ClickColl[noOfButton];
void setup(void) {
Serial.begin(115200);
lcd.init();
// Setting display to landscape
if (lcd.width() < lcd.height()) lcd.setRotation(lcd.getRotation() ^ 1);
lcd.setCursor(0, 0);
lcd.printf("Ready to touch & draw!");
/*Button drawing logic*/
// for (int i = 1; i <= noOfButton; i++) {
btn1ClickColl[0] = true;
//drawRect ( x, y, w, h , color); // 矩形の外周
uint16_t green = 0x07E0;
lcd.fillRect(xBox, yBox, xWidth, yHeight, 0xF800);
int box1TextX = xBox + 10;
int box1TextY = yBox + 10;
lcd.setCursor(box1TextX, box1TextY);
lcd.println("RF1");
xBox = (xBox + xWidth) + marginRight;
btn1ClickColl[1] = true;
//drawRect ( x, y, w, h , color); // 矩形の外周
green = 0x07E0;
lcd.fillRect(xBox, yBox, xWidth, yHeight, 0xF800);
box1TextX = xBox + 10;
box1TextY = yBox + 10;
lcd.setCursor(box1TextX, box1TextY);
lcd.println("RF2");
xBox = (xBox + xWidth) + marginRight;
// }
}
void loop() {
xBox = 20;
if (lcd.getTouch(&x, &y)) {
Serial.printf("Rect Touch:(%03d,%03d)", x, y);
//lcd.fillRect(x-2, y-2, 5, 5, TFT_RED);
//Btn 1 detected
/*Below loop is checking button region for each section*/
//Button 1 test
if ((x >= xBox && x <= xBox + xWidth) && (y >= yBox && y <= yBox + yHeight)) {
Serial.println("Box Touched");
if (btn1ClickColl[0]) {
Serial.println("Box Register");
lcd.fillRect(xBox, yBox, xWidth, yHeight, 0x07E0); //Green
int box1TextX = xBox + 10;
int box1TextY = yBox + 10;
lcd.setCursor(box1TextX, box1TextY);
lcd.println("RF Selected");
//btn1Clicked =false;
} else {
Serial.println("Box NOt Register");
lcd.fillRect(xBox, yBox, xWidth, yHeight, 0xF800); //red color
int box1TextX = xBox + 10;
int box1TextY = yBox + 10;
lcd.setCursor(box1TextX, box1TextY);
lcd.println("RF 1");
}
btn1ClickColl[0] = !btn1ClickColl[0];
lcd.setCursor(180, 110);
lcd.printf("Rect Touch:(%03d,%03d)", x, y);
delay(1000);
} else {
lcd.setCursor(180, 110);
lcd.printf("Not touched");
}
// Import as it will move x axis cursor to right for new btn render
xBox = (xBox + xWidth) + marginRight;
//Button 2 test
if ((x >= xBox && x <= xBox + xWidth) && (y >= yBox && y <= yBox + yHeight)) {
Serial.println("Box Touched");
if (btn1ClickColl[1]) {
Serial.println("Box Register");
lcd.fillRect(xBox, yBox, xWidth, yHeight, 0x07E0); //Green
//btn1Clicked =false;
int box1TextX = xBox + 10;
int box1TextY = yBox + 10;
lcd.setCursor(box1TextX, box1TextY);
lcd.println("RF Selected");
} else {
Serial.println("Box NOt Register");
lcd.fillRect(xBox, yBox, xWidth, yHeight, 0xF800); //Red
int box1TextX = xBox + 10;
int box1TextY = yBox + 10;
lcd.setCursor(box1TextX, box1TextY);
lcd.println("RF 2");
}
btn1ClickColl[1] = !btn1ClickColl[1];
lcd.setCursor(180, 110);
lcd.printf("Rect Touch:(%03d,%03d)", x, y);
delay(1000);
} else {
lcd.setCursor(180, 110);
lcd.printf("Not touched");
}
}
lcd.setCursor(380, 0);
lcd.printf("Touch:(%03d,%03d)", x, y);
}
// delay(1000);
Note: Discuss with me before buying this !!!!
Datasheet
https://files.seeedstudio.com/product...
Product link: https://robu.in/product/esp32-develop...
https://www.amazon.in/Seeed-Studio-ES...
Seeed Studio ESP32 Development Board - WT32-SC01 with 3.5in 320x480 Multi-Touch LCD Screen, Built-in Bluetooth WiFi with GUI Firmware and Dual-core Xtensa 32-bit LX6 MCU, 4MB SPI Flash 8MB PSRAM.
About this item
🧡Notice: Please check out the 'Product guides and documents' below before you use it.
🧡【Highly Integrated&Low Power Consumption】WT32-SC01 development board adopts the ESP32-WROVER-B module, which is a general-purpose MCU module with Wi-Fi, Bluetooth, 4MB SPI Flash and 8MB PSRAM.Wireless Connectivity with Wi-Fi&BLE.
🧡【Easy Interactions】3.5-inch 320x480 capacitive 2-point multi-touch screen.Now you can experience easy touch interactions with an ESP32 development board!
🧡【Easy to Program】The board is equipped with a graphical user interface (GUI) firmware, which supports graphical drag-and-drop programming and helps users develop a customized control platform.
🧡【Customize Functions】By using the expansion interfaces on both sides of the development board, developers can customize the use of functions such as button operation, voice control, and camera operation, which greatly shortens the user’s development cycle.
Search tags used:
Getting to Know the WT32-SC01 Touchscreen Display
Wireless-Tag WT32-SC01
How to use WT32-SC01?
WT32-SC01 Development board simple tutorial
wt32-sc01 button
Wt32-SC01 Button simulation using arduino
WT32-SC01 Touchscreen Display
wt32-sc01 with arduino
WT32-SC01 using LOVYANGFX
wt32-sc01 button click
can we program wt32-sc01 with arduino?
toggle button lovyangfx
graphical programming with wt32-sc01 button click
Wt32-sc01 With 3.5in 320x480 Capacitive Multi-touch
Social Links: [FOLLOW]
Social network section
Twitter: https://twitter.com/myzingonline
Facebook : https://www.facebook.com/myzingonline/
Blog : https://myzingonline.in
Youtube Channel :
/ myzingonline
YouTube User ID: ivd6M0sL-YaWMgwAvDtfOA
YouTube Channel ID: UCivd6M0sL-YaWMgwAvDtfOA
0 comments:
Post a Comment