diff --git a/hot_fermentation.ino b/hot_fermentation.ino index 82557df..419e4f2 100644 --- a/hot_fermentation.ino +++ b/hot_fermentation.ino @@ -83,21 +83,16 @@ int currentPhase; bool isInTransition = false; bool inSelectionMode = true; -// PID Control variables -// double Kp = 0.5, Ki = 1, Kd = 0.05; -// PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT); - // #include "GyverPID.h" #include "pid.h" double Setpoint, Input, Output; -GyverPID regulator(10, 2, 10, 1000); +GyverPID regulator(50, 1, 0, 1000); bool temperatureSensorError = false; // Timing variables long phaseStartTime; long totalStartTime; -long ssrLastSwitchTime; long totalElapsedTime; long totalProcessTime; long finishTime = 0; @@ -107,7 +102,6 @@ bool isClick = false; bool isLeft = false; bool isRight = false; bool isComplete = false; -const int ssrSwitchInterval = 1000; // SSR switching interval in milliseconds // Buffer for formatted time strings char timeBuffer[10]; @@ -117,8 +111,6 @@ bool boolLastCompletedState = false; float failedReadingLastValue = 0; int failedReadingCount = 0; -#define PARTS 8 - void setup() { pinMode(activeBuzzerPin, OUTPUT); Serial.begin(9600); diff --git a/t_encoder.ino b/t_encoder.ino index a303cc8..e36b2ba 100644 --- a/t_encoder.ino +++ b/t_encoder.ino @@ -1,4 +1,6 @@ -LP_THREAD({ +LP_TIMER(10, checkEncoder); + +void checkEncoder() { enc1.tick(); isLeft = enc1.isLeft(); isRight = enc1.isRight(); @@ -13,8 +15,7 @@ LP_THREAD({ else { handleExecutionSelection(); } - LP_DELAY(10); -}); +} void handleExecutionSelection() { if (isClick) { diff --git a/t_main.ino b/t_main.ino index 498cd06..3beb117 100644 --- a/t_main.ino +++ b/t_main.ino @@ -90,8 +90,6 @@ void startExecution() { phaseStartTime = totalStartTime = millis(); // Start the timer totalElapsedTime = 0; regulator.setpoint = 0; - // digitalWrite(ssrPin, HIGH); // Start with heater on - ssrLastSwitchTime = millis(); calculateTotalTime(); getPhaseAndTemperature(); writeEEPROM();