|
|
@ -159,9 +159,9 @@ boolean s1, s2, s3, s4;
|
|
|
|
String outtext2 = "";
|
|
|
|
String outtext2 = "";
|
|
|
|
int linecount = 0;
|
|
|
|
int linecount = 0;
|
|
|
|
int brightness = 255;
|
|
|
|
int brightness = 255;
|
|
|
|
int uda[] = {};
|
|
|
|
int uda[] = {200, 30, 100, 20, 300};
|
|
|
|
int sla[] = {10, 90, 300, 280};
|
|
|
|
int sla[] = {10, 90, 300, 280};
|
|
|
|
|
|
|
|
int go = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup(void) {
|
|
|
|
void setup(void) {
|
|
|
@ -208,7 +208,7 @@ void setup(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clearLog();
|
|
|
|
clearLog();
|
|
|
|
printFastCText("Booting GreenhouseOS...");
|
|
|
|
printFastCText("Booting GreenhouseOS...");
|
|
|
|
printFastCText("Version: 0.1.5");
|
|
|
|
printFastCText("Version: 0.2.2");
|
|
|
|
printFastCText("");
|
|
|
|
printFastCText("");
|
|
|
|
delay(250);
|
|
|
|
delay(250);
|
|
|
|
if(!didDraw) {
|
|
|
|
if(!didDraw) {
|
|
|
@ -264,12 +264,12 @@ void setup(void) {
|
|
|
|
tft.setTextColor(ILI9341_BLACK);
|
|
|
|
tft.setTextColor(ILI9341_BLACK);
|
|
|
|
String out = "Water Level:";
|
|
|
|
String out = "Water Level:";
|
|
|
|
tft.drawString(out.c_str(), 2, 2, 2);
|
|
|
|
tft.drawString(out.c_str(), 2, 2, 2);
|
|
|
|
drawButton(0, 20, 160, 110, "Settings", "ILI9341_YELLOW");
|
|
|
|
//drawButton(0, 20, 160, 110, "Settings", "ILI9341_YELLOW");
|
|
|
|
drawButton(160, 20, 160, 110, "Stats", "ILI9341_GREEN");
|
|
|
|
//drawButton(160, 20, 160, 110, "Stats", "ILI9341_GREEN");
|
|
|
|
upd = false;
|
|
|
|
upd = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const int sec = 1000;
|
|
|
|
const int sec = 1000;
|
|
|
|
const int min = 1000 * 60;
|
|
|
|
const int mins = 1000 * 60;
|
|
|
|
const int hr = 1000 * 60 * 60;
|
|
|
|
const int hr = 1000 * 60 * 60;
|
|
|
|
void loop(void) {
|
|
|
|
void loop(void) {
|
|
|
|
TSPoint p = ts.getPoint();
|
|
|
|
TSPoint p = ts.getPoint();
|
|
|
@ -288,6 +288,9 @@ void loop(void) {
|
|
|
|
analogWrite(6, map(sla[3], 0, 280, 25, 255));
|
|
|
|
analogWrite(6, map(sla[3], 0, 280, 25, 255));
|
|
|
|
drawSlider(sla);
|
|
|
|
drawSlider(sla);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(menu == 3) {
|
|
|
|
|
|
|
|
updUD(uda);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (x < 160 && y < 130) {
|
|
|
|
if (x < 160 && y < 130) {
|
|
|
|
button(0, 0);
|
|
|
|
button(0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -302,26 +305,31 @@ void loop(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((batteryupd.m_milliseconds - millis() + batteryupd.m_lastRunTimestamp) / 250 == 0 && menu == 2) {
|
|
|
|
if ((batteryupd.m_milliseconds - millis() + batteryupd.m_lastRunTimestamp) / (sec / 4) == 0 && menu == 2) {
|
|
|
|
upd = true;
|
|
|
|
upd = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (upd) {
|
|
|
|
if (upd) {
|
|
|
|
if (menu == 0) {
|
|
|
|
if (menu == 0) {
|
|
|
|
drawButton(0, 20, 160, 110, "System", "ILI9341_YELLOW");
|
|
|
|
drawButton(0, 20, 160, 110, "System", ILI9341_YELLOW);
|
|
|
|
drawButton(160, 20, 160, 110, "Stats", "ILI9341_GREEN");
|
|
|
|
drawButton(160, 20, 160, 110, "Stats", ILI9341_GREEN);
|
|
|
|
drawButton(0, 130, 160, 110, "Options", "ILI9341_BLUE");
|
|
|
|
drawButton(0, 130, 160, 110, "Options", ILI9341_BLUE);
|
|
|
|
drawButton(160, 130, 160, 110, "Stop", "ILI9341_BLACK");
|
|
|
|
if(go) {
|
|
|
|
|
|
|
|
drawButton(160, 130, 160, 110, "Stop", ILI9341_RED);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
drawButton(160, 130, 160, 110, "Start", ILI9341_RED);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (menu == 1) {
|
|
|
|
if (menu == 1) {
|
|
|
|
drawButton(0, 130, 160, 110, "Reset", "ILI9341_GREEN");
|
|
|
|
drawButton(0, 130, 160, 110, "Reset", ILI9341_GREEN);
|
|
|
|
drawButton(0, 20, 320, 110, "", "ILI9341_RED");
|
|
|
|
drawButton(0, 20, 320, 110, "Brightness", ILI9341_RED);
|
|
|
|
drawSlider(sla);
|
|
|
|
drawSlider(sla);
|
|
|
|
drawButton(160, 130, 160, 110, "Back", "ILI9341_BLUE");
|
|
|
|
drawButton(160, 130, 160, 110, "Back", ILI9341_BLUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (menu == 2) {
|
|
|
|
if (menu == 2) {
|
|
|
|
//debug = true;
|
|
|
|
//debug = true;
|
|
|
|
//printFastCText("pressed");
|
|
|
|
//printFastCText("pressed");
|
|
|
|
drawButton(0, 20, 320, 220, "", "ILI9341_BLACK");
|
|
|
|
drawButton(0, 20, 320, 220, "", ILI9341_WHITE);
|
|
|
|
float h = dht.readHumidity();
|
|
|
|
float h = dht.readHumidity();
|
|
|
|
// Read temperature as Celsius (the default)
|
|
|
|
// Read temperature as Celsius (the default)
|
|
|
|
float t = dht.readTemperature();
|
|
|
|
float t = dht.readTemperature();
|
|
|
@ -335,11 +343,16 @@ void loop(void) {
|
|
|
|
txt += f;
|
|
|
|
txt += f;
|
|
|
|
txt += " degrees";
|
|
|
|
txt += " degrees";
|
|
|
|
displayText(2, 53, false, txt, 4);
|
|
|
|
displayText(2, 53, false, txt, 4);
|
|
|
|
txt = (water.m_milliseconds - millis() + water.m_lastRunTimestamp) / 60000;
|
|
|
|
txt = (water.m_milliseconds - millis() + water.m_lastRunTimestamp) / 60000 + 1; // ceil instead of float
|
|
|
|
txt += " minutes until water";
|
|
|
|
txt += " minutes until water";
|
|
|
|
displayText(2, 76, false, txt, 4);
|
|
|
|
displayText(2, 76, false, txt, 4);
|
|
|
|
// moisture, temperature, next cycle, how much water, power usage, sensor connections
|
|
|
|
// moisture, temperature, next cycle, how much water, power usage, sensor connections
|
|
|
|
drawButton(160, 130, 160, 110, "Back", "ILI9341_BLUE");
|
|
|
|
drawButton(160, 130, 160, 110, "Back", ILI9341_BLUE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (menu == 3) {
|
|
|
|
|
|
|
|
drawButton(0, 20, 320, 220, "", ILI9341_WHITE);
|
|
|
|
|
|
|
|
drawButton(160, 130, 160, 110, "Back", ILI9341_BLUE);
|
|
|
|
|
|
|
|
drawUD(uda);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
upd = false;
|
|
|
|
upd = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -745,8 +758,16 @@ void button(int x, int y) {
|
|
|
|
upd = true;
|
|
|
|
upd = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x == 1 && y == 1) {
|
|
|
|
if (x == 1 && y == 1) {
|
|
|
|
menu = 4;
|
|
|
|
if(go) {
|
|
|
|
upd = true;
|
|
|
|
water.Stop();
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
go = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
water.Start();
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
go = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (menu == 1) {
|
|
|
|
else if (menu == 1) {
|
|
|
@ -769,6 +790,12 @@ void button(int x, int y) {
|
|
|
|
upd = true;
|
|
|
|
upd = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (menu == 3) {
|
|
|
|
|
|
|
|
if (x == 1 && y == 1) {
|
|
|
|
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
upd = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
delay(250);
|
|
|
|
delay(250);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -788,3 +815,56 @@ void drawSlider(int data[]) {
|
|
|
|
tft.fillRect(x, y, w, 20, ILI9341_BLACK);
|
|
|
|
tft.fillRect(x, y, w, 20, ILI9341_BLACK);
|
|
|
|
tft.fillRect(x + d, y, 20, 20, ILI9341_GREEN);
|
|
|
|
tft.fillRect(x + d, y, 20, 20, ILI9341_GREEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void drawUD(int data[]) {
|
|
|
|
|
|
|
|
int x = data[0];
|
|
|
|
|
|
|
|
int y = data[1];
|
|
|
|
|
|
|
|
int d = data[2];
|
|
|
|
|
|
|
|
tft.fillTriangle(x + 75, y + 20, x + 90, y - 5, x + 105, y + 20, ILI9341_BLACK);
|
|
|
|
|
|
|
|
tft.fillTriangle(x + 75, y + 30, x + 90, y + 55, x + 105, y + 30, ILI9341_BLACK);
|
|
|
|
|
|
|
|
String out = "";
|
|
|
|
|
|
|
|
out += d;
|
|
|
|
|
|
|
|
out += "%";
|
|
|
|
|
|
|
|
//tft.fillRect(x, y + 15, 70, 25, ILI9341_WHITE);
|
|
|
|
|
|
|
|
tft.drawString(out.c_str(), x, y + 15, 4);
|
|
|
|
|
|
|
|
//tft.fillRect(x + d, y, 20, 20, ILI9341_GREEN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void updUD(int data[]) {
|
|
|
|
|
|
|
|
int x = data[0];
|
|
|
|
|
|
|
|
int y = data[1];
|
|
|
|
|
|
|
|
int d = data[2];
|
|
|
|
|
|
|
|
int xt = 0;
|
|
|
|
|
|
|
|
int yt = 0;
|
|
|
|
|
|
|
|
TSPoint p = ts.getPoint();
|
|
|
|
|
|
|
|
if (p.z > ts.pressureThreshhold) {
|
|
|
|
|
|
|
|
p.x = map(p.x, TS_MINX, TS_MAXX, tft.height(), 0);
|
|
|
|
|
|
|
|
p.y = map(p.y, TS_MINY, TS_MAXY, tft.width(), 0);
|
|
|
|
|
|
|
|
Serial.print("X = "); Serial.print(320 - p.y);
|
|
|
|
|
|
|
|
Serial.print("\tY = "); Serial.print(p.x);
|
|
|
|
|
|
|
|
Serial.print("\tPressure = "); Serial.println(p.z);
|
|
|
|
|
|
|
|
xt = 320 - p.y;
|
|
|
|
|
|
|
|
yt = p.x;
|
|
|
|
|
|
|
|
if (xt >= x + 70 && xt <= x + 110) {
|
|
|
|
|
|
|
|
if (yt <= y + 15 && yt >= y - 20 && d < data[4]) {
|
|
|
|
|
|
|
|
// UP
|
|
|
|
|
|
|
|
data[2] += 20;
|
|
|
|
|
|
|
|
d += 20;
|
|
|
|
|
|
|
|
String out = "";
|
|
|
|
|
|
|
|
out += d;
|
|
|
|
|
|
|
|
out += "%";
|
|
|
|
|
|
|
|
tft.fillRect(x, y + 15, 70, 25, ILI9341_WHITE);
|
|
|
|
|
|
|
|
tft.drawString(out.c_str(), x, y + 15, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (yt >= y + 15 && yt <= y + 50 && d > data[3]) {
|
|
|
|
|
|
|
|
// DOWN
|
|
|
|
|
|
|
|
data[2] -= 20;
|
|
|
|
|
|
|
|
d -= 20;
|
|
|
|
|
|
|
|
String out = "";
|
|
|
|
|
|
|
|
out += d;
|
|
|
|
|
|
|
|
out += "%";
|
|
|
|
|
|
|
|
tft.fillRect(x, y + 15, 70, 25, ILI9341_WHITE);
|
|
|
|
|
|
|
|
tft.drawString(out.c_str(), x, y + 15, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|