polishing

This commit is contained in:
Alexander Belov 2024-08-31 01:46:02 +07:00
parent f23b6c3938
commit 589d8ea8f2
2 changed files with 12 additions and 10 deletions

View File

@ -1,7 +1,4 @@
## TODO ## TODO
* check the ai suggestion
* time after completion is not displayed
* eeprom saving every 5 minutes and resuming * eeprom saving every 5 minutes and resuming
* profile selection

View File

@ -65,6 +65,7 @@ unsigned long ssrLastSwitchTime;
unsigned long totalElapsedTime; unsigned long totalElapsedTime;
unsigned long totalProcessTime; unsigned long totalProcessTime;
unsigned long finishTime = 0; unsigned long finishTime = 0;
unsigned long currentTime = 0;
bool isComplete = false; bool isComplete = false;
const int ssrSwitchInterval = 1000; // SSR switching interval in milliseconds const int ssrSwitchInterval = 1000; // SSR switching interval in milliseconds
@ -85,12 +86,15 @@ void loop() {
if (inSelectionMode) { if (inSelectionMode) {
handleProfileSelection(); // Handle profile selection mode handleProfileSelection(); // Handle profile selection mode
} else { } else {
unsigned long currentTime = millis(); currentTime = millis();
totalElapsedTime = (currentTime - totalStartTime) / 1000; // Total elapsed time in seconds totalElapsedTime = (currentTime - totalStartTime) / 1000; // Total elapsed time in seconds
getPhaseAndTemperature(totalElapsedTime); getPhaseAndTemperature(totalElapsedTime);
Input = (int) thermocouple.readCelsius(); // Cast to integer for display and control Input = thermocouple.readCelsius();
if (isnan(Input)) {
Input = 0;
}
myPID.Compute(); myPID.Compute();
// Switch SSR based on PID output and interval control // Switch SSR based on PID output and interval control
@ -99,12 +103,12 @@ void loop() {
ssrLastSwitchTime = currentTime; ssrLastSwitchTime = currentTime;
} }
if (isComplete && currentPhase >= activeProfile.numPhases) { if (isComplete && currentPhase >= activeProfile.numPhases && !finishTime) {
finishTime = currentTime; finishTime = currentTime;
} }
// Display all phases and highlight the current one // Display all phases and highlight the current one
printPhases(currentPhase, currentTime - phaseStartTime, currentTime); printPhases();
oled.update(); oled.update();
@ -213,7 +217,7 @@ void getPhaseAndTemperature(unsigned long elapsedSeconds) {
isComplete = true; // Mark the process as complete isComplete = true; // Mark the process as complete
} }
void printPhases(int currentPhase, unsigned long phaseElapsedTime, unsigned long currentTime) { void printPhases() {
oled.clear(); oled.clear();
if (isComplete) { if (isComplete) {
@ -241,16 +245,17 @@ void printPhases(int currentPhase, unsigned long phaseElapsedTime, unsigned long
formatTime(totalProcessTime, timeBuffer); formatTime(totalProcessTime, timeBuffer);
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 && !isComplete) { 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
unsigned long timeRemaining = (activeProfile.phases[i].duration * 60) - (phaseElapsedTime / 1000); unsigned long timeRemaining = (activeProfile.phases[i].duration * 60) - ((currentTime - phaseStartTime) / 1000);
formatTime(timeRemaining, timeBuffer); formatTime(timeRemaining, timeBuffer);
oled.print(i + 1); oled.print(i + 1);
oled.print(". "); oled.print(". ");
oled.print((int)Input); oled.print(Input, 1);
oled.print("c "); oled.print("c ");
if (fabs(Setpoint - round(Setpoint)) < 0.05) { if (fabs(Setpoint - round(Setpoint)) < 0.05) {
oled.print((int)Setpoint); // Print without decimals oled.print((int)Setpoint); // Print without decimals