completion text and time since finish + temp

This commit is contained in:
Alexander Belov 2024-08-30 00:23:18 +07:00
parent 505db01de1
commit 8ec2f57e15

View File

@ -29,7 +29,7 @@ struct Profile {
// Profiles definition // Profiles definition
Profile profiles[] = { Profile profiles[] = {
{"Test", {{49, 1}, {51, 1}, {55, 1}, {45, 1}}, 4}, {"Test", {{49, 1}, {51, 1}}, 2},
{"Пшеница", {{47, 40}, {55, 40}, {65, 20}, {72, 20}, {85, 20}}, 5}, {"Пшеница", {{47, 40}, {55, 40}, {65, 20}, {72, 20}, {85, 20}}, 5},
{"Veggies Sous Vide", {{85, 120}}, 1}, {"Veggies Sous Vide", {{85, 120}}, 1},
{"Фитаза/Протеаза", {{47, 120}, {53, 120}, {65, 150}, {72, 60}, {90, 105}, {50, 60}}, 6}, {"Фитаза/Протеаза", {{47, 120}, {53, 120}, {65, 150}, {72, 60}, {90, 105}, {50, 60}}, 6},
@ -50,6 +50,8 @@ unsigned long totalStartTime;
unsigned long ssrLastSwitchTime; unsigned long ssrLastSwitchTime;
unsigned long totalElapsedTime; unsigned long totalElapsedTime;
unsigned long totalProcessTime; unsigned long totalProcessTime;
unsigned long finishTime = 0;
bool isComplete = false;
const int ssrSwitchInterval = 1000; // SSR switching interval in milliseconds const int ssrSwitchInterval = 1000; // SSR switching interval in milliseconds
// Buffer for formatted time strings // Buffer for formatted time strings
@ -95,32 +97,46 @@ void loop() {
} }
// Check if the phase duration is complete // Check if the phase duration is complete
if ((unsigned long)((currentTime - phaseStartTime) / 1000) >= (unsigned long)activeProfile.phases[currentPhase].duration * 60) { if (!isComplete && (unsigned long)((currentTime - phaseStartTime) / 1000) >= (unsigned long)activeProfile.phases[currentPhase].duration * 60) {
currentPhase++; currentPhase++;
if (currentPhase >= activeProfile.numPhases) { if (currentPhase >= activeProfile.numPhases) {
oled.clear(); isComplete = true;
oled.print("Complete"); finishTime = currentTime;
Setpoint = 45; // Set target temperature to 45°C
digitalWrite(ssrPin, LOW); // Turn off the heater digitalWrite(ssrPin, LOW); // Turn off the heater
return; // Stop further execution } else {
phaseStartTime = currentTime; // Reset the start time for the new phase
Setpoint = activeProfile.phases[currentPhase].temperature;
} }
phaseStartTime = currentTime; // Reset the start time for the new phase
Setpoint = activeProfile.phases[currentPhase].temperature;
} }
// Display all phases and highlight the current one // Display all phases and highlight the current one
printPhases(currentPhase, currentTime - phaseStartTime); printPhases(currentPhase, currentTime - phaseStartTime, currentTime);
oled.update(); oled.update();
delay(1000); // Update every second delay(1000); // Update every second
} }
void printPhases(int currentPhase, unsigned long phaseElapsedTime) { void printPhases(int currentPhase, unsigned long phaseElapsedTime, unsigned long currentTime) {
oled.clear(); oled.clear();
oled.setCursor(0, 0); if (isComplete) {
oled.print(activeProfile.name); // Show completion time and current temperature instead of the title
oled.setCursor(0, 0);
oled.invertText(true);
oled.print("Done! ");
formatTime((currentTime - finishTime) / 1000, timeBuffer); // Time since completion
oled.print(timeBuffer);
oled.print(" ");
oled.print((int)Input);
oled.print("c");
oled.invertText(false);
} else {
oled.setCursor(0, 0);
oled.print(activeProfile.name);
}
// Display the totals and current state on the OLED // Display the totals and current state on the OLED
oled.setCursor(18, 1); oled.setCursor(18, 1);
formatTime(totalElapsedTime, timeBuffer); formatTime(totalElapsedTime, timeBuffer);
@ -130,7 +146,7 @@ void printPhases(int currentPhase, unsigned long phaseElapsedTime) {
oled.print(timeBuffer); oled.print(timeBuffer);
for (int i = 0; i < activeProfile.numPhases; i++) { for (int i = 0; i < activeProfile.numPhases; i++) {
if (i == currentPhase) { if (i == currentPhase && !isComplete) {
oled.invertText(true); // Invert text for the current phase oled.invertText(true); // Invert text for the current phase
oled.setCursor(0, i + 2); // Set cursor to the row corresponding to the phase oled.setCursor(0, i + 2); // Set cursor to the row corresponding to the phase