|
|
@ -131,7 +131,7 @@ String outtext = "";
|
|
|
|
String oldtext = "";
|
|
|
|
String oldtext = "";
|
|
|
|
boolean fastboot = false;
|
|
|
|
boolean fastboot = false;
|
|
|
|
boolean debug;
|
|
|
|
boolean debug;
|
|
|
|
|
|
|
|
int menu = 0;
|
|
|
|
boolean ps3 = false;
|
|
|
|
boolean ps3 = false;
|
|
|
|
boolean upd = true;
|
|
|
|
boolean upd = true;
|
|
|
|
boolean s1, s2, s3, s4;
|
|
|
|
boolean s1, s2, s3, s4;
|
|
|
@ -230,6 +230,16 @@ void setup(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debug = false;
|
|
|
|
debug = false;
|
|
|
|
//getMoisture();
|
|
|
|
//getMoisture();
|
|
|
|
|
|
|
|
tft.fillScreen(ILI9341_BLACK);
|
|
|
|
|
|
|
|
tft.fillRect(0, 0, 160, 20, ILI9341_WHITE);
|
|
|
|
|
|
|
|
tft.setCursor(2, 2);
|
|
|
|
|
|
|
|
tft.setTextFont(4);
|
|
|
|
|
|
|
|
tft.setTextColor(ILI9341_BLACK);
|
|
|
|
|
|
|
|
String out = "Water Level:";
|
|
|
|
|
|
|
|
tft.drawString(out.c_str(), 2, 2, 2);
|
|
|
|
|
|
|
|
drawButton(0, 20, 160, 110, "Settings", "ILI9341_YELLOW");
|
|
|
|
|
|
|
|
drawButton(160, 20, 160, 110, "Stats", "ILI9341_GREEN");
|
|
|
|
|
|
|
|
upd = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const int sec = 1000;
|
|
|
|
const int sec = 1000;
|
|
|
|
const int min = 1000 * 60;
|
|
|
|
const int min = 1000 * 60;
|
|
|
@ -239,13 +249,35 @@ void loop(void) {
|
|
|
|
if (p.z > ts.pressureThreshhold) {
|
|
|
|
if (p.z > ts.pressureThreshhold) {
|
|
|
|
p.x = map(p.x, TS_MINX, TS_MAXX, tft.height(), 0);
|
|
|
|
p.x = map(p.x, TS_MINX, TS_MAXX, tft.height(), 0);
|
|
|
|
p.y = map(p.y, TS_MINY, TS_MAXY, tft.width(), 0);
|
|
|
|
p.y = map(p.y, TS_MINY, TS_MAXY, tft.width(), 0);
|
|
|
|
Serial.print("X = "); Serial.print(p.x);
|
|
|
|
Serial.print("X = "); Serial.print(320 - p.y);
|
|
|
|
Serial.print("\tY = "); Serial.print(p.y);
|
|
|
|
Serial.print("\tY = "); Serial.print(p.x);
|
|
|
|
Serial.print("\tPressure = "); Serial.println(p.z);
|
|
|
|
Serial.print("\tPressure = "); Serial.println(p.z);
|
|
|
|
|
|
|
|
int x = 320 - p.y;
|
|
|
|
|
|
|
|
int y = p.x;
|
|
|
|
|
|
|
|
if (x < 160 && y < 130) {
|
|
|
|
|
|
|
|
button(0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x > 160 && y < 130) {
|
|
|
|
if (ps3) {
|
|
|
|
button(1, 0);
|
|
|
|
ADCSRA = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x < 160 && y > 130) {
|
|
|
|
|
|
|
|
button(0, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x > 160 && y > 130) {
|
|
|
|
|
|
|
|
button(1, 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (upd) {
|
|
|
|
|
|
|
|
if (menu == 0) {
|
|
|
|
|
|
|
|
drawButton(0, 20, 160, 110, "Settings", "ILI9341_YELLOW");
|
|
|
|
|
|
|
|
drawButton(160, 20, 160, 110, "Stats", "ILI9341_GREEN");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (menu == 1) {
|
|
|
|
|
|
|
|
drawButton(0, 130, 160, 110, "Reset", "ILI9341_GREEN");
|
|
|
|
|
|
|
|
drawButton(0, 20, 320, 110, "Stop", "ILI9341_RED");
|
|
|
|
|
|
|
|
drawButton(160, 130, 160, 110, "Back", "ILI9341_BLUE");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
upd = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(Serial.available() > 0) {
|
|
|
|
if(Serial.available() > 0) {
|
|
|
|
String txtin = "Serial: " + Serial.readString();
|
|
|
|
String txtin = "Serial: " + Serial.readString();
|
|
|
@ -299,18 +331,7 @@ void loop(void) {
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
// change upd to true if screen update needed
|
|
|
|
// change upd to true if screen update needed
|
|
|
|
if(!debug && upd) {
|
|
|
|
|
|
|
|
tft.fillScreen(ILI9341_BLACK);
|
|
|
|
|
|
|
|
tft.fillRect(0, 0, 160, 20, ILI9341_WHITE);
|
|
|
|
|
|
|
|
tft.setCursor(2, 2);
|
|
|
|
|
|
|
|
tft.setTextFont(4);
|
|
|
|
|
|
|
|
tft.setTextColor(ILI9341_BLACK);
|
|
|
|
|
|
|
|
String out = "Water Level:";
|
|
|
|
|
|
|
|
tft.drawString(out.c_str(), 2, 2, 2);
|
|
|
|
|
|
|
|
drawButton(0, 20, 160, 110, "Settings", "ILI9341_YELLOW");
|
|
|
|
|
|
|
|
drawButton(160, 20, 160, 110, "Stats", "ILI9341_GREEN");
|
|
|
|
|
|
|
|
upd = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
batteryupd.Update();
|
|
|
|
batteryupd.Update();
|
|
|
|
water.Update();
|
|
|
|
water.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -329,16 +350,14 @@ void checkBat() {
|
|
|
|
delay(10);
|
|
|
|
delay(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(analogRead(1) > 910) {
|
|
|
|
if(analogRead(1) > 910) {
|
|
|
|
out += map(y / 20, 572, 859, 0, 100) - 20;
|
|
|
|
out += "Using solar poower";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
out += map(y / 20, 572, 859, 0, 100);
|
|
|
|
out += map(y / 20, 572, 859, 0, 100);
|
|
|
|
|
|
|
|
out += "%";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out += "%, Raw: ";
|
|
|
|
out += ", Raw: ";
|
|
|
|
out += y/20;
|
|
|
|
out += y/20;
|
|
|
|
out += ".";
|
|
|
|
out += ".";
|
|
|
|
if(analogRead(1) > 910) {
|
|
|
|
|
|
|
|
out += ". Battery Charging.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printFastCText(out);
|
|
|
|
printFastCText(out);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
String out = "Battery: ";
|
|
|
|
String out = "Battery: ";
|
|
|
@ -348,13 +367,10 @@ void checkBat() {
|
|
|
|
delay(10);
|
|
|
|
delay(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(analogRead(1) > 910) {
|
|
|
|
if(analogRead(1) > 910) {
|
|
|
|
out += map(y / 20, 572, 859, 0, 100) - 20;
|
|
|
|
out += "Using solar.";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
out += map(y / 20, 572, 859, 0, 100);
|
|
|
|
out += map(y / 20, 572, 859, 0, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
out += "%";
|
|
|
|
out += "%";
|
|
|
|
if(analogRead(1) > 910) {
|
|
|
|
|
|
|
|
out += " Charging";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tft.fillRect(160, 0, 160, 20, ILI9341_WHITE);
|
|
|
|
tft.fillRect(160, 0, 160, 20, ILI9341_WHITE);
|
|
|
|
tft.drawString(out.c_str(), 162, 2, 2);
|
|
|
|
tft.drawString(out.c_str(), 162, 2, 2);
|
|
|
@ -629,7 +645,48 @@ void scrollAddress(uint16_t vsp) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void drawButton(int x, int y, int w, int h, char* text, char* color) {
|
|
|
|
void drawButton(int x, int y, int w, int h, char* text, char* color) {
|
|
|
|
|
|
|
|
tft.fillRect(x, y, w, h, ILI9341_BLACK);
|
|
|
|
tft.setTextFont(4);
|
|
|
|
tft.setTextFont(4);
|
|
|
|
tft.fillRect(x, y, w, h, color);
|
|
|
|
tft.fillRect(x, y, w, h, color);
|
|
|
|
tft.drawCentreString(text, x + w/2, y + h/2 - 15, 4);
|
|
|
|
tft.drawCentreString(text, x + w/2, y + h/2 - 15, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void button(int x, int y) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (menu == 0) {
|
|
|
|
|
|
|
|
if (x == 0 && y == 0) {
|
|
|
|
|
|
|
|
menu = 1;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x == 1 && y == 0) {
|
|
|
|
|
|
|
|
menu = 2;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x == 0 && y == 1) {
|
|
|
|
|
|
|
|
menu = 3;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x == 1 && y == 1) {
|
|
|
|
|
|
|
|
menu = 4;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (menu == 1) {
|
|
|
|
|
|
|
|
if (x == 0 && y == 1) {
|
|
|
|
|
|
|
|
tft.fillRect(0, 0, 320, 240, ILI9341_BLACK);
|
|
|
|
|
|
|
|
pinMode(9, OUTPUT);
|
|
|
|
|
|
|
|
digitalWrite(9, LOW); // RESET
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y == 0) {
|
|
|
|
|
|
|
|
// STOP CODE HERE
|
|
|
|
|
|
|
|
water.Stop();
|
|
|
|
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x == 1 && y == 1) {
|
|
|
|
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delay(250);
|
|
|
|
|
|
|
|
}
|
|
|
|