4
0
Fork 0
mirror of https://github.com/zzzzDev4/IAS-Better-Tea.git synced 2025-04-21 07:31:20 +02:00

add dumb method for change of steeping time

This commit is contained in:
zzzz 2024-06-14 14:59:44 +02:00
parent 568a5e06e1
commit bf7d8037c7

View file

@ -284,7 +284,8 @@ void loop()
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds); String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
Serial.println(payload); Serial.println(payload);
smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", ""); smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", "");
JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload); JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time-log/" + currentTea.m_id, payload);
JSONVar res2 = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload);
// catch possible failure // catch possible failure
if (res == JSON.parse("{}")) if (res == JSON.parse("{}"))
{ {
@ -292,6 +293,12 @@ void loop()
delay(500); delay(500);
break; break;
} }
if (res2 == JSON.parse("{}"))
{
smartDisplay.printMsg("TRY AGAIN");
delay(500);
break;
}
state = State::WAIT_FOR_RFID_SCAN; state = State::WAIT_FOR_RFID_SCAN;
smartStrip.reset(); smartStrip.reset();
break; break;
@ -306,7 +313,8 @@ void loop()
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds); String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
Serial.println(payload); Serial.println(payload);
smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", ""); smartDisplay.playTeaAnimationPartOne(32, "", "Loading...", "", "");
JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload); JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time-log/" + currentTea.m_id, payload);
JSONVar res2 = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload);
// catch possible failure // catch possible failure
if (res == JSON.parse("{}")) if (res == JSON.parse("{}"))
{ {
@ -314,6 +322,12 @@ void loop()
delay(500); delay(500);
break; break;
} }
if (res2 == JSON.parse("{}"))
{
smartDisplay.printMsg("TRY AGAIN");
delay(500);
break;
}
currentTea.m_rfidCode = uid; currentTea.m_rfidCode = uid;
smartDisplay.resetDisplay(); smartDisplay.resetDisplay();
@ -328,7 +342,8 @@ void loop()
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds); String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
Serial.println(payload); Serial.println(payload);
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(perfect)", "", "saving..."); smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(perfect)", "", "saving...");
JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload); JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time-log/" + currentTea.m_id, payload);
JSONVar res2 = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload);
// catch possible failure // catch possible failure
if (res == JSON.parse("{}")) if (res == JSON.parse("{}"))
{ {
@ -336,6 +351,12 @@ void loop()
delay(1000); delay(1000);
break; break;
} }
if (res2 == JSON.parse("{}"))
{
smartDisplay.printMsg("TRY AGAIN");
delay(500);
break;
}
state = State::WAIT_FOR_RFID_SCAN; state = State::WAIT_FOR_RFID_SCAN;
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", ""); smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
smartStrip.reset(); smartStrip.reset();
@ -343,12 +364,18 @@ void loop()
if (buttonLeft.isJustPressed()) if (buttonLeft.isJustPressed())
{ {
// decrease steeping time for next brew // TODO: this should be smarter // decrease steeping time for next brew // TODO: this should be smarter
currentTea.m_steepingSeconds -= 10;
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds); String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
Serial.println(payload); Serial.println(payload);
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(shorter)", "", "saving..."); smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(shorter)", "", "saving...");
JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload); // log old steeping time
JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time-log/" + currentTea.m_id, payload);
// now update steeping time for next use
currentTea.m_steepingSeconds += 10;
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
JSONVar res2 = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload);
// catch possible failure // catch possible failure
if (res == JSON.parse("{}")) if (res == JSON.parse("{}"))
{ {
@ -356,6 +383,12 @@ void loop()
delay(1000); delay(1000);
break; break;
} }
if (res2 == JSON.parse("{}"))
{
smartDisplay.printMsg("TRY AGAIN");
delay(500);
break;
}
state = State::WAIT_FOR_RFID_SCAN; state = State::WAIT_FOR_RFID_SCAN;
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", ""); smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
smartStrip.reset(); smartStrip.reset();
@ -363,13 +396,17 @@ void loop()
if (buttonRight.isJustPressed()) if (buttonRight.isJustPressed())
{ {
// increase steeping time for next brew // TODO: this should be smarter // increase steeping time for next brew // TODO: this should be smarter
currentTea.m_steepingSeconds += 10;
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds); String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
Serial.println(payload); Serial.println(payload);
smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(longer)", "", "saving..."); smartDisplay.playTeaAnimationPartOne(32, "Accepted!", "(longer)", "", "saving...");
JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload); JSONVar res = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time-log/" + currentTea.m_id, payload);
// now update steeping time for next use
currentTea.m_steepingSeconds -= 10;
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
JSONVar res2 = teaNet.httpsPOSTRequest(shuttleServer + "/tea-steeping-time/" + currentTea.m_id, payload);
// catch possible failure // catch possible failure
if (res == JSON.parse("{}")) if (res == JSON.parse("{}"))
{ {
@ -377,6 +414,12 @@ void loop()
delay(1000); delay(1000);
break; break;
} }
if (res2 == JSON.parse("{}"))
{
smartDisplay.printMsg("TRY AGAIN");
delay(500);
break;
}
state = State::WAIT_FOR_RFID_SCAN; state = State::WAIT_FOR_RFID_SCAN;
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", ""); smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
smartStrip.reset(); smartStrip.reset();