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:
parent
568a5e06e1
commit
bf7d8037c7
1 changed files with 51 additions and 8 deletions
59
src/main.cpp
59
src/main.cpp
|
@ -284,7 +284,8 @@ void loop()
|
|||
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
|
||||
Serial.println(payload);
|
||||
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
|
||||
if (res == JSON.parse("{}"))
|
||||
{
|
||||
|
@ -292,6 +293,12 @@ void loop()
|
|||
delay(500);
|
||||
break;
|
||||
}
|
||||
if (res2 == JSON.parse("{}"))
|
||||
{
|
||||
smartDisplay.printMsg("TRY AGAIN");
|
||||
delay(500);
|
||||
break;
|
||||
}
|
||||
state = State::WAIT_FOR_RFID_SCAN;
|
||||
smartStrip.reset();
|
||||
break;
|
||||
|
@ -306,7 +313,8 @@ void loop()
|
|||
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
|
||||
Serial.println(payload);
|
||||
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
|
||||
if (res == JSON.parse("{}"))
|
||||
{
|
||||
|
@ -314,6 +322,12 @@ void loop()
|
|||
delay(500);
|
||||
break;
|
||||
}
|
||||
if (res2 == JSON.parse("{}"))
|
||||
{
|
||||
smartDisplay.printMsg("TRY AGAIN");
|
||||
delay(500);
|
||||
break;
|
||||
}
|
||||
|
||||
currentTea.m_rfidCode = uid;
|
||||
smartDisplay.resetDisplay();
|
||||
|
@ -328,7 +342,8 @@ void loop()
|
|||
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
|
||||
Serial.println(payload);
|
||||
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
|
||||
if (res == JSON.parse("{}"))
|
||||
{
|
||||
|
@ -336,6 +351,12 @@ void loop()
|
|||
delay(1000);
|
||||
break;
|
||||
}
|
||||
if (res2 == JSON.parse("{}"))
|
||||
{
|
||||
smartDisplay.printMsg("TRY AGAIN");
|
||||
delay(500);
|
||||
break;
|
||||
}
|
||||
state = State::WAIT_FOR_RFID_SCAN;
|
||||
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
|
||||
smartStrip.reset();
|
||||
|
@ -343,12 +364,18 @@ void loop()
|
|||
if (buttonLeft.isJustPressed())
|
||||
{
|
||||
// decrease steeping time for next brew // TODO: this should be smarter
|
||||
currentTea.m_steepingSeconds -= 10;
|
||||
|
||||
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
|
||||
Serial.println(payload);
|
||||
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
|
||||
if (res == JSON.parse("{}"))
|
||||
{
|
||||
|
@ -356,6 +383,12 @@ void loop()
|
|||
delay(1000);
|
||||
break;
|
||||
}
|
||||
if (res2 == JSON.parse("{}"))
|
||||
{
|
||||
smartDisplay.printMsg("TRY AGAIN");
|
||||
delay(500);
|
||||
break;
|
||||
}
|
||||
state = State::WAIT_FOR_RFID_SCAN;
|
||||
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
|
||||
smartStrip.reset();
|
||||
|
@ -363,13 +396,17 @@ void loop()
|
|||
if (buttonRight.isJustPressed())
|
||||
{
|
||||
// increase steeping time for next brew // TODO: this should be smarter
|
||||
currentTea.m_steepingSeconds += 10;
|
||||
|
||||
|
||||
String payload = teaNet.bundleSteepingTimeChange(currentTea.m_steepingSeconds);
|
||||
Serial.println(payload);
|
||||
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
|
||||
if (res == JSON.parse("{}"))
|
||||
{
|
||||
|
@ -377,6 +414,12 @@ void loop()
|
|||
delay(1000);
|
||||
break;
|
||||
}
|
||||
if (res2 == JSON.parse("{}"))
|
||||
{
|
||||
smartDisplay.printMsg("TRY AGAIN");
|
||||
delay(500);
|
||||
break;
|
||||
}
|
||||
state = State::WAIT_FOR_RFID_SCAN;
|
||||
smartDisplay.playTeaAnimationPartTwo(32, "", "Done!", "", "");
|
||||
smartStrip.reset();
|
||||
|
|
Loading…
Add table
Reference in a new issue