oled changed

This commit is contained in:
Alexander Belov 2024-08-29 23:01:32 +07:00
parent d52e559ef4
commit 12f478271f
2 changed files with 30 additions and 25 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.swp *.swp
.idea*

View File

@ -1,7 +1,7 @@
#include <LiquidCrystal_I2C.h>
#include <max6675.h> #include <max6675.h>
#include <Wire.h> #include <Wire.h>
#include <PID_v1.h> #include <PID_v1.h>
#include <GyverOLED.h> // Include the GyverOLED library
// MAX6675 configuration // MAX6675 configuration
int max_SO = 12; int max_SO = 12;
@ -9,8 +9,8 @@ int max_CS = 10;
int max_SCK = 13; int max_SCK = 13;
MAX6675 thermocouple(max_SCK, max_CS, max_SO); MAX6675 thermocouple(max_SCK, max_CS, max_SO);
// LCD configuration via I2C // OLED configuration
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address GyverOLED<SSD1306_128x64, OLED_BUFFER> oled;
// SSR pin configuration // SSR pin configuration
const int ssrPin = 7; const int ssrPin = 7;
@ -53,10 +53,13 @@ const int ssrSwitchInterval = 1000; // SSR switching interval in milliseconds
void setup() { void setup() {
pinMode(ssrPin, OUTPUT); pinMode(ssrPin, OUTPUT);
Serial.begin(9600); Serial.begin(9600);
lcd.init(); oled.init(); // Initialize the OLED
lcd.backlight(); oled.clear(); // Clear the display
lcd.print("Starting..."); oled.setScale(2); // Set text scale to 2 for better visibility
oled.print("Starting...");
oled.update();
delay(2000); delay(2000);
oled.setScale(0); // Set text scale to 2 for better visibility
// Begin the first phase // Begin the first phase
phaseStartTime = totalStartTime = millis(); phaseStartTime = totalStartTime = millis();
@ -91,8 +94,8 @@ void loop() {
if ((currentTime - phaseStartTime) / 1000 >= phaseDurations[currentPhase] * 60) { if ((currentTime - phaseStartTime) / 1000 >= phaseDurations[currentPhase] * 60) {
currentPhase++; currentPhase++;
if (currentPhase >= numPhases) { if (currentPhase >= numPhases) {
lcd.clear(); oled.clear();
lcd.print("Complete"); oled.print("Complete");
digitalWrite(ssrPin, LOW); // Turn off the heater digitalWrite(ssrPin, LOW); // Turn off the heater
return; // Stop further execution return; // Stop further execution
} }
@ -100,22 +103,23 @@ void loop() {
Setpoint = temperatures[currentPhase]; Setpoint = temperatures[currentPhase];
} }
// Display data on the LCD // Display data on the OLED
lcd.clear(); oled.clear();
lcd.setCursor(0, 0); oled.setCursor(0, 0);
lcd.print(formatTime(totalElapsedTime)); oled.print(formatTime(totalElapsedTime));
lcd.print(" ("); oled.print(" (");
lcd.print(formatTime(totalProcessTime)); oled.print(formatTime(totalProcessTime));
lcd.print(")"); oled.print(")");
lcd.setCursor(0, 1); oled.setCursor(0, 1);
lcd.print(currentPhase + 1); oled.print(currentPhase + 1);
lcd.print(". "); oled.print(". ");
lcd.print((int)Input); oled.print((int)Input);
lcd.print("C "); oled.print("C ");
lcd.print((int)Setpoint); oled.print((int)Setpoint);
lcd.print("C "); oled.print("C ");
lcd.print(formatTime((phaseDurations[currentPhase] * 60) - ((currentTime - phaseStartTime) / 1000))); oled.print(formatTime((phaseDurations[currentPhase] * 60) - ((currentTime - phaseStartTime) / 1000)));
oled.update();
delay(1000); // Update every second delay(1000); // Update every second
} }