From 294bd943a405e5c637fab7e7f2b40ed5788b4f2a Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Sat, 2 Oct 2021 12:23:07 +0100 Subject: [PATCH] use enum for machinestate (rebased) --- .../rancilio-pid/Displaytemplateminimal.h | 16 +- .../rancilio-pid/Displaytemplatescale.h | 10 +- .../rancilio-pid/Displaytemplatestandard.h | 10 +- .../rancilio-pid/Displaytemplatetemponly.h | 10 +- .../rancilio-pid/Displaytemplateupright.h | 10 +- rancilio-pid/rancilio-pid/display.h | 20 +- rancilio-pid/rancilio-pid/rancilio-pid.ino | 240 +++++++++--------- 7 files changed, 163 insertions(+), 153 deletions(-) diff --git a/rancilio-pid/rancilio-pid/Displaytemplateminimal.h b/rancilio-pid/rancilio-pid/Displaytemplateminimal.h index fe7c2d2dd..c756ae2f1 100644 --- a/rancilio-pid/rancilio-pid/Displaytemplateminimal.h +++ b/rancilio-pid/rancilio-pid/Displaytemplateminimal.h @@ -5,15 +5,21 @@ void printScreen() { unsigned long currentMillisDisplay = millis(); if ( - (machinestate == 19 || machinestate == 20 || machinestate == 35) || - ((machinestate == 30 || machinestate == 31) && SHOTTIMER == 0) || // shottimer == 0, auch Bezug anzeigen - machinestate == 45 || - ((machinestate == 10) && HEATINGLOGO == 0) || - ((machinestate == 90) && OFFLINEGLOGO == 0)) + (machinestate == kSetPointNegative || machinestate == kPidNormal || machinestate == kBrewDetectionTrailing) || + ((machinestate == kBrew || machinestate == kShotTimerAfterBrew) && SHOTTIMER == 0) || // shottimer == 0, auch Bezug anzeigen + machinestate == kCoolDown || + ((machinestate == kColdStart) && HEATINGLOGO == 0) || + ((machinestate == kPidOffline) && OFFLINEGLOGO == 0)) { if (!sensorError) { u8g2.clearBuffer(); + //draw outline frame + //u8g2.drawFrame(0, 0, 128, 64); + // Draw heat bar outline + u8g2.drawFrame(15, 58, 102, 4); + u8g2.drawLine(16, 59, (Output / 10) + 16, 59); + u8g2.drawLine(16, 60, (Output / 10) + 16, 60); // Draw heat bar outline u8g2.drawFrame(15, 58, 102, 4); diff --git a/rancilio-pid/rancilio-pid/Displaytemplatescale.h b/rancilio-pid/rancilio-pid/Displaytemplatescale.h index 55de44479..7fcdee689 100644 --- a/rancilio-pid/rancilio-pid/Displaytemplatescale.h +++ b/rancilio-pid/rancilio-pid/Displaytemplatescale.h @@ -4,11 +4,11 @@ void printScreen() unsigned long currentMillisDisplay = millis(); if ( - (machinestate == 19 || machinestate == 20 || machinestate == 35) || - ((machinestate == 30 || machinestate == 31) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen - machinestate == 45 || - ((machinestate == 0 || machinestate == 10 ) && HEATINGLOGO == 0) || - ((machinestate == 90) && OFFLINEGLOGO == 0) + (machinestate == kSetPointNegative || machinestate == kPidNormal || machinestate == kBrewDetectionTrailing) || + ((machinestate == kBrew || machinestate == kShotTimerAfterBrew) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen + machinestate == kCoolDown || + ((machinestate == kInit || machinestate == kColdStart ) && HEATINGLOGO == 0) || + ((machinestate == kPidOffline) && OFFLINEGLOGO == 0) ) { u8g2.clearBuffer(); diff --git a/rancilio-pid/rancilio-pid/Displaytemplatestandard.h b/rancilio-pid/rancilio-pid/Displaytemplatestandard.h index 64a11510f..c2b8f2c77 100644 --- a/rancilio-pid/rancilio-pid/Displaytemplatestandard.h +++ b/rancilio-pid/rancilio-pid/Displaytemplatestandard.h @@ -10,11 +10,11 @@ void printScreen() unsigned long currentMillisDisplay = millis(); if ( - (machinestate == 19 || machinestate == 20 || machinestate == 35) || - ((machinestate == 30 || machinestate == 31) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen - machinestate == 45 || - ((machinestate == 0 || machinestate == 10 ) && HEATINGLOGO == 0) || - ((machinestate == 90) && OFFLINEGLOGO == 0) + (machinestate == kSetPointNegative || machinestate == kPidNormal || machinestate == kBrewDetectionTrailing) || + ((machinestate == kBrew || machinestate == kShotTimerAfterBrew) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen + machinestate == kCoolDown || + ((machinestate == kInit || machinestate == kColdStart ) && HEATINGLOGO == 0) || + ((machinestate == kPidOffline) && OFFLINEGLOGO == 0) ) { //DEBUG_println(weight); diff --git a/rancilio-pid/rancilio-pid/Displaytemplatetemponly.h b/rancilio-pid/rancilio-pid/Displaytemplatetemponly.h index fe23b16ce..a143a9b6d 100644 --- a/rancilio-pid/rancilio-pid/Displaytemplatetemponly.h +++ b/rancilio-pid/rancilio-pid/Displaytemplatetemponly.h @@ -11,11 +11,11 @@ void printScreen() unsigned long currentMillisDisplay = millis(); if ( - (machinestate == 19 || machinestate == 20 || machinestate == 35) || - ((machinestate == 30 || machinestate == 31) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen - machinestate == 45 || - ((machinestate == 0 || machinestate == 10 ) && HEATINGLOGO == 0) || - ((machinestate == 90) && OFFLINEGLOGO == 0) + (machinestate == kSetPointNegative || machinestate == kPidNormal || machinestate == kBrewDetectionTrailing) || + ((machinestate == kBrew || machinestate == kShotTimerAfterBrew) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen + machinestate == kCoolDown || + ((machinestate == kInit || machinestate == kColdStart ) && HEATINGLOGO == 0) || + ((machinestate == kPidOffline) && OFFLINEGLOGO == 0) ) { if (!sensorError) diff --git a/rancilio-pid/rancilio-pid/Displaytemplateupright.h b/rancilio-pid/rancilio-pid/Displaytemplateupright.h index 29eeacd5f..dd16fce26 100644 --- a/rancilio-pid/rancilio-pid/Displaytemplateupright.h +++ b/rancilio-pid/rancilio-pid/Displaytemplateupright.h @@ -7,11 +7,11 @@ void printScreen() unsigned long currentMillisDisplay = millis(); if ( - (machinestate == 19 || machinestate == 20 || machinestate == 35) || - ((machinestate == 30 || machinestate == 31) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen - machinestate == 45 || - ((machinestate == 0 || machinestate == 10 ) && HEATINGLOGO == 0) || - ((machinestate == 90) && OFFLINEGLOGO == 0) + (machinestate == kSetPointNegative || machinestate == kPidNormal || machinestate == kBrewDetectionTrailing) || + ((machinestate == kBrew || machinestate == kShotTimerAfterBrew) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen + machinestate == kCoolDown || + ((machinestate == kInit || machinestate == kColdStart ) && HEATINGLOGO == 0) || + ((machinestate == kPidOffline) && OFFLINEGLOGO == 0) ) { diff --git a/rancilio-pid/rancilio-pid/display.h b/rancilio-pid/rancilio-pid/display.h index 53bd1a1b0..a8e244cc7 100644 --- a/rancilio-pid/rancilio-pid/display.h +++ b/rancilio-pid/rancilio-pid/display.h @@ -88,7 +88,7 @@ void displayShottimer(void) { - if ((machinestate == 30 ) && SHOTTIMER == 1) // Shotimer muss 1 = True sein und Bezug vorliegen + if ((machinestate == kBrew ) && SHOTTIMER == 1) // Shotimer muss 1 = True sein und Bezug vorliegen { // Dann Zeit anzeigen u8g2.clearBuffer(); @@ -105,7 +105,7 @@ if ( - ((machinestate == 31) && SHOTTIMER == 1) + ((machinestate == kShotTimerAfterBrew) && SHOTTIMER == 1) ) // wenn die totalbrewtime automatisch erreicht wird, //soll nichts gemacht werden, da sonst falsche Zeit angezeigt wird, da Schalter später betätigt wird als totalbrewtime { @@ -119,7 +119,7 @@ } #if (ONLYPIDSCALE == 1 || BREWMODE == 2) - if ((machinestate == 30 ) && SHOTTIMER == 2) // Shotimer muss 2 sein und Bezug vorliegen + if ((machinestate == kBrew ) && SHOTTIMER == 2) // Shotimer muss 2 sein und Bezug vorliegen { // Dann Zeit anzeigen u8g2.clearBuffer(); @@ -139,7 +139,7 @@ } if ( - ((machinestate == 31) && SHOTTIMER == 2) + ((machinestate == kShotTimerAfterBrew) && SHOTTIMER == 2) ) // wenn die totalbrewtime automatisch erreicht wird, soll nichts gemacht werden, // da sonst falsche Zeit angezeigt wird, da Schalter später betätigt wird als totalbrewtime { @@ -164,7 +164,7 @@ *****************************************************/ void Displaymachinestate() { - if (HEATINGLOGO > 0 && (machinestate == 0 || machinestate == 10 )) + if (HEATINGLOGO > 0 && (machinestate == kInit || machinestate == kColdStart )) { // Für Statusinfos u8g2.clearBuffer(); @@ -241,7 +241,7 @@ /******************************************************** DISPLAY - PID Off Logo *****************************************************/ - if (OFFLINEGLOGO == 1 && machinestate == 90) + if (OFFLINEGLOGO == 1 && machinestate == kPidOffline) { u8g2.clearBuffer(); u8g2.drawXBMP(38,0, OFFLogo_width, OFFLogo_height, OFFLogo); @@ -254,7 +254,7 @@ DISPLAY - Steam *****************************************************/ - if (machinestate == 40) + if (machinestate == kSteam) { u8g2.clearBuffer(); u8g2.drawXBMP(0,0, steamlogo_width, steamlogo_height, steamlogo); @@ -269,7 +269,7 @@ DISPLAY - Backflush *****************************************************/ - if ( machinestate == 50 ) + if ( machinestate == kBackflush ) { u8g2.setFont(u8g2_font_profont11_tf); // set font if (backflushState == 43) @@ -294,7 +294,7 @@ /******************************************************** DISPLAY - PID Off Logo *****************************************************/ - if (machinestate == 80) + if (machinestate == kEmergencyStop) { u8g2.clearBuffer(); u8g2.setFont(u8g2_font_profont11_tf); // set font @@ -328,7 +328,7 @@ /******************************************************** Sensor error *****************************************************/ - if (machinestate == 100) + if (machinestate == kSensorError) { displayMessage(langstring_error_tsensor[0], String(Input), langstring_error_tsensor[1], "", "", ""); //DISPLAY AUSGABE } diff --git a/rancilio-pid/rancilio-pid/rancilio-pid.ino b/rancilio-pid/rancilio-pid/rancilio-pid.ino index 94d3c7e9b..54f4c92df 100644 --- a/rancilio-pid/rancilio-pid/rancilio-pid.ino +++ b/rancilio-pid/rancilio-pid/rancilio-pid.ino @@ -58,6 +58,30 @@ DebugStreamManager debugStream; PeriodicTrigger writeDebugTrigger(5000); // trigger alle 5000 ms PeriodicTrigger logbrew(500); +/******************************************************** + Machine State +******************************************************/ + +enum MachineState { + kInit = 0, + kColdStart = 10, + kSetPointNegative = 19, + kPidNormal = 20, + kBrew = 30, + kShotTimerAfterBrew = 31, + kBrewDetectionTrailing = 35, + kSteam = 40, + kCoolDown = 45, + kBackflush = 50, + kEmergencyStop = 80, + kPidOffline = 90, + kSensorError = 100, +}; +MachineState machinestate = kInit; +int machinestatecold = 0; +unsigned long machinestatecoldmillis = 0; +MachineState lastmachinestate = kInit; +int lastmachinestatepid = -1; /******************************************************** definitions below must be changed in the userConfig.h file @@ -75,12 +99,7 @@ const unsigned long wifiConnectionDelay = WIFICINNECTIONDELAY; const unsigned int maxWifiReconnects = MAXWIFIRECONNECTS; //int machineLogo = MACHINELOGO; const unsigned long brewswitchDelay = BREWSWITCHDELAY; -int BrewMode = BREWMODE ; -int machinestate = 0; -int machinestatecold = 0; -unsigned long machinestatecoldmillis = 0; -int lastmachinestate = 0; -int lastmachinestatepid = -1; +int BrewMode = BREWMODE; //Display uint8_t oled_i2c = OLED_I2C; @@ -379,7 +398,7 @@ BLYNK_WRITE(V6) { } BLYNK_WRITE(V7) { - if (machinestate == 10) //antiwindup by coldstart + if (machinestate == kColdStart) //antiwindup by coldstart { bPID.SetOutputLimits(0.0, 1.0); // Forces minimum up to 0.0 bPID.SetOutputLimits(-1.0, 0.0); // Forces maximum down to 0.0 @@ -1166,7 +1185,7 @@ void checkSteamON() void setEmergencyStopTemp() { - if (machinestate == 40 || machinestate == 45) + if (machinestate == kSteam || machinestate == kCoolDown) { if (EmergencyStopTemp != 145) EmergencyStopTemp = 145; @@ -1213,46 +1232,31 @@ boolean checkSteamOffQM() machinestatevoid ******************************************************/ - void machinestatevoid() { - /* - 00 = init - 10 = kaltstart - 19 = Setpoint -1 Celsius - 20 = Setpoint überschritten, idle at setpoint - 30 = Bezug - 35 = Nachlauf BD - 40 = Dampf - 50 = Backflush - 80 = Emergency Stop - 90 = PID Offline - 100 = Sensorerror - */ //DEBUG_println(machinestate); switch (machinestate) { // init - case 0: + case kInit: if (Input < (BrewSetPoint-1) || Input < 150 ) // Prevent coldstart leave by Input 222 { - machinestate = 10 ; // kaltstart + machinestate = kColdStart; DEBUG_println(Input); DEBUG_println(machinestate); } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // kaltstart - case 10: + case kColdStart: switch (machinestatecold) // one high Input let the state jump to 19. // switch (machinestatecold) prevent it, we wait 10 sec with new state. @@ -1276,14 +1280,14 @@ void machinestatevoid() } if (machinestatecoldmillis+10*1000 < millis() ) // 10 sec Input above BrewSetPoint, no set new state { - machinestate = 19 ; + machinestate = kSetPointNegative ; debugStream.writeV("10 sec Input >= (BrewSetPoint-1) finished, switch to state 19"); } break; } if (SteamON == 1) { - machinestate = 40 ; // Steam + machinestate = kSteam; } if @@ -1293,33 +1297,33 @@ void machinestatevoid() ) { - machinestate = 30 ; // Brew + machinestate = kBrew; } if (SteamON == 1) { - machinestate = 40 ; // switch to Steam + machinestate = kSteam; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; // Setpoint -1 Celsius - case 19: + case kSetPointNegative: if (Input >= (BrewSetPoint)) { - machinestate = 20 ; + machinestate = kPidNormal; } if ( @@ -1327,34 +1331,34 @@ void machinestatevoid() (ONLYPID == 0 && brewcounter > 10 && brewcounter <= 42) ) { - machinestate = 30 ; // Brew + machinestate = kBrew; } if (SteamON == 1) { - machinestate = 40 ; // Steam + machinestate = kSteam; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (SteamON == 1) { - machinestate = 40 ; // switch to Steam + machinestate = kSteam; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // normal PID - case 20: + + case kPidNormal: brewdetection(); //if brew detected, set PID values if ( @@ -1362,32 +1366,32 @@ void machinestatevoid() (ONLYPID == 0 && brewcounter > 10 && brewcounter <= 42) ) { - machinestate = 30 ; // Brew + machinestate = kBrew; } if (SteamON == 1) { - machinestate = 40 ; // Steam + machinestate = kSteam; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // Brew - case 30: + + case kBrew: brewdetection(); // Ausgabe waehrend des Bezugs von Bruehzeit, Temp und heatrateaverage if (logbrew.check()) @@ -1401,74 +1405,74 @@ void machinestatevoid() { if ((ONLYPID == 1 && Brewdetection == 3) || ONLYPID == 0 ) // only delay of shotimer for voltagesensor or brewcounter { - machinestate = 31 ; + machinestate = kShotTimerAfterBrew ; lastbezugszeitMillis = millis() ; // for delay } if (ONLYPID == 1 && Brewdetection == 1 && timerBrewdetection == 1) //direct to PID BD { - machinestate = 35 ; + machinestate = kBrewDetectionTrailing ; } } if (SteamON == 1) { - machinestate = 40 ; // Steam + machinestate = kSteam; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // Sec after shot finish - case 31: //lastbezugszeitMillis + + case kShotTimerAfterBrew: //lastbezugszeitMillis brewdetection(); if ( millis()-lastbezugszeitMillis > BREWSWITCHDELAY ) { debugStream.writeI("Bezugsdauer: %4.1f s",lastbezugszeit/1000); - machinestate = 35 ; + machinestate = kBrewDetectionTrailing ; lastbezugszeit = 0 ; } if (SteamON == 1) { - machinestate = 40 ; // Steam + machinestate = kSteam; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // BD PID - case 35: - brewdetection(); + + case kBrewDetectionTrailing: + brewdetection(); if (timerBrewdetection == 0) { - machinestate = 20 ; // switch to normal PID + machinestate = kPidNormal; } if ( @@ -1476,60 +1480,60 @@ void machinestatevoid() (ONLYPID == 0 && brewcounter > 10 && brewcounter <= 42) ) { - machinestate = 30 ; // Brew + machinestate = kBrew; } if (SteamON == 1) { - machinestate = 40 ; // switch to Steam + machinestate = kSteam; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // Steam - case 40: + + case kSteam: if (SteamON == 0) { - machinestate = 45 ; // switch to cool down after steam + machinestate = kCoolDown; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - case 45: // chill-mode after steam + case kCoolDown: if (Brewdetection == 2 || Brewdetection == 3) { /* @@ -1543,104 +1547,104 @@ void machinestatevoid() // Ab lokalen Minumum wieder freigeben für state 20, dann wird bist Solltemp geheizt. if (heatrateaverage > 0 && Input < BrewSetPoint + 2) { - machinestate = 20; + machinestate = kPidNormal; } } if ((Brewdetection == 3 || Brewdetection == 2) && Input < BrewSetPoint + 2) { - machinestate = 20; // switch to normal + machinestate = kPidNormal; } if (SteamON == 1) { - machinestate = 40 ; // Steam + machinestate = kSteam; } if (backflushON || backflushState > 10) { - machinestate = 50 ; // backflushON + machinestate = kBackflush; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - case 50: - // Backflush + case kBackflush: if (backflushON == 0) { - machinestate = 20 ; // switch to normal + machinestate = kPidNormal; } if (emergencyStop) { - machinestate = 80 ; // Emergency Stop + machinestate = kEmergencyStop; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ;// sensorerror + machinestate = kSensorError; } break; - // emergencyStop - case 80: + + case kEmergencyStop: if (!emergencyStop) { - machinestate = 20 ; // normal PID + machinestate = kPidNormal; } if (pidON == 0) { - machinestate = 90 ; // offline + machinestate = kPidOffline; } if(sensorError) { - machinestate = 100 ; + machinestate = kSensorError ; } break; - // PID offline - case 90: + + case kPidOffline: if (pidON == 1) { if(kaltstart) { - machinestate = 10 ; // kaltstart + machinestate = kColdStart; } else if(!kaltstart && (Input > (BrewSetPoint-10) )) // Input higher BrewSetPoint-10, normal PID { - machinestate = 20 ; // normal PID + machinestate = kPidNormal; } else if (Input <= (BrewSetPoint-10) ) { - machinestate = 10 ; // Input higher BrewSetPoint-10, kaltstart + machinestate = kColdStart; // Input 10C below set point, enter cold start kaltstart = true; } } if(sensorError) { - machinestate = 100 ; + machinestate = kSensorError ; } break; - // sensor error - case 100: - machinestate = 100 ; + + case kSensorError: + machinestate = kSensorError ; break; } // switch case + if (machinestate != lastmachinestate) { - debugStream.writeI("new machinestate: %i -> %i",lastmachinestate, machinestate); + debugStream.writeI("new machinestate: %i -> %i", lastmachinestate, machinestate); lastmachinestate = machinestate; } } // end void @@ -2171,7 +2175,7 @@ void looppid() printScreen(); // refresh display } #endif - if (machinestate == 90 || machinestate == 100 || machinestate == 80) // Offline see machinestate.h + if (machinestate == kPidOffline || machinestate == kSensorError || machinestate == kEmergencyStop) // Offline see machinestate.h { if (pidMode == 1) { @@ -2192,7 +2196,7 @@ void looppid() } //Set PID if first start of machine detected, and no SteamON - if (machinestate == 0 || machinestate == 10 || machinestate == 19) // Cold Start states + if (machinestate == kInit || machinestate == kColdStart || machinestate == kSetPointNegative) // Cold Start states { if (startTn != 0) { startKi = startKp / startTn; @@ -2207,7 +2211,7 @@ void looppid() bPID.SetTunings(startKp, startKi, 0, P_ON_M); // normal PID } - if (machinestate == 20 ) + if (machinestate == kPidNormal ) { //Prevent overwriting of brewdetection values // calc ki, kd if (aggTn != 0) { @@ -2242,7 +2246,7 @@ void looppid() bPID.SetTunings(aggbKp, aggbKi, aggbKd, PonE) ; } // Steam on - if (machinestate == 40) // STEAM + if (machinestate == kSteam) // STEAM { // if (aggTn != 0) { // aggKi = aggKp / aggTn ; @@ -2259,7 +2263,7 @@ void looppid() bPID.SetTunings(150, 0, 0, PonE); } - if (machinestate == 45) // chill-mode after steam + if (machinestate == kCoolDown) // chill-mode after steam { switch (machine) {