writing to eeprom, oled disabled buffer works better
This commit is contained in:
parent
dc659929dd
commit
de4af97026
@ -3,6 +3,7 @@
|
|||||||
#include <PID_v1.h>
|
#include <PID_v1.h>
|
||||||
#include <GyverOLED.h>
|
#include <GyverOLED.h>
|
||||||
#include "GyverEncoder.h" // Include the GyverEncoder library
|
#include "GyverEncoder.h" // Include the GyverEncoder library
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
// MAX6675 configuration
|
// MAX6675 configuration
|
||||||
int max_SO = 12;
|
int max_SO = 12;
|
||||||
@ -11,7 +12,8 @@ int max_SCK = 13;
|
|||||||
MAX6675 thermocouple(max_SCK, max_CS, max_SO);
|
MAX6675 thermocouple(max_SCK, max_CS, max_SO);
|
||||||
|
|
||||||
// OLED configuration
|
// OLED configuration
|
||||||
GyverOLED<SSD1306_128x64> oled;
|
// GyverOLED<SSD1306_128x64> oled;
|
||||||
|
GyverOLED<SSD1306_128x64, OLED_NO_BUFFER> oled;
|
||||||
|
|
||||||
// Encoder configuration
|
// Encoder configuration
|
||||||
#define CLK 5
|
#define CLK 5
|
||||||
@ -66,6 +68,7 @@ long totalElapsedTime;
|
|||||||
long totalProcessTime;
|
long totalProcessTime;
|
||||||
long finishTime = 0;
|
long finishTime = 0;
|
||||||
long currentTime = 0;
|
long currentTime = 0;
|
||||||
|
long lastEEPROMWriteTime = 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
|
||||||
|
|
||||||
@ -94,6 +97,10 @@ void handleExecution() {
|
|||||||
currentTime = millis();
|
currentTime = millis();
|
||||||
totalElapsedTime = (currentTime - totalStartTime) / 1000; // Total elapsed time in seconds
|
totalElapsedTime = (currentTime - totalStartTime) / 1000; // Total elapsed time in seconds
|
||||||
|
|
||||||
|
if ((currentTime - lastEEPROMWriteTime) >= (unsigned int) 10*60*1000) {
|
||||||
|
writeEEPROM();
|
||||||
|
}
|
||||||
|
|
||||||
getPhaseAndTemperature();
|
getPhaseAndTemperature();
|
||||||
|
|
||||||
Input = thermocouple.readCelsius();
|
Input = thermocouple.readCelsius();
|
||||||
@ -144,10 +151,12 @@ void handleProfileSelection() {
|
|||||||
calculateTotalTime();
|
calculateTotalTime();
|
||||||
inSelectionMode = false; // Switch to execution mode
|
inSelectionMode = false; // Switch to execution mode
|
||||||
phaseStartTime = totalStartTime = millis(); // Start the timer
|
phaseStartTime = totalStartTime = millis(); // Start the timer
|
||||||
|
totalElapsedTime = 0;
|
||||||
myPID.SetMode(AUTOMATIC);
|
myPID.SetMode(AUTOMATIC);
|
||||||
myPID.SetOutputLimits(0, 1); // SSR is either ON or OFF
|
myPID.SetOutputLimits(0, 1); // SSR is either ON or OFF
|
||||||
digitalWrite(ssrPin, HIGH); // Start with heater on
|
// digitalWrite(ssrPin, HIGH); // Start with heater on
|
||||||
ssrLastSwitchTime = millis();
|
ssrLastSwitchTime = millis();
|
||||||
|
writeEEPROM();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +247,10 @@ void printPhases() {
|
|||||||
formatTime((currentTime - finishTime) / 1000, timeBuffer); // Time since completion
|
formatTime((currentTime - finishTime) / 1000, timeBuffer); // Time since completion
|
||||||
oled.print(timeBuffer);
|
oled.print(timeBuffer);
|
||||||
oled.print(" ");
|
oled.print(" ");
|
||||||
oled.print((int)Input);
|
oled.print(Input,1);
|
||||||
|
oled.print("c");
|
||||||
|
oled.print("->");
|
||||||
|
oled.print((int)Setpoint);
|
||||||
oled.print("c");
|
oled.print("c");
|
||||||
} else {
|
} else {
|
||||||
oled.setCursor(0, 0);
|
oled.setCursor(0, 0);
|
||||||
@ -305,3 +317,13 @@ void formatTime(long seconds, char* buffer) {
|
|||||||
sprintf(buffer + strlen(buffer), "%ds", secs);
|
sprintf(buffer + strlen(buffer), "%ds", secs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeEEPROM() {
|
||||||
|
lastEEPROMWriteTime = millis();
|
||||||
|
EEPROM.put(0, activeProfileIndex); // Store the active profile index
|
||||||
|
EEPROM.put(4, totalElapsedTime); // Store the total elapsed time
|
||||||
|
Serial.print("EEPROM written: ");
|
||||||
|
Serial.print(activeProfileIndex);
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println(totalElapsedTime);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user