Update:
Ok, made two functions Title() and prevNext() gained 13%
Removed F() basically moved the text from Flash to dynamic memory 3%
Sketch uses 25494 bytes (79%) of program storage space. Maximum is 32256 bytes.
Global variables use 703 bytes (34%) of dynamic memory, leaving 1345 bytes for local variables. Maximum is 2048 bytes.
For now I am happy with the results and learned a few things.
case 10 :
if (displayCase) {
displayCase = false;
Title("Welkom!");
}
if (TkFl != PrTkFl) {
tft.setCursor(5, 100);
tft.setTextColor(BLACK);
tft.print("Tk: ");
tft.println(PrTkFl);
tft.setCursor(5, 100);
tft.setTextColor(WHITE);
tft.print("Tk: ");
tft.println(TkFl);
PrTkFl = TkFl;
}
if (HkFl != PrHkFl) {
tft.setCursor(5, 130);
tft.setTextColor(BLACK);
tft.print("Hk: ");
tft.println(PrHkFl);
tft.setCursor(5, 130);
tft.setTextColor(WHITE);
tft.print("Hk: ");
tft.println(HkFl);
PrHkFl = HkFl;
}
if (LkFl != PrLkFl) {
tft.setCursor(5, 160);
tft.setTextColor(BLACK);
tft.print("Lk: ");
tft.println(PrLkFl, 0);
tft.setCursor(5, 160);
tft.setTextColor(WHITE);
tft.print("Lk: ");
tft.println(LkFl, 0);
PrLkFl = LkFl;
}
if (TbFl != PrTbFl) {
tft.setCursor(5, 190);
tft.setTextColor(BLACK);
tft.print("Tb: ");
tft.println(PrTbFl);
tft.setCursor(5, 190);
tft.setTextColor(WHITE);
tft.print("Tb: ");
tft.println(TbFl);
PrTbFl = TbFl;
}
if (HbFl != PrHbFl) {
tft.setCursor(5, 220);
tft.setTextColor(BLACK);
tft.print("Hb: ");
tft.println(PrHbFl);
tft.setCursor(5, 220);
tft.setTextColor(WHITE);
tft.print("Hb: ");
tft.println(HbFl);
PrHbFl = HbFl;
}
if (LbFl != PrLbFl) {
tft.setCursor(5, 250);
tft.setTextColor(BLACK);
tft.print("Lb: ");
tft.println(PrLbFl, 0);
tft.setCursor(5, 250);
tft.setTextColor(WHITE);
tft.print("Lb: ");
tft.println(LbFl, 0);
PrLbFl = LbFl;
}
prevNext(40, 20);
break;
void Title(String title) {
tft.fillScreen(BLACK);
tft.setFont(&FreeMonoBold18pt7b);
tft.setTextColor(WHITE);
tft.setTextSize(1);
tft.setCursor(40, 45);
tft.print(title);
tft.fillRect(10, 270, 100, 40, RED);
tft.drawRect(10, 270, 100, 40, WHITE);
tft.setTextColor(WHITE);
tft.setCursor(30, 298);
tft.print("<<<");
tft.fillRect(133, 270, 100, 40, RED);
tft.drawRect(133, 270, 100, 40, WHITE);
tft.setCursor(155, 298);
tft.print(">>>");
}
void prevNext(byte prev, byte next) {
TSPoint p = ts.getPoint();
// map(val, fromLow, fromHigh, toLow, toHigh)
py = map(p.x, TS_LEFT, TS_RT, 0, tft.height()); // 320
px = map(p.y, TS_BOT, TS_TOP, 0, tft.width()); // 243
/*
if (p.z > ts.pressureThreshhold) {
Serial.println((String)"X = " + px + "");
Serial.println((String)"Y = " + py + "");
Serial.println((String)"Pressure = " + p.z + "");
}
*/
if (p.z > ts.pressureThreshhold && (px > 10 && px < 180 && py > 10 && py < 40)) {
displayCase = true;
displayCase = prev;
delay(200);
}
if (p.z > ts.pressureThreshhold && (px > 155 && px < 233 && py > 10 && py < 40)) {
displayCase = true;
displayCase = next;
delay(200);
}
}
Thank you all,
Ray
HAL_2020_0_3.ino (11.8 KB)