now when pressing Reset button on screen
void (*resetFunc)(void) = 0;
hangs the screen & mega2560
can you solve this?
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
#include <TouchScreen.h>
#include <EEPROM.h>
#include <AceButton.h>
#include <arduino-timer.h>
MCUFRIEND_kbv tft;
auto timer = timer_create_default();
using namespace ace_button;
// Fonts
#include <FreeDefaultFonts.h>
#include <Fonts/FreeSansBold12pt7b.h>
#include <Fonts/FreeSansBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
// Touchscreen settings
#define MINPRESSURE 5
#define MAXPRESSURE 1000
const int XP = 8, XM = A2, YP = A3, YM = 9;
const int TS_LEFT = 134, TS_RT = 887, TS_TOP = 945, TS_BOT = 87;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
int pixel_x, pixel_y; //Touch_getXY() updates global vars
bool Touch_getXY(void)
{
TSPoint p = ts.getPoint();
pinMode(YP, OUTPUT); //restore shared pins
pinMode(XM, OUTPUT);
digitalWrite(YP, HIGH); //because TFT control pins
digitalWrite(XM, HIGH);
bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
if (pressed) {
pixel_x = map(p.x, TS_LEFT, TS_RT, 0, tft.width()); //.kbv makes sense to me
pixel_y = map(p.y, TS_TOP, TS_BOT, 0, tft.height());
}
return pressed;
}
//Color definition
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define ORANGE 0xFD20
#define PURPLE 0x801F
#define PINK 0xF81F
#define OLIVE 0xBFF7
Adafruit_GFX_Button start_btn, reset_btn, off_btn, manual_btn, dry_btn, dark_btn, nrml_btn, graph_btn, wthr_btn, wifi_btn;
const int trigPin = 26;
const int echoPin = 27;
// define the GPIO connected with Relays and switches
#define RelayPin1 22
#define RelayPin2 23
#define RelayPin3 24
#define RelayPin4 25
#define SwitchPin1 28
#define SwitchPin2 29
#define SwitchPin3 30
#define SwitchPin4 31
#define WIFI_LED LED_BUILTIN
// define the GPIO connected with Relays and switches
#define RelayPin1 22
#define RelayPin2 23
#define RelayPin3 24
#define RelayPin4 25
#define SwitchPin1 28
#define SwitchPin2 29
#define SwitchPin3 30
#define SwitchPin4 31
#define WIFI_LED LED_BUILTIN
String bt_data; // variable for storing bluetooth data
String pinStatus = "000000.00";
String wifiLed = "HI";
int level;
int temp = 0;
long duration;
float distance;
int water_level;
int water_percentage;
int water_bottom = 160;
int water_top = 25;
int water_distance = 135;
int sensor;
int prev = 0;
int bar;
int bottom = 400;
int width = 50;
int maxscale = 100;
int zero = 0;
int one = 150;
int two = 250;
int three = 300;
int four = 350;
int five = 400;
int six = 480;
ButtonConfig config1;
AceButton button1(&config1);
ButtonConfig config2;
AceButton button2(&config2);
ButtonConfig config3;
AceButton button3(&config3);
ButtonConfig config4;
AceButton button4(&config4);
void handleEvent1(AceButton*, uint8_t, uint8_t);
void handleEvent2(AceButton*, uint8_t, uint8_t);
void handleEvent3(AceButton*, uint8_t, uint8_t);
void handleEvent4(AceButton*, uint8_t, uint8_t);
void relayOnOff(int relay){
switch(relay){
case 1:
digitalWrite(RelayPin1, !digitalRead(RelayPin1)); // change state for relay-1
EEPROM.update(0,digitalRead(RelayPin1));
delay(100);
break;
case 2:
digitalWrite(RelayPin2, !digitalRead(RelayPin2)); // change state for relay-2
EEPROM.update(1,digitalRead(RelayPin2));
delay(100);
break;
case 3:
digitalWrite(RelayPin3, !digitalRead(RelayPin3)); // change state for relay-3
EEPROM.update(2,digitalRead(RelayPin3));
delay(100);
break;
case 4:
digitalWrite(RelayPin4, !digitalRead(RelayPin4)); // change state for relay-4
EEPROM.update(3,digitalRead(RelayPin4));
delay(100);
break;
default : break;
}
}
void eepromState()
{
digitalWrite(RelayPin1, EEPROM.read(0)); delay(200);
if (EEPROM.read(0) == LOW) {
onStartChange();
}
digitalWrite(RelayPin2, EEPROM.read(1)); delay(200);
digitalWrite(RelayPin3, EEPROM.read(2)); delay(200);
if (EEPROM.read(2) == LOW) {
onManualChange();
}
digitalWrite(RelayPin4, EEPROM.read(3)); delay(200);
}
void wifi_control()
{
while(Serial1.available()) {
bt_data = Serial1.readString();
Serial.println(bt_data);
if(bt_data == "A1") { onStartChange(); EEPROM.update(0,LOW); } // if 'A1' received Turn on Relay1
if(bt_data == "A0") { onOffChange(); EEPROM.update(0,HIGH); } // if 'A0' received Turn off Relay1
if(bt_data == "B1") { onManualChange(); EEPROM.update(1,LOW); } // if 'B1' received Turn on Relay2
if(bt_data == "B0") { onOffChange(); EEPROM.update(1,HIGH); } // if 'B0' received Turn off Relay2
if(bt_data == "C1") { onDryChange(); EEPROM.update(2,LOW); } // if 'C1' received Turn on Relay3
if(bt_data == "C0") { onOffChange(); EEPROM.update(2,HIGH); } // if 'C0' received Turn off Relay3
if(bt_data == "D1") { digitalWrite(RelayPin4, LOW); EEPROM.update(3,LOW); } // if 'D1' received Turn on Relay4
if(bt_data == "D0") { digitalWrite(RelayPin4, HIGH); EEPROM.update(3,HIGH); } // if 'D0' received Turn off Relay4
// if(bt_data == "LO") { wifiOn(); }
// if(bt_data == "HI") { wifiOff(); }
//if(bt_data == "W1") { digitalWrite(WIFI_LED, HIGH); } // if 'W1' Turn on WiFi LED
//if(bt_data == "W0") { digitalWrite(WIFI_LED, LOW); } // if 'W0' Turn off WiFi LED
delay(200);
pinStatus = String(!digitalRead(RelayPin1)) + String(!digitalRead(RelayPin2)) + String(!digitalRead(RelayPin3)) + String(!digitalRead(RelayPin4))+ String(wifiLed);
//Serial1.print(pinStatus);
//Serial.print(pinStatus);
}
}
void wifiOn() {
tft.setTextColor(GREEN);
tft.setTextSize(1);
tft.setFont(&FreeMonoBold12pt7b);
tft.setCursor(110, 35);
tft.print("WiFi");
}
void wifiOff() {
tft.setTextColor(RED);
tft.setTextSize(1);
tft.setFont(&FreeMonoBold12pt7b);
tft.setCursor(110, 35);
tft.print("WiFi");
}
void all_Switch_ON(){
digitalWrite(RelayPin1, LOW); EEPROM.update(0,LOW); delay(100);
digitalWrite(RelayPin2, LOW); EEPROM.update(1,LOW); delay(100);
digitalWrite(RelayPin3, LOW); EEPROM.update(2,LOW); delay(100);
digitalWrite(RelayPin4, LOW); EEPROM.update(3,LOW); delay(100);
}
void all_Switch_OFF(){
digitalWrite(RelayPin1, HIGH); EEPROM.update(0,HIGH); delay(100);
digitalWrite(RelayPin2, HIGH); EEPROM.update(1,HIGH); delay(100);
digitalWrite(RelayPin3, HIGH); EEPROM.update(2,HIGH); delay(100);
digitalWrite(RelayPin4, HIGH); EEPROM.update(3,HIGH); delay(100);
}
void readSensor(){
}
void sendStatus(){
// readSensor();
pinStatus = String(!digitalRead(RelayPin1)) + String(!digitalRead(RelayPin2)) + String(!digitalRead(RelayPin3)) + String(!digitalRead(RelayPin4));
Serial1.print(pinStatus);
}
void (*resetFunc)(void) = 0;
void setup() {
Serial.begin(115200);
Serial1.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);
pinMode(RelayPin3, OUTPUT);
pinMode(RelayPin4, OUTPUT);
pinMode(WIFI_LED, OUTPUT);
pinMode(SwitchPin1, INPUT_PULLUP);
pinMode(SwitchPin2, INPUT_PULLUP);
pinMode(SwitchPin3, INPUT_PULLUP);
pinMode(SwitchPin4, INPUT_PULLUP);
digitalWrite(RelayPin1, HIGH);
digitalWrite(RelayPin2, HIGH);
digitalWrite(RelayPin3, HIGH);
digitalWrite(RelayPin4, HIGH);
digitalWrite(WIFI_LED, LOW);
config1.setEventHandler(button1Handler);
config2.setEventHandler(button2Handler);
config3.setEventHandler(button3Handler);
config4.setEventHandler(button4Handler);
button1.init(SwitchPin1);
button2.init(SwitchPin2);
button3.init(SwitchPin3);
button4.init(SwitchPin4);
Serial1.println("bulu");
tft.begin(0x9486);
tft.setRotation(0);
tft.fillScreen(WHITE);
// Touchscreen buttons init
reset_btn.initButton(&tft, 195, 460, 40, 25, WHITE, RED, GREEN, "", 0);
start_btn.initButton(&tft, 158, 240, 100, 100, WHITE, WHITE, WHITE, "", 0);
off_btn.initButton(&tft, 265, 240, 100, 100, WHITE, WHITE, WHITE, "", 0);
manual_btn.initButton(&tft, 158, 345, 100, 100, WHITE, WHITE, WHITE, "", 0);
dry_btn.initButton(&tft, 265, 345, 100, 100, WHITE, WHITE, WHITE, "", 0);
dark_btn.initButton(&tft, 300, 460, 40, 15, WHITE, BLACK, RED, "", 0);
nrml_btn.initButton(&tft, 260, 460, 40, 15, WHITE, TFT_LIGHTGREY, RED, "", 0);
wifi_btn.initButton(&tft, 135, 30, 60, 40, WHITE, WHITE, WHITE, "", 0);
graph_btn.initButton(&tft, 210, 30, 60, 40, WHITE, WHITE, WHITE, "", 0);
wthr_btn.initButton(&tft, 285, 30, 60, 40, WHITE, WHITE, WHITE, "", 0); //cloud
reset_btn.drawButton(false);
start_btn.drawButton(false);
off_btn.drawButton(false);
manual_btn.drawButton(false);
dry_btn.drawButton(false);
dark_btn.drawButton(false);
nrml_btn.drawButton(false);
wifi_btn.drawButton(false);
graph_btn.drawButton(false);
wthr_btn.drawButton(false);
// Drawings
tft.setTextColor(WHITE); //reset text
tft.setTextSize(1);
tft.setCursor(180, 457);
tft.print("RESET");
tft.fillRect(180, 10, 8, 40, PURPLE); //Bar Graph design
tft.fillRect(188, 25, 8, 25, GREEN);
tft.fillRect(196, 20, 8, 30, RED);
tft.fillRect(204, 15, 8, 35, TFT_LIGHTGREY);
tft.fillRect(212, 40, 8, 10, ORANGE);
tft.fillRect(220, 18, 8, 32, OLIVE);
tft.fillRect(228, 36, 8, 14, YELLOW);
tft.fillRect(236, 10, 8, 40, BLUE);
tft.fillRoundRect(267, 30, 35, 20, 5, TFT_LIGHTGREY); //Cloud design
tft.fillCircle(265, 35, 15, TFT_LIGHTGREY);
tft.fillCircle(300, 35, 15, TFT_LIGHTGREY);
tft.fillCircle(295, 20, 15, TFT_LIGHTGREY);
tft.fillCircle(273, 22, 10, TFT_LIGHTGREY);
tft.fillCircle(158, 240, 48, GREEN); //Start button design
tft.fillCircle(158, 240, 40, WHITE);
tft.setFont(&FreeSansBold9pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(127, 247);
tft.print("START");
tft.fillCircle(265, 240, 48, RED); //OFF button design
tft.fillCircle(265, 240, 40, WHITE);
tft.setFont(&FreeSansBold12pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(240, 250);
tft.print("OFF");
tft.fillCircle(158, 345, 48, RED); //MANUAL button design
tft.fillCircle(158, 345, 40, WHITE);
tft.setCursor(127, 348); //manual text
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("Manual");
tft.fillCircle(265, 345, 48, RED); //DRY button design
tft.fillCircle(265, 345, 40, WHITE);
tft.setCursor(242, 355); //DRY text
tft.setFont(&FreeSansBold12pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("DRY");
delay(10);
eepromState();
wifiOn();
// wifiOff();
// call the toggle_led function every 500 millis (2 seconds)
timer.every(500, sendStatus);
Serial.println("Setup complete, starting loop!");
}
void loop() {
bool down = Touch_getXY();
reset_btn.press(down && reset_btn.contains(pixel_x, pixel_y));
start_btn.press(down && start_btn.contains(pixel_x, pixel_y));
off_btn.press(down && off_btn.contains(pixel_x, pixel_y));
manual_btn.press(down && manual_btn.contains(pixel_x, pixel_y));
dry_btn.press(down && dry_btn.contains(pixel_x, pixel_y));
graph_btn.press(down && graph_btn.contains(pixel_x, pixel_y));
wthr_btn.press(down && wthr_btn.contains(pixel_x, pixel_y));
wifi_btn.press(down && wifi_btn.contains(pixel_x, pixel_y));
if (reset_btn.justPressed()) {
resetFunc();
}
if (start_btn.justPressed()) {
onStartChange();
}
if (off_btn.justPressed()) {
onOffChange();
}
if (manual_btn.justPressed()) {
onManualChange();
}
if (dry_btn.justPressed()) {
onDryChange();
}
if (graph_btn.justPressed()) {
//
}
if (wthr_btn.justPressed()) {
//
}
if (wifi_btn.justPressed()) {
//
}
number();
darkMode();
wifi_control();
button1.check();
button2.check();
button3.check();
button4.check();
usSensor();
timer.tick(); // tick the timer
}
void button1Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
switch (eventType) {
case AceButton::kEventReleased:
relayOnOff(1);
onStartChange();
break;
}
}
void button2Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
switch (eventType) {
case AceButton::kEventReleased:
relayOnOff(2);
onOffChange();
break;
}
}
void button3Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
switch (eventType) {
case AceButton::kEventReleased:
relayOnOff(3);
onManualChange();
break;
}
}
void button4Handler(AceButton* button, uint8_t eventType, uint8_t buttonState) {
switch (eventType) {
case AceButton::kEventReleased:
relayOnOff(4);
onDryChange();
break;
}
}
void usSensor() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
water_percentage = (100 * (water_top + water_distance - distance)) / water_distance;
level = water_percentage;
sensor = water_percentage;
// Serial.println(sensor);
bar = water_percentage * bottom / maxscale;
if (distance < 25 && temp == 0) {
onOffChange();
Serial.println("Water Tank Full ");
}
else if (distance < 25 && temp == 1) {
onOffChange();
Serial.println("Water Tank Full2 ");
delay(10);
}
else if (distance > 100) {
// digitalWrite(RelayPin1, LOW);
onStartChange();
Serial.println("Low Water Level");
Serial.println("100Motor Auto Mode ON");
delay(10);
temp = 0;
}
delay(50);
tft.fillRect(40, 40, 50, -40, WHITE);
tft.fillRect(40, 440, 50, 40, WHITE);
tft.fillRect(40, 40, width, bottom - bar, WHITE);
if (bar > zero && bar <= one) {
tft.fillRect(40, 40 + bottom - bar, width, bar, RED);
delay(500);
}
else if (bar > one && bar <= two) {
tft.fillRect(40, 40 + bottom - bar, width, bar, ORANGE);
delay(500);
}
else if (bar > two && bar <= three) {
tft.fillRect(40, 40 + bottom - bar, width, bar, YELLOW);
delay(500);
}
else if (bar > three && bar <= four) {
tft.fillRect(40, 40 + bottom - bar, width, bar, GREEN);
delay(500);
}
else if (bar > four && bar <= five) {
tft.fillRect(40, 40 + bottom - bar, width, bar, BLUE);
delay(500);
}
else if (bar > five && bar <= six) {
tft.fillRect(40, 40 + bottom - bar, width, bar, WHITE);
}
else (bar > five && bar <= six); {
// do nothing
}
}
void onStartChange() {
tft.fillCircle(158, 240, 48, CYAN);
tft.fillCircle(158, 240, 40, GREEN);
tft.setTextColor(BLACK);
tft.setFont(&FreeSansBold12pt7b);
tft.setTextSize(1);
tft.setCursor(140, 250);
tft.print("ON");
tft.fillCircle(265, 240, 48, TFT_LIGHTGREY); //OFF button design
tft.fillCircle(265, 240, 40, WHITE);
tft.setFont(&FreeSansBold12pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(240, 250);
tft.print("OFF");
tft.fillCircle(158, 345, 48, TFT_LIGHTGREY); //MANUAL button design
tft.fillCircle(158, 345, 40, WHITE);
tft.setCursor(127, 348); //manual text
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("Manual");
tft.fillCircle(265, 345, 48, TFT_LIGHTGREY); //DRY button design
tft.fillCircle(265, 345, 40, WHITE);
tft.setCursor(242, 355); //DRY text
tft.setFont(&FreeSansBold12pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("DRY");
digitalWrite(RelayPin1, LOW); EEPROM.update(0,LOW); delay(100);
digitalWrite(RelayPin2, HIGH); EEPROM.update(1,HIGH); delay(100);
digitalWrite(RelayPin3, HIGH); EEPROM.update(2,HIGH); delay(100);
Serial.println("TFT Motor ON");
delay(50);
}
void onOffChange() {
tft.fillCircle(158, 240, 48, TFT_LIGHTGREY);
tft.fillCircle(158, 240, 40, WHITE);
tft.setFont(&FreeSansBold9pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(127, 247);
tft.print("START");
tft.fillCircle(265, 240, 48, CYAN); //OFF button design
tft.fillCircle(265, 240, 40, RED);
tft.setFont(&FreeSansBold12pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(240, 250);
tft.print("OFF");
tft.fillCircle(158, 345, 48, TFT_LIGHTGREY); //MANUAL button design
tft.fillCircle(158, 345, 40, WHITE);
tft.setCursor(127, 348); //manual text
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("Manual");
tft.fillCircle(265, 345, 48, TFT_LIGHTGREY); //DRY button design
tft.fillCircle(265, 345, 40, WHITE);
tft.setCursor(242, 355); //DRY text
tft.setFont(&FreeSansBold12pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("DRY");
digitalWrite(RelayPin1, HIGH); EEPROM.update(0,HIGH); delay(100);
digitalWrite(RelayPin2, HIGH); EEPROM.update(1,HIGH); delay(100);
digitalWrite(RelayPin3, HIGH); EEPROM.update(2,HIGH); delay(100);
Serial.println("TFT OFF Pressed");
delay(50);
}
void onManualChange() {
tft.fillCircle(158, 240, 48, TFT_LIGHTGREY);
tft.fillCircle(158, 240, 40, WHITE);
tft.setFont(&FreeSansBold9pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(127, 247);
tft.print("START");
tft.fillCircle(265, 240, 48, TFT_LIGHTGREY); //OFF button design
tft.fillCircle(265, 240, 40, WHITE);
tft.setFont(&FreeSansBold12pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(240, 250);
tft.print("OFF");
tft.fillCircle(158, 345, 48, CYAN); //MANUAL button design
tft.fillCircle(158, 345, 40, GREEN);
tft.setCursor(127, 348); //manual text
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("Manual");
tft.fillCircle(265, 345, 48, TFT_LIGHTGREY); //DRY button design
tft.fillCircle(265, 345, 40, WHITE);
tft.setCursor(242, 355); //DRY text
tft.setFont(&FreeSansBold12pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("DRY");
digitalWrite(RelayPin1, HIGH); EEPROM.update(0,HIGH); delay(100);
digitalWrite(RelayPin2, LOW); EEPROM.update(1,LOW); delay(100);
digitalWrite(RelayPin3, HIGH); EEPROM.update(2,HIGH); delay(100);
Serial.println("TFT Manual Pressed");
delay(50);
}
void onDryChange() {
tft.fillCircle(158, 240, 48, TFT_LIGHTGREY);
tft.fillCircle(158, 240, 40, WHITE);
tft.setFont(&FreeSansBold9pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(127, 247);
tft.print("START");
tft.fillCircle(265, 240, 48, TFT_LIGHTGREY); //OFF button design
tft.fillCircle(265, 240, 40, WHITE);
tft.setFont(&FreeSansBold12pt7b);
tft.setTextSize(1);
tft.setTextColor(BLACK);
tft.setCursor(240, 250);
tft.print("OFF");
tft.fillCircle(158, 345, 48, TFT_LIGHTGREY); //MANUAL button design
tft.fillCircle(158, 345, 40, WHITE);
tft.setCursor(127, 348); //manual text
tft.setFont(&FreeSansBold9pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("Manual");
tft.fillCircle(265, 345, 48, CYAN); //DRY button design
tft.fillCircle(265, 345, 40, GREEN);
tft.setCursor(242, 355); //DRY text
tft.setFont(&FreeSansBold12pt7b);
tft.setTextColor(BLACK);
tft.setTextSize(1);
tft.println("DRY");
digitalWrite(RelayPin1, HIGH); EEPROM.update(0,HIGH); delay(100);
digitalWrite(RelayPin2, HIGH); EEPROM.update(1,HIGH); delay(100);
digitalWrite(RelayPin3, LOW); EEPROM.update(2,LOW); delay(100);
Serial.println("TFT Dry Pressed");
delay(15000);
digitalWrite(RelayPin1, HIGH); EEPROM.update(0,HIGH); delay(100);
digitalWrite(RelayPin2, HIGH); EEPROM.update(1,HIGH); delay(100);
digitalWrite(RelayPin3, HIGH); EEPROM.update(2,HIGH); delay(100);
delay(50);
onStartChange();
}
void number() {
tft.setFont(&FreeSevenSegNumFont);
tft.setCursor(120, 170);
tft.setTextColor(RED);
tft.setTextSize(2);
tft.println(level);
delay(2000);
tft.setFont(&FreeSevenSegNumFont);
tft.setCursor(120, 170);
tft.setTextColor(WHITE);
tft.println(level);
}
void darkMode(void) {
bool down = Touch_getXY();
dark_btn.press(down && dark_btn.contains(pixel_x, pixel_y));
nrml_btn.press(down && nrml_btn.contains(pixel_x, pixel_y));
if (dark_btn.justReleased())
dark_btn.drawButton();
if (nrml_btn.justReleased())
nrml_btn.drawButton();
if (dark_btn.justPressed()) {
dark_btn.drawButton(true);
tft.invertDisplay(true);
}
if (nrml_btn.justPressed()) {
nrml_btn.drawButton(true);
tft.invertDisplay(false);
}
}
i solved my last query, just commented //Serial.print lines