add humidity and temp range control, bump version to 0.4.1

master
cd109876 5 years ago
parent 850e5a4981
commit 5ecbc64959

@ -160,7 +160,7 @@ boolean s1, s2, s3, s4;
String outtext2 = "";
int linecount = 0;
int brightness = 255;
int uda[] = {200, 30, 20, 20, 300};
int uda[] = {45, 70, 20, 20, 300};
int sla[] = {10, 90, 300, 280};
int go = true;
int trange[] = {60, 100};
@ -174,6 +174,15 @@ int ud2[] = {200, 50, uda[2], 20, 300};
int ud3[] = {200, 50, uda[2], 20, 300};
int ud4[] = {200, 50, uda[2], 20, 300};
int dispbox = 0;
int udd1[] = {45, 30, 90, 0, 100};
int udd2[] = {45, 65, 80, 0, 100};
int udd3[] = {45 + 160, 30, 85, 40, 150};
int udd4[] = {45 + 160, 65, 65, 40, 150};
boolean daytime = true;
int udn1[] = {45, 30, 75, 0, 100};
int udn2[] = {45, 65, 65, 0, 100};
int udn3[] = {45 + 160, 30, 80, 40, 150};
int udn4[] = {45 + 160, 65, 65, 40, 150};
void setup(void) {
batteryupd.Every(10000, checkBat);
@ -230,7 +239,7 @@ void setup(void) {
}
clearLog();
printFastCText("Booting GreenhouseOS...");
printFastCText("Version: 0.3.7");
printFastCText("Version: 0.4.1");
printFastCText("");
delay(250);
if(!didDraw) {
@ -316,7 +325,20 @@ void loop(void) {
}
if(menu == 3) {
updUD(uda);
}
if(menu == 4) {
if(daytime) {
hmupdUD(udd1);
hupdUD(udd2);
tmupdUD(udd3);
tupdUD(udd4);
}
else {
hmupdUD(udn1);
hupdUD(udn2);
tmupdUD(udn3);
tupdUD(udn4);
}
}
if (x < 160 && y < 130) {
button(0, 0);
@ -490,7 +512,29 @@ void loop(void) {
drawButton(85, 190, 70, 45, "4", ILI9341_RED);
}
}
displayText(15, 45, false, "Water amount:", 4);
displayText(15, 25, false, "Water", 4);
displayText(15, 55, false, "amount:", 4);
drawButton(160, 20, 160, 110, "Page 2", ILI9341_ORANGE);
}
if (menu == 4) {
drawButton(160, 130, 160, 110, "Back", ILI9341_BLUE);
if(daytime) {
drawButton(0, 20, 320, 110, "", ILI9341_CYAN);
drawButton(0, 130, 160, 110, "Night Mode", ILI9341_ORANGE);
drawMirrorUD(udd1);
drawUD(udd2);
tdrawMirrorUD(udd3);
tdrawUD(udd4);
}
else {
drawButton(0, 20, 320, 110, "", ILI9341_DARKCYAN);
drawButton(0, 130, 160, 110, "Day Mode", ILI9341_ORANGE);
drawMirrorUD(udn1);
drawUD(udn2);
tdrawMirrorUD(udn3);
tdrawUD(udn4);
}
}
upd = false;
}
@ -531,7 +575,17 @@ void checkBat() {
if (digitalRead(35) == 0) drawButton(140, 2, 16, 16, "", ILI9341_ORANGE);
if (digitalRead(36) == 0) drawButton(140, 2, 16, 16, "", ILI9341_YELLOW);
if (digitalRead(37) == 0) drawButton(140, 2, 16, 16, "", ILI9341_GREEN);
if(analogRead(1) > 910) {
trange[0] = udd4[2];
trange[1] = udd3[2];
hrange[0] = udd2[2];
hrange[1] = udd1[2];
} else {
trange[0] = udn4[2];
trange[1] = udn3[2];
hrange[0] = udn2[2];
hrange[1] = udn1[2];
}
float h = dht.readHumidity();
float f = dht.readTemperature(true);
@ -966,6 +1020,11 @@ void button(int x, int y) {
updBoxMenu(4);
delay(125);
}
if (x == 1 && y == 0) {
menu = 4;
daytime = true;
upd = true;
}
TSPoint p = ts.getPoint();
p.x = map(p.x, TS_MINX, TS_MAXX, tft.height(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.width(), 0);
@ -990,6 +1049,18 @@ void button(int x, int y) {
updBoxMenu(4);
}
}
else if (menu == 4) {
if (x == 1 && y == 1) {
menu = 3;
upd = true;
delay(125);
}
if (x == 0 && y == 1) {
daytime = !daytime;
upd = true;
delay(125);
}
}
// skip 4 lol, oops
else if (menu == 5) {
if (x == 1 && y == 0) {
@ -1054,6 +1125,51 @@ void drawUD(int data[]) {
tft.drawString(out.c_str(), x, y + 15, 4);
//tft.fillRect(x + d, y, 20, 20, ILI9341_GREEN);
}
void drawMirrorUD(int data[]) {
int x = data[0];
int y = data[1];
int d = data[2];
tft.fillTriangle(x - 40, y + 20, x - 25, y - 5, x - 10, y + 20, ILI9341_BLACK);
tft.fillTriangle(x - 40, y + 30, x - 25, y + 55, x - 10, 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 tdrawUD(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;
//tft.fillRect(x, y + 15, 70, 25, ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
tft.drawCircle(x + 40, y + 18, 3, ILI9341_BLACK);
tft.drawString("F", x + 43, y + 15, 4);
//tft.fillRect(x + d, y, 20, 20, ILI9341_GREEN);
}
void tdrawMirrorUD(int data[]) {
int x = data[0];
int y = data[1];
int d = data[2];
tft.fillTriangle(x - 40, y + 20, x - 25, y - 5, x - 10, y + 20, ILI9341_BLACK);
tft.fillTriangle(x - 40, y + 30, x - 25, y + 55, x - 10, y + 30, ILI9341_BLACK);
String out = "";
out += d;
//tft.fillRect(x, y + 15, 70, 25, ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
tft.drawCircle(x + 40, y + 18, 3, ILI9341_BLACK);
tft.drawString("F", x + 43, y + 15, 4);
//tft.fillRect(x + d, y, 20, 20, ILI9341_GREEN);
}
void updUD(int data[]) {
int x = data[0];
int y = data[1];
@ -1094,6 +1210,173 @@ void updUD(int data[]) {
}
}
void hupdUD(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 - 30 && d < data[4]) {
// UP
data[2] += 5;
d += 5;
String out = "";
out += d;
out += "%";
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
}
else if (yt >= y + 15 && yt <= y + 60 && d > data[3]) {
// DOWN
data[2] -= 5;
d -= 5;
String out = "";
out += d;
out += "%";
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
}
}
}
}
void hmupdUD(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 - 40 && xt <= x - 10) {
if (yt <= y + 15 && yt >= y - 30 && d < data[4]) {
// UP
data[2] += 5;
d += 5;
String out = "";
out += d;
out += "%";
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
}
else if (yt >= y + 15 && yt <= y + 60 && d > data[3]) {
// DOWN
data[2] -= 5;
d -= 5;
String out = "";
out += d;
out += "%";
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
}
}
}
}
void tupdUD(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 - 30 && d < data[4]) {
// UP
data[2] += 5;
d += 5;
String out = "";
out += d;
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
tft.drawCircle(x + 40, y + 18, 3, ILI9341_BLACK);
tft.drawString("F", x + 43, y + 15, 4);
}
else if (yt >= y + 15 && yt <= y + 60 && d > data[3]) {
// DOWN
data[2] -= 5;
d -= 5;
String out = "";
out += d;
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
tft.drawCircle(x + 40, y + 18, 3, ILI9341_BLACK);
tft.drawString("F", x + 43, y + 15, 4);
}
}
}
}
void tmupdUD(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 - 40 && xt <= x - 10) {
if (yt <= y + 15 && yt >= y - 30 && d < data[4]) {
// UP
data[2] += 5;
d += 5;
String out = "";
out += d;
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
tft.drawCircle(x + 40, y + 18, 3, ILI9341_BLACK);
tft.drawString("F", x + 43, y + 15, 4);
}
else if (yt >= y + 15 && yt <= y + 60 && d > data[3]) {
// DOWN
data[2] -= 5;
d -= 5;
String out = "";
out += d;
drawButton(x, y + 15, 70, 25, "", ILI9341_WHITE);
tft.drawString(out.c_str(), x, y + 15, 4);
tft.drawCircle(x + 40, y + 18, 3, ILI9341_BLACK);
tft.drawString("F", x + 43, y + 15, 4);
}
}
}
}
boolean touch(int x, int y, int w, int h, TSPoint p) {
int xt = 320 - p.y;
int yt = p.x;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save