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
.idea*

View File

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