time format

This commit is contained in:
Alexander Belov 2024-08-30 00:07:12 +07:00
parent 24b1986dec
commit c402c63f3d

View File

@ -23,7 +23,7 @@ struct Phase {
struct Profile { struct Profile {
const char* name; const char* name;
Phase phases[7]; // Maximum of 6 phases per profile Phase phases[6]; // Maximum of 6 phases per profile
int numPhases; int numPhases;
}; };
@ -32,12 +32,11 @@ Profile profiles[] = {
{"Test", {{49, 1}, {51, 1}, {55, 1}, {45, 1}}, 4}, {"Test", {{49, 1}, {51, 1}, {55, 1}, {45, 1}}, 4},
{"Пшеница", {{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},
{"Profile 4", {{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},
{"Profile 5", {{55, 60}, {65, 120}, {72, 120}, {80, 120}, {90, 30}, {10, 100}}, 6}
}; };
// Select active profile (constant at this point) // Select active profile (constant at this point)
const int activeProfileIndex = 1; // Index of the active profile, starting from 0 const int activeProfileIndex = 0; // Index of the active profile, starting from 0
Profile activeProfile = profiles[activeProfileIndex]; Profile activeProfile = profiles[activeProfileIndex];
// PID Control variables // PID Control variables
@ -140,9 +139,9 @@ void printPhases(int currentPhase, unsigned long phaseElapsedTime) {
oled.print(i + 1); oled.print(i + 1);
oled.print(". "); oled.print(". ");
oled.print((int)Input); oled.print((int)Input);
oled.print("C "); oled.print("c ");
oled.print((int)Setpoint); oled.print((int)Setpoint);
oled.print("C "); oled.print("c ");
oled.print(timeBuffer); oled.print(timeBuffer);
} else { } else {
oled.invertText(false); // Normal text for other phases oled.invertText(false); // Normal text for other phases
@ -152,7 +151,7 @@ void printPhases(int currentPhase, unsigned long phaseElapsedTime) {
oled.print(i + 1); oled.print(i + 1);
oled.print(". "); oled.print(". ");
oled.print(activeProfile.phases[i].temperature); oled.print(activeProfile.phases[i].temperature);
oled.print("C "); oled.print("c ");
oled.print(timeBuffer); oled.print(timeBuffer);
} }
} }
@ -161,13 +160,19 @@ void printPhases(int currentPhase, unsigned long phaseElapsedTime) {
} }
void formatTime(long seconds, char* buffer) { void formatTime(long seconds, char* buffer) {
long hours = seconds / 3600; long hours = seconds / 3600;
long mins = (seconds % 3600) / 60; long mins = (seconds % 3600) / 60;
int secs = seconds % 60; int secs = seconds % 60;
if (hours > 0) { buffer[0] = '\0'; // Ensure the buffer is empty
sprintf(buffer, "%ld:%02ld:%02d", hours, mins, secs);
} else { if (hours > 0) {
sprintf(buffer, "%ld:%02d", mins, secs); sprintf(buffer + strlen(buffer), "%ldh", hours);
} }
if (mins > 0) {
sprintf(buffer + strlen(buffer), "%ldm", mins);
}
if (secs > 0) {
sprintf(buffer + strlen(buffer), "%ds", secs);
}
} }