From e560ed4431096518241d46071d86eaabff1f3644 Mon Sep 17 00:00:00 2001 From: Makuro Date: Wed, 29 Nov 2023 00:26:38 +0100 Subject: [PATCH 1/6] Water Sensor shown on display with icons --- src/Displaytemplateminimal.h | 3 +- src/Displaytemplatescale.h | 1 + src/Displaytemplatestandard.h | 1 + src/Displaytemplatetemponly.h | 1 + src/display.h | 59 +++++++++++++-- src/icon.h | 16 ++++ src/main.cpp | 133 ++++++++++++++++++++++++++++++++-- src/userConfig_sample.h | 1 + 8 files changed, 203 insertions(+), 12 deletions(-) diff --git a/src/Displaytemplateminimal.h b/src/Displaytemplateminimal.h index 77cb8bba..2fd6333f 100644 --- a/src/Displaytemplateminimal.h +++ b/src/Displaytemplateminimal.h @@ -118,7 +118,8 @@ void printScreen() { u8g2.print("O"); } - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();sendBufferWithIcons(); } } } diff --git a/src/Displaytemplatescale.h b/src/Displaytemplatescale.h index 704ea74d..d8a7ccc3 100644 --- a/src/Displaytemplatescale.h +++ b/src/Displaytemplatescale.h @@ -136,6 +136,7 @@ void printScreen() { u8g2.print("Offline Mode"); } + displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/Displaytemplatestandard.h b/src/Displaytemplatestandard.h index 0896ca33..306e6ed5 100644 --- a/src/Displaytemplatestandard.h +++ b/src/Displaytemplatestandard.h @@ -160,6 +160,7 @@ void printScreen() u8g2.print(langstring_offlinemode); } + displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/Displaytemplatetemponly.h b/src/Displaytemplatetemponly.h index 85ee8daf..8425e15a 100644 --- a/src/Displaytemplatetemponly.h +++ b/src/Displaytemplatetemponly.h @@ -64,6 +64,7 @@ void printScreen() { u8g2.print("O"); } + displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/display.h b/src/display.h index 6529b466..aad1ae05 100644 --- a/src/display.h +++ b/src/display.h @@ -21,6 +21,23 @@ void u8g2_prepare(void) { u8g2.setDisplayRotation(DISPLAYROTATE); } +/** + * Icons... + * Show water empty icon in upper right corner if water empty + */ +void displayWaterIcon() { + if (!waterFull) { + //small water empty logo + u8g2.drawXBMP(119, 2, 8, 8, water_EMPTY_u8g2); + } +} + +/** + * Collector to always show indicators along all the other information + */ +void displayIcons() { + displayWaterIcon(); +} /** * @brief print message @@ -39,6 +56,7 @@ void displayMessage(String text1, String text2, String text3, String text4, Stri u8g2.print(text5); u8g2.setCursor(0, 50); u8g2.print(text6); + displayIcons(); u8g2.sendBuffer(); } @@ -73,6 +91,7 @@ void displayLogo(String displaymessagetext, String displaymessagetext2) { startLogoQuickMill_bits); break; } + displayIcons(); u8g2.sendBuffer(); } @@ -87,6 +106,7 @@ void displayDistance(int display_distance) { u8g2.setFont(u8g2_font_fub20_tf); u8g2.printf("%d", display_distance); u8g2.print("mm"); + displayIcons(); u8g2.sendBuffer(); } @@ -103,6 +123,7 @@ void displayShottimer(void) { u8g2.setCursor(64, 25); u8g2.print(timeBrewed / 1000, 1); u8g2.setFont(u8g2_font_profont11_tf); + displayIcons(); u8g2.sendBuffer(); } @@ -117,7 +138,8 @@ void displayShottimer(void) { u8g2.setCursor(64, 25); u8g2.print(lastbrewTime / 1000, 1); u8g2.setFont(u8g2_font_profont11_tf); - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();; } #if (ONLYPIDSCALE == 1 || BREWMODE == 2) @@ -134,6 +156,7 @@ void displayShottimer(void) { u8g2.print(weightBrew, 0); u8g2.print("g"); u8g2.setFont(u8g2_font_profont11_tf); + displayIcons(); u8g2.sendBuffer(); } @@ -148,7 +171,8 @@ void displayShottimer(void) { u8g2.print(weightBrew, 0); u8g2.print(" g"); u8g2.setFont(u8g2_font_profont11_tf); - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();; } #endif } @@ -212,7 +236,8 @@ void Displaymachinestate() { u8g2.setCursor(92, 30); u8g2.setFont(u8g2_font_profont17_tf); u8g2.print(temperature, 1); - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();; } // Offline logo @@ -222,6 +247,7 @@ void Displaymachinestate() { u8g2.setCursor(0, 55); u8g2.setFont(u8g2_font_profont10_tf); u8g2.print("PID is disabled manually"); + displayIcons(); u8g2.sendBuffer(); } @@ -231,7 +257,8 @@ void Displaymachinestate() { u8g2.setCursor(36, 55); u8g2.setFont(u8g2_font_profont10_tf); u8g2.print("Standby mode"); - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();; } // Steam @@ -242,7 +269,26 @@ void Displaymachinestate() { u8g2.setFont(u8g2_font_profont22_tf); u8g2.print(temperature, 0); u8g2.setCursor(64, 25); - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();; + } + + // Water empty + if (machineState == kWaterEmpty) { + u8g2.clearBuffer(); + u8g2.setFontPosBottom(); + u8g2.setFont(u8g2_font_profont22_tr); + u8g2.drawStr(53, 26, "Fill"); + u8g2.drawStr(59, 42, "water"); + u8g2.drawXBMP( 3, 0, water_empty_big_width, water_empty_big_height, water_EMPTY_big_u8g2); + u8g2.setFont(u8g2_font_profont11_tf); + u8g2.setCursor(80, 64); + u8g2.print(temperature); + u8g2.print((char)176); + u8g2.print("C"); + u8g2.setFontPosTop(); + displayIcons(); + u8g2.sendBuffer();; } // Backflush @@ -292,7 +338,8 @@ void Displaymachinestate() { u8g2.print("PID STOPPED"); } - u8g2.sendBuffer(); + displayIcons(); + u8g2.sendBuffer();; } if (machineState == kSensorError) { diff --git a/src/icon.h b/src/icon.h index c981fc53..dbd2d125 100644 --- a/src/icon.h +++ b/src/icon.h @@ -27,6 +27,8 @@ #define OFFLogo_height 53 #define steamlogo_width 60 #define steamlogo_height 58 +#define water_empty_big_width 47 +#define water_empty_big_height 64 static const unsigned char PROGMEM logo_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x01, 0xff, 0x00, 0x03, 0x83, 0x80, 0x03, 0x01, 0x80, 0x06, @@ -226,6 +228,20 @@ static const unsigned char PROGMEM antenna_NOK_u8g2[] = { B10001000 }; +static const unsigned char PROGMEM water_EMPTY_u8g2[] = { + B00001001, + B01001010, + B00011100, + B00010100, + B00101110, + B00111110, + B01011100, + B10000000 +}; + +// "water empty logo" +static const unsigned char PROGMEM water_EMPTY_big_u8g2[] = {0x00,0x00,0xfc,0x07,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0xe0,0x07,0xfc,0x00,0x00,0x00,0xf0,0x00,0xe0,0x01,0x00,0x00,0x3c,0xf0,0x81,0x03,0x00,0x00,0x1e,0xfe,0x0f,0x07,0x00,0x00,0x87,0x1f,0x3f,0x0e,0x00,0x00,0xc3,0x01,0x78,0x1c,0x00,0x80,0xf3,0x00,0xe0,0x38,0x00,0xc0,0x31,0x00,0xc0,0x31,0x00,0xc0,0x18,0x00,0x80,0x73,0x00,0xe0,0x1c,0x00,0x00,0x67,0x00,0x60,0x0c,0x00,0x00,0xe6,0x00,0x60,0x0e,0x00,0x00,0xc6,0x00,0x60,0x06,0x00,0x00,0xcc,0x00,0x70,0x06,0x00,0x00,0xcc,0x00,0x30,0x06,0x00,0x00,0xcc,0x00,0xfc,0x0f,0x00,0x00,0xcc,0x00,0xfc,0x1f,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x01,0x0e,0x18,0x00,0x00,0xcc,0x01,0x06,0x38,0x00,0x00,0xcc,0x01,0x0e,0x38,0x00,0x00,0xcc,0x01,0xfe,0x3f,0x00,0x00,0xcc,0x01,0xfc,0x1f,0x00,0x00,0xcc,0x01,0x00,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,0x80,0x03,0xcc,0x01,0x00,0x00,0xc0,0x07,0xcc,0x01,0x00,0x00,0xe0,0x0f,0xcc,0x01,0x80,0x00,0x60,0x1c,0xcc,0x01,0xc0,0x01,0x70,0x38,0xfe,0x01,0xe0,0x03,0xe0,0x70,0xfe,0x03,0x70,0x03,0xc0,0xe1,0x86,0x03,0x30,0x06,0x80,0xe3,0x06,0x03,0x38,0x0e,0x00,0x77,0x06,0x03,0x1c,0x0c,0x00,0x7e,0x06,0x03,0x0c,0x1c,0x00,0xfc,0x86,0x03,0x4e,0x18,0x00,0xc0,0x87,0x03,0xc6,0x30,0x00,0x80,0xff,0x03,0x47,0x30,0x00,0x00,0xff,0x03,0x03,0x70,0x00,0x00,0x86,0x03,0x03,0x60,0x00,0x00,0x07,0x03,0x73,0x60,0x00,0x00,0x03,0x07,0x63,0x70,0x00,0x00,0x03,0x07,0x47,0x30,0x00,0x00,0x07,0x03,0x0e,0x38,0x00,0x00,0x8e,0x03,0x1c,0x1c,0x00,0x00,0xfe,0x03,0xf8,0x0f,0x00,0x00,0xfe,0x03,0xf0,0x07,0x00,0x00,0x86,0x03,0x00,0x00,0x00,0x00,0x86,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0xf0,0xff,0x7f}; + // 'logo', 64x59px static const unsigned char brewlogo_bits_u8g2 [] PROGMEM = { diff --git a/src/main.cpp b/src/main.cpp index 1e94da63..c3bac7fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -73,6 +73,7 @@ enum MachineState { kSteam = 40, kCoolDown = 45, kBackflush = 50, + kWaterEmpty = 70, kEmergencyStop = 80, kPidOffline = 90, kStandby = 95, @@ -152,6 +153,7 @@ void setBDPIDTunings(); void loopcalibrate(); void looppid(); void loopLED(); +void loopWater(); void printMachineState(); char const* machinestateEnumToString(MachineState machineState); void initSteamQM(); @@ -248,6 +250,14 @@ int backflushON = 0; // 1 = backflush mode active int flushCycles = 0; // number of active flush cycles int backflushState = 10; // counter for state machine +//Water sensor +boolean waterFull = true; // current state of water reservoir. If water sensor not installed, will stay always on "true" +unsigned long lastWaterCheck; +const unsigned long WaterCheckInterval = 20; //Check water level every .1s +int WaterCheckConsecutiveReads = 0; // Counter for consecutive readings of water sensor +const int WaterCountsNeeded = 5; // Number of same readings to change water sensing + + // Moving average for software brew detection double tempRateAverage = 0; // average value of temp values double tempChangeRateAverageMin = 0; @@ -943,6 +953,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1014,6 +1028,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1063,6 +1081,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1111,9 +1133,14 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } + break; case kBrew: @@ -1178,6 +1205,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1214,6 +1245,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1236,6 +1271,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1276,6 +1315,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1294,6 +1337,10 @@ void handleMachineState() { machineState = kPidOffline; } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1313,6 +1360,20 @@ void handleMachineState() { } break; + case kWaterEmpty: + if (waterFull) { + machineState = kPidNormal; + } + + if (pidON == 0) { + machineState = kPidOffline; + } + + if (sensorError) { + machineState = kSensorError; + } + break; + case kPidOffline: if (pidON == 1) { if (coldstart) { @@ -1325,6 +1386,10 @@ void handleMachineState() { } } + if (!waterFull) { + machineState = kWaterEmpty; + } + if (sensorError) { machineState = kSensorError; } @@ -1393,6 +1458,8 @@ char const* machinestateEnumToString(MachineState machineState) { return "Cool Down"; case kBackflush: return "Backflush"; + case kWaterEmpty: + return "Water Empty"; case kEmergencyStop: return "Emergency Stop"; case kPidOffline: @@ -2049,6 +2116,16 @@ void setup() { pinMode(PIN_STATUSLED, OUTPUT); } + #if WATER_SENS == 1 + //NPN + pinMode(PIN_WATERSENSOR, INPUT_PULLUP); + #endif + + #if WATER_SENS == 2 + //PNP + pinMode(PIN_WATERSENSOR, INPUT_PULLDOWN); + #endif + #if OLED_DISPLAY != 0 u8g2.setI2CAddress(oled_i2c * 2); u8g2.begin(); @@ -2150,6 +2227,10 @@ void loop() { loopLED(); } + if (WATER_SENS > 0) { + loopWater(); + } + checkForRemoteSerialClients(); } @@ -2239,8 +2320,13 @@ void looppid() { checkPressure(); #endif - brew(); - checkSteamON(); + if(machineState != kWaterEmpty) { + brew(); + } + + setEmergencyStopTemp(); + checkSteamSwitch(); + checkPowerSwitch(); // set setpoint depending on steam or brew mode if (steamON == 1) { @@ -2250,8 +2336,6 @@ void looppid() { } setEmergencyStopTemp(); - checkPowerSwitch(); - checkSteamSwitch(); if (standbyModeOn && machineState != kStandby) { updateStandbyTimer(); @@ -2278,7 +2362,7 @@ void looppid() { } #endif - if (machineState == kPidOffline || machineState == kSensorError || machineState == kEmergencyStop || machineState == kEepromError || machineState == kStandby || brewPIDdisabled) { + if (machineState == kPidOffline || machineState == kWaterEmpty || machineState == kSensorError || machineState == kEmergencyStop || machineState == kEepromError || machineState == kStandby || brewPIDdisabled) { if (pidMode == 1) { // Force PID shutdown pidMode = 0; @@ -2392,6 +2476,45 @@ void loopLED() { } } +void loopWater() { + if ((millis() - lastWaterCheck) > WaterCheckInterval) { + lastWaterCheck = millis(); + + // Check water + bool isWaterDetected = digitalRead(PIN_WATERSENSOR) == (WATER_SENS == 1 ? LOW : HIGH); + + if (isWaterDetected) { + // Water is detected, increment counter if it was previously empty + if (!waterFull) { + WaterCheckConsecutiveReads++; + if (WaterCheckConsecutiveReads >= WaterCountsNeeded) { + waterFull = true; + debugPrintf("Water full\n"); + WaterCheckConsecutiveReads = 0; // Reset counter + } + } + else { + WaterCheckConsecutiveReads = 0; // Reset counter if water was already full + } + } + else { + // No water detected, increment counter if it was previously full + if (waterFull) { + WaterCheckConsecutiveReads++; + + if (WaterCheckConsecutiveReads >= WaterCountsNeeded) { + waterFull = false; + debugPrintf("Water empty\n"); + WaterCheckConsecutiveReads = 0; // Reset counter + } + } + else { + WaterCheckConsecutiveReads = 0; // Reset counter if water was already empty + } + } + } +} + void setBackflush(int backflush) { backflushON = backflush; } diff --git a/src/userConfig_sample.h b/src/userConfig_sample.h index efc0e2e4..9560279f 100644 --- a/src/userConfig_sample.h +++ b/src/userConfig_sample.h @@ -62,6 +62,7 @@ enum MACHINE { #define TRIGGERTYPE HIGH // LOW = low trigger, HIGH = high trigger relay for pump & valve #define PRESSURESENSOR 0 // 0 = no pressure sensor connected, 1 = pressure sensor connected #define TEMP_LED 1 // Blink status LED when temp is in range +#define WATER_SENS 0 // 0 = no water sensor, 1 = water sensor XKC-Y25-NPN connected, 2 = XKC-Y25-PNP connected // Brew Scale #define SCALE_SAMPLES 2 // Load cell sample rate From 937f905b5dd319fc5e261b838983702eec426107 Mon Sep 17 00:00:00 2001 From: Andreas Tacke Date: Sun, 10 Dec 2023 12:30:22 +0100 Subject: [PATCH 2/6] Fixes for initial water sensor implementation * Remove unused function call from Displaytemplateminimal.h * Fix indentation and spacing * Add missing call of checkSteamON() * Remove unnecessary semicolons from display.h * Remove unnecessary comments --- src/Displaytemplateminimal.h | 2 +- src/display.h | 14 +++++++------- src/icon.h | 36 ++++++++++++++++++++++++++++++++---- src/main.cpp | 36 +++++++++++++++++------------------- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/Displaytemplateminimal.h b/src/Displaytemplateminimal.h index 2fd6333f..8aa72438 100644 --- a/src/Displaytemplateminimal.h +++ b/src/Displaytemplateminimal.h @@ -119,7 +119,7 @@ void printScreen() { } displayIcons(); - u8g2.sendBuffer();sendBufferWithIcons(); + u8g2.sendBuffer(); } } } diff --git a/src/display.h b/src/display.h index aad1ae05..15868ed7 100644 --- a/src/display.h +++ b/src/display.h @@ -139,7 +139,7 @@ void displayShottimer(void) { u8g2.print(lastbrewTime / 1000, 1); u8g2.setFont(u8g2_font_profont11_tf); displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } #if (ONLYPIDSCALE == 1 || BREWMODE == 2) @@ -172,7 +172,7 @@ void displayShottimer(void) { u8g2.print(" g"); u8g2.setFont(u8g2_font_profont11_tf); displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } #endif } @@ -237,7 +237,7 @@ void Displaymachinestate() { u8g2.setFont(u8g2_font_profont17_tf); u8g2.print(temperature, 1); displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } // Offline logo @@ -258,7 +258,7 @@ void Displaymachinestate() { u8g2.setFont(u8g2_font_profont10_tf); u8g2.print("Standby mode"); displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } // Steam @@ -270,7 +270,7 @@ void Displaymachinestate() { u8g2.print(temperature, 0); u8g2.setCursor(64, 25); displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } // Water empty @@ -288,7 +288,7 @@ void Displaymachinestate() { u8g2.print("C"); u8g2.setFontPosTop(); displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } // Backflush @@ -339,7 +339,7 @@ void Displaymachinestate() { } displayIcons(); - u8g2.sendBuffer();; + u8g2.sendBuffer(); } if (machineState == kSensorError) { diff --git a/src/icon.h b/src/icon.h index dbd2d125..875bfd7c 100644 --- a/src/icon.h +++ b/src/icon.h @@ -28,7 +28,7 @@ #define steamlogo_width 60 #define steamlogo_height 58 #define water_empty_big_width 47 -#define water_empty_big_height 64 +#define water_empty_big_height 64 static const unsigned char PROGMEM logo_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x01, 0xff, 0x00, 0x03, 0x83, 0x80, 0x03, 0x01, 0x80, 0x06, @@ -240,11 +240,39 @@ static const unsigned char PROGMEM water_EMPTY_u8g2[] = { }; // "water empty logo" -static const unsigned char PROGMEM water_EMPTY_big_u8g2[] = {0x00,0x00,0xfc,0x07,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0xe0,0x07,0xfc,0x00,0x00,0x00,0xf0,0x00,0xe0,0x01,0x00,0x00,0x3c,0xf0,0x81,0x03,0x00,0x00,0x1e,0xfe,0x0f,0x07,0x00,0x00,0x87,0x1f,0x3f,0x0e,0x00,0x00,0xc3,0x01,0x78,0x1c,0x00,0x80,0xf3,0x00,0xe0,0x38,0x00,0xc0,0x31,0x00,0xc0,0x31,0x00,0xc0,0x18,0x00,0x80,0x73,0x00,0xe0,0x1c,0x00,0x00,0x67,0x00,0x60,0x0c,0x00,0x00,0xe6,0x00,0x60,0x0e,0x00,0x00,0xc6,0x00,0x60,0x06,0x00,0x00,0xcc,0x00,0x70,0x06,0x00,0x00,0xcc,0x00,0x30,0x06,0x00,0x00,0xcc,0x00,0xfc,0x0f,0x00,0x00,0xcc,0x00,0xfc,0x1f,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x01,0x0e,0x18,0x00,0x00,0xcc,0x01,0x06,0x38,0x00,0x00,0xcc,0x01,0x0e,0x38,0x00,0x00,0xcc,0x01,0xfe,0x3f,0x00,0x00,0xcc,0x01,0xfc,0x1f,0x00,0x00,0xcc,0x01,0x00,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,0x80,0x03,0xcc,0x01,0x00,0x00,0xc0,0x07,0xcc,0x01,0x00,0x00,0xe0,0x0f,0xcc,0x01,0x80,0x00,0x60,0x1c,0xcc,0x01,0xc0,0x01,0x70,0x38,0xfe,0x01,0xe0,0x03,0xe0,0x70,0xfe,0x03,0x70,0x03,0xc0,0xe1,0x86,0x03,0x30,0x06,0x80,0xe3,0x06,0x03,0x38,0x0e,0x00,0x77,0x06,0x03,0x1c,0x0c,0x00,0x7e,0x06,0x03,0x0c,0x1c,0x00,0xfc,0x86,0x03,0x4e,0x18,0x00,0xc0,0x87,0x03,0xc6,0x30,0x00,0x80,0xff,0x03,0x47,0x30,0x00,0x00,0xff,0x03,0x03,0x70,0x00,0x00,0x86,0x03,0x03,0x60,0x00,0x00,0x07,0x03,0x73,0x60,0x00,0x00,0x03,0x07,0x63,0x70,0x00,0x00,0x03,0x07,0x47,0x30,0x00,0x00,0x07,0x03,0x0e,0x38,0x00,0x00,0x8e,0x03,0x1c,0x1c,0x00,0x00,0xfe,0x03,0xf8,0x0f,0x00,0x00,0xfe,0x03,0xf0,0x07,0x00,0x00,0x86,0x03,0x00,0x00,0x00,0x00,0x86,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0xf0,0xff,0x7f}; +static const unsigned char PROGMEM water_EMPTY_big_u8g2[] = { + 0x00,0x00,0xfc,0x07,0x00,0x00,0x00,0x80,0xff,0x3f,0x00,0x00,0x00,0xe0, + 0x07,0xfc,0x00,0x00,0x00,0xf0,0x00,0xe0,0x01,0x00,0x00,0x3c,0xf0,0x81, + 0x03,0x00,0x00,0x1e,0xfe,0x0f,0x07,0x00,0x00,0x87,0x1f,0x3f,0x0e,0x00, + 0x00,0xc3,0x01,0x78,0x1c,0x00,0x80,0xf3,0x00,0xe0,0x38,0x00,0xc0,0x31, + 0x00,0xc0,0x31,0x00,0xc0,0x18,0x00,0x80,0x73,0x00,0xe0,0x1c,0x00,0x00, + 0x67,0x00,0x60,0x0c,0x00,0x00,0xe6,0x00,0x60,0x0e,0x00,0x00,0xc6,0x00, + 0x60,0x06,0x00,0x00,0xcc,0x00,0x70,0x06,0x00,0x00,0xcc,0x00,0x30,0x06, + 0x00,0x00,0xcc,0x00,0xfc,0x0f,0x00,0x00,0xcc,0x00,0xfc,0x1f,0x00,0x00, + 0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x00, + 0x0c,0x18,0x00,0x00,0xcc,0x00,0x0c,0x18,0x00,0x00,0xcc,0x01,0x0e,0x18, + 0x00,0x00,0xcc,0x01,0x06,0x38,0x00,0x00,0xcc,0x01,0x0e,0x38,0x00,0x00, + 0xcc,0x01,0xfe,0x3f,0x00,0x00,0xcc,0x01,0xfc,0x1f,0x00,0x00,0xcc,0x01, + 0x00,0x00,0x00,0x00,0xcc,0x01,0x00,0x00,0x00,0x00,0xcc,0x01,0x00,0x00, + 0x80,0x03,0xcc,0x01,0x00,0x00,0xc0,0x07,0xcc,0x01,0x00,0x00,0xe0,0x0f, + 0xcc,0x01,0x80,0x00,0x60,0x1c,0xcc,0x01,0xc0,0x01,0x70,0x38,0xfe,0x01, + 0xe0,0x03,0xe0,0x70,0xfe,0x03,0x70,0x03,0xc0,0xe1,0x86,0x03,0x30,0x06, + 0x80,0xe3,0x06,0x03,0x38,0x0e,0x00,0x77,0x06,0x03,0x1c,0x0c,0x00,0x7e, + 0x06,0x03,0x0c,0x1c,0x00,0xfc,0x86,0x03,0x4e,0x18,0x00,0xc0,0x87,0x03, + 0xc6,0x30,0x00,0x80,0xff,0x03,0x47,0x30,0x00,0x00,0xff,0x03,0x03,0x70, + 0x00,0x00,0x86,0x03,0x03,0x60,0x00,0x00,0x07,0x03,0x73,0x60,0x00,0x00, + 0x03,0x07,0x63,0x70,0x00,0x00,0x03,0x07,0x47,0x30,0x00,0x00,0x07,0x03, + 0x0e,0x38,0x00,0x00,0x8e,0x03,0x1c,0x1c,0x00,0x00,0xfe,0x03,0xf8,0x0f, + 0x00,0x00,0xfe,0x03,0xf0,0x07,0x00,0x00,0x86,0x03,0x00,0x00,0x00,0x00, + 0x86,0x03,0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x06,0x03, + 0x00,0x00,0x00,0x00,0x06,0x03,0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00, + 0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0xf0,0xff,0x7f,0x00,0x00,0x00,0x30, + 0x00,0x60,0x00,0x00,0x00,0x30,0x00,0x60,0x00,0x00,0x00,0xf0,0xff,0x7f, + 0x00,0x00,0x00,0xf0,0xff,0x7f +}; // 'logo', 64x59px -static const unsigned char brewlogo_bits_u8g2 [] PROGMEM = -{ +static const unsigned char brewlogo_bits_u8g2 [] PROGMEM = { 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/src/main.cpp b/src/main.cpp index c3bac7fa..5d2358dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -250,12 +250,12 @@ int backflushON = 0; // 1 = backflush mode active int flushCycles = 0; // number of active flush cycles int backflushState = 10; // counter for state machine -//Water sensor -boolean waterFull = true; // current state of water reservoir. If water sensor not installed, will stay always on "true" +// Water sensor +boolean waterFull = true; // Current state of water reservoir. If water sensor not installed, will stay always on "true" unsigned long lastWaterCheck; -const unsigned long WaterCheckInterval = 20; //Check water level every .1s -int WaterCheckConsecutiveReads = 0; // Counter for consecutive readings of water sensor -const int WaterCountsNeeded = 5; // Number of same readings to change water sensing +const unsigned long WaterCheckInterval = 20; // Check water level every .1s +int waterCheckConsecutiveReads = 0; // Counter for consecutive readings of water sensor +const int waterCountsNeeded = 5; // Number of same readings to change water sensing // Moving average for software brew detection @@ -2117,12 +2117,8 @@ void setup() { } #if WATER_SENS == 1 - //NPN pinMode(PIN_WATERSENSOR, INPUT_PULLUP); - #endif - - #if WATER_SENS == 2 - //PNP + #elif WATER_SENS == 2 pinMode(PIN_WATERSENSOR, INPUT_PULLDOWN); #endif @@ -2320,6 +2316,8 @@ void looppid() { checkPressure(); #endif + checkSteamON(); + if(machineState != kWaterEmpty) { brew(); } @@ -2480,36 +2478,36 @@ void loopWater() { if ((millis() - lastWaterCheck) > WaterCheckInterval) { lastWaterCheck = millis(); - // Check water bool isWaterDetected = digitalRead(PIN_WATERSENSOR) == (WATER_SENS == 1 ? LOW : HIGH); if (isWaterDetected) { // Water is detected, increment counter if it was previously empty if (!waterFull) { - WaterCheckConsecutiveReads++; - if (WaterCheckConsecutiveReads >= WaterCountsNeeded) { + waterCheckConsecutiveReads++; + + if (waterCheckConsecutiveReads >= waterCountsNeeded) { waterFull = true; debugPrintf("Water full\n"); - WaterCheckConsecutiveReads = 0; // Reset counter + waterCheckConsecutiveReads = 0; } } else { - WaterCheckConsecutiveReads = 0; // Reset counter if water was already full + waterCheckConsecutiveReads = 0; } } else { // No water detected, increment counter if it was previously full if (waterFull) { - WaterCheckConsecutiveReads++; + waterCheckConsecutiveReads++; - if (WaterCheckConsecutiveReads >= WaterCountsNeeded) { + if (waterCheckConsecutiveReads >= waterCountsNeeded) { waterFull = false; debugPrintf("Water empty\n"); - WaterCheckConsecutiveReads = 0; // Reset counter + waterCheckConsecutiveReads = 0; } } else { - WaterCheckConsecutiveReads = 0; // Reset counter if water was already empty + waterCheckConsecutiveReads = 0; } } } From a0c463171ae33678b5e8daa763cdb00209f1e186 Mon Sep 17 00:00:00 2001 From: Andreas Tacke Date: Sun, 10 Dec 2023 13:59:07 +0100 Subject: [PATCH 3/6] Increase water check interval duration, lower necessary consecutive reads, center icon and remove text --- src/display.h | 19 ++----------------- src/main.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/display.h b/src/display.h index 15868ed7..89f37ccf 100644 --- a/src/display.h +++ b/src/display.h @@ -22,19 +22,14 @@ void u8g2_prepare(void) { } /** - * Icons... - * Show water empty icon in upper right corner if water empty + * Show water empty icon in upper right corner if water supply is low */ void displayWaterIcon() { if (!waterFull) { - //small water empty logo u8g2.drawXBMP(119, 2, 8, 8, water_EMPTY_u8g2); } } -/** - * Collector to always show indicators along all the other information - */ void displayIcons() { displayWaterIcon(); } @@ -276,18 +271,8 @@ void Displaymachinestate() { // Water empty if (machineState == kWaterEmpty) { u8g2.clearBuffer(); - u8g2.setFontPosBottom(); - u8g2.setFont(u8g2_font_profont22_tr); - u8g2.drawStr(53, 26, "Fill"); - u8g2.drawStr(59, 42, "water"); - u8g2.drawXBMP( 3, 0, water_empty_big_width, water_empty_big_height, water_EMPTY_big_u8g2); + u8g2.drawXBMP( 45, 0, water_empty_big_width, water_empty_big_height, water_EMPTY_big_u8g2); u8g2.setFont(u8g2_font_profont11_tf); - u8g2.setCursor(80, 64); - u8g2.print(temperature); - u8g2.print((char)176); - u8g2.print("C"); - u8g2.setFontPosTop(); - displayIcons(); u8g2.sendBuffer(); } diff --git a/src/main.cpp b/src/main.cpp index 5d2358dc..02d7be84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -251,11 +251,11 @@ int flushCycles = 0; // number of active flush cycles int backflushState = 10; // counter for state machine // Water sensor -boolean waterFull = true; // Current state of water reservoir. If water sensor not installed, will stay always on "true" +boolean waterFull = true; unsigned long lastWaterCheck; -const unsigned long WaterCheckInterval = 20; // Check water level every .1s +const unsigned long WaterCheckInterval = 200; // Check water level every 200 ms int waterCheckConsecutiveReads = 0; // Counter for consecutive readings of water sensor -const int waterCountsNeeded = 5; // Number of same readings to change water sensing +const int waterCountsNeeded = 3; // Number of same readings to change water sensing // Moving average for software brew detection @@ -2487,7 +2487,7 @@ void loopWater() { if (waterCheckConsecutiveReads >= waterCountsNeeded) { waterFull = true; - debugPrintf("Water full\n"); + debugPrintln("Water full"); waterCheckConsecutiveReads = 0; } } @@ -2502,7 +2502,7 @@ void loopWater() { if (waterCheckConsecutiveReads >= waterCountsNeeded) { waterFull = false; - debugPrintf("Water empty\n"); + debugPrintln("Water empty"); waterCheckConsecutiveReads = 0; } } From 7b2980970382c314e27ce0a399f0d9e746e3af1f Mon Sep 17 00:00:00 2001 From: Andreas Tacke Date: Sun, 7 Jan 2024 19:51:03 +0100 Subject: [PATCH 4/6] Remove calls to small water icon that aren't actually being shown --- src/Displaytemplateminimal.h | 20 +++++----- src/Displaytemplatescale.h | 25 ++++++++----- src/Displaytemplatestandard.h | 19 ++++++---- src/Displaytemplatetemponly.h | 17 +++++---- src/display.h | 70 ++++++++++++----------------------- 5 files changed, 71 insertions(+), 80 deletions(-) diff --git a/src/Displaytemplateminimal.h b/src/Displaytemplateminimal.h index 8aa72438..038b9280 100644 --- a/src/Displaytemplateminimal.h +++ b/src/Displaytemplateminimal.h @@ -53,7 +53,8 @@ void printScreen() { u8g2.setFont(u8g2_font_profont22_tf); u8g2.print(setpoint, numDecimalsSetpoint); } - } else { + } + else { u8g2.setCursor(2, 2); u8g2.setFont(u8g2_font_profont22_tf); u8g2.print(temperature, numDecimalsInput); @@ -62,7 +63,8 @@ void printScreen() { if (pidMode == 1) { u8g2.print(char(74)); - } else { + } + else { u8g2.print(char(70)); } @@ -73,13 +75,10 @@ void printScreen() { if (brewcounter > kBrewIdle) { u8g2.setFont(u8g2_font_profont17_tf); - - // Brew u8g2.setCursor(2, 30); - } else { + } + else { u8g2.setFont(u8g2_font_profont10_tf); - - // Brew u8g2.setCursor(36, 30); } @@ -89,7 +88,8 @@ void printScreen() { if (ONLYPID == 1) { u8g2.print(brewtimesoftware, 0); - } else { + } + else { u8g2.print(totalBrewTime / 1000, 0); } @@ -112,13 +112,13 @@ void printScreen() { u8g2.drawFrame(116, 28, 12, 12); u8g2.drawXBMP(118, 30, 8, 8, antenna_NOK_u8g2); } - } else { + } + else { u8g2.drawFrame(116, 28, 12, 12); u8g2.setCursor(120, 30); u8g2.print("O"); } - displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/Displaytemplatescale.h b/src/Displaytemplatescale.h index d8a7ccc3..eee83d84 100644 --- a/src/Displaytemplatescale.h +++ b/src/Displaytemplatescale.h @@ -44,13 +44,15 @@ void printScreen() { u8g2.drawLine(12, 48, 12, 58 - (temperature / 2)); u8g2.drawLine(13, 48, 13, 58 - (temperature / 2)); } - } else if (temperature > 106) { + } + else if (temperature > 106) { u8g2.drawLine(9, 48, 9, 5); u8g2.drawLine(10, 48, 10, 4); u8g2.drawLine(11, 48, 11, 3); u8g2.drawLine(12, 48, 12, 4); u8g2.drawLine(13, 48, 13, 5); - } else { + } + else { u8g2.drawLine(9, 48, 9, 58 - (temperature / 2)); u8g2.drawLine(10, 48, 10, 58 - (temperature / 2)); u8g2.drawLine(11, 48, 11, 58 - (temperature / 2)); @@ -69,7 +71,8 @@ void printScreen() { if (ONLYPID == 1) { u8g2.print(brewtimesoftware, 0); // deaktivieren wenn Preinfusion ( // voransetzen ) - } else { + } + else { u8g2.print(totalBrewTime / 1000, 1); // aktivieren wenn Preinfusion und eine Nachkommastelle // oder alternativ keine } @@ -79,10 +82,12 @@ void printScreen() { if (scaleFailure) { u8g2.print("fault"); - } else { + } + else { if (brewswitch == LOW) { u8g2.print(weight, 0); - } else { + } + else { u8g2.print(weightBrew, 0); } @@ -114,7 +119,8 @@ void printScreen() { for (int b = 0; b <= signalBars; b++) { u8g2.drawVLine(45 + (b * 2), 10 - (b * 2), b * 2); } - } else { + } + else { u8g2.drawXBMP(40, 2, 8, 8, antenna_NOK_u8g2); u8g2.setCursor(88, 2); u8g2.print("RC: "); @@ -126,17 +132,18 @@ void printScreen() { u8g2.setCursor(60, 1); u8g2.setFont(u8g2_font_profont11_tf); u8g2.print("MQTT"); - } else { + } + else { u8g2.setCursor(60, 2); u8g2.print(""); } } - } else { + } + else { u8g2.setCursor(40, 2); u8g2.print("Offline Mode"); } - displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/Displaytemplatestandard.h b/src/Displaytemplatestandard.h index 306e6ed5..96eec1e8 100644 --- a/src/Displaytemplatestandard.h +++ b/src/Displaytemplatestandard.h @@ -52,13 +52,15 @@ void printScreen() u8g2.drawLine(12, 48, 12, 58 - (temperature / 2)); u8g2.drawLine(13, 48, 13, 58 - (temperature / 2)); } - } else if (temperature > 106) { + } + else if (temperature > 106) { u8g2.drawLine(9, 48, 9, 5); u8g2.drawLine(10, 48, 10, 4); u8g2.drawLine(11, 48, 11, 3); u8g2.drawLine(12, 48, 12, 4); u8g2.drawLine(13, 48, 13, 5); - } else { + } + else { u8g2.drawLine(9, 48, 9, 58 - (temperature / 2)); u8g2.drawLine(10, 48, 10, 58 - (temperature / 2)); u8g2.drawLine(11, 48, 11, 58 - (temperature / 2)); @@ -88,7 +90,8 @@ void printScreen() if (pidOutput < 99) { u8g2.print(pidOutput / 10, 1); - } else { + } + else { u8g2.print(pidOutput / 10, 0); } @@ -110,7 +113,8 @@ void printScreen() else { u8g2.print(totalBrewTime / 1000, 1); // Activate if pre-infusion and one decimal place or alternatively none } - } else { + } + else { // Show uptime of machine u8g2.print(langstring_uptime); float seconds = millis() / 1000; @@ -138,7 +142,8 @@ void printScreen() for (int b = 0; b <= signalBars; b++) { u8g2.drawVLine(45 + (b * 2), 10 - (b * 2), b * 2); } - } else { + } + else { u8g2.drawXBMP(40, 2, 8, 8, antenna_NOK_u8g2); u8g2.setCursor(88, 1); u8g2.print("RC: "); @@ -155,12 +160,12 @@ void printScreen() u8g2.print(""); } } - } else { + } + else { u8g2.setCursor(40, 1); u8g2.print(langstring_offlinemode); } - displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/Displaytemplatetemponly.h b/src/Displaytemplatetemponly.h index 8425e15a..b8403355 100644 --- a/src/Displaytemplatetemponly.h +++ b/src/Displaytemplatetemponly.h @@ -18,8 +18,8 @@ void printScreen() { if ((machineState == kAtSetpoint || 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)) { - + ((machineState == kPidOffline) && OFFLINEGLOGO == 0)) + { if (!sensorError) { u8g2.clearBuffer(); @@ -31,18 +31,21 @@ void printScreen() { u8g2.setCursor(13, 12); u8g2.setFont(u8g2_font_fub35_tf); u8g2.print(temperature, 1); - } else { + } + else { u8g2.setCursor(-1, 12); u8g2.setFont(u8g2_font_fub35_tf); u8g2.print(temperature, 1); } } - } else { + } + else { if (temperature < 99.999) { u8g2.setCursor(13, 12); u8g2.setFont(u8g2_font_fub35_tf); u8g2.print(temperature, 1); - } else { + } + else { u8g2.setCursor(-1, 12); u8g2.setFont(u8g2_font_fub35_tf); u8g2.print(temperature, 1); @@ -58,13 +61,13 @@ void printScreen() { u8g2.drawFrame(116, 28, 12, 12); u8g2.drawXBMP(118, 30, 8, 8, antenna_NOK_u8g2); } - } else { + } + else { u8g2.drawFrame(116, 28, 12, 12); u8g2.setCursor(120, 30); u8g2.print("O"); } - displayIcons(); u8g2.sendBuffer(); } } diff --git a/src/display.h b/src/display.h index 89f37ccf..e193cd44 100644 --- a/src/display.h +++ b/src/display.h @@ -8,7 +8,6 @@ #if (OLED_DISPLAY != 0) - /** * @brief initialize display */ @@ -22,16 +21,12 @@ void u8g2_prepare(void) { } /** - * Show water empty icon in upper right corner if water supply is low + * @brief Show water empty icon in upper right corner if water supply is low */ -void displayWaterIcon() { - if (!waterFull) { - u8g2.drawXBMP(119, 2, 8, 8, water_EMPTY_u8g2); - } -} - -void displayIcons() { - displayWaterIcon(); +void displayWaterIcon(int x, int y) { + if (!waterFull) { + u8g2.drawXBMP(x, y, 8, 8, water_EMPTY_u8g2); + } } /** @@ -51,7 +46,6 @@ void displayMessage(String text1, String text2, String text3, String text4, Stri u8g2.print(text5); u8g2.setCursor(0, 50); u8g2.print(text6); - displayIcons(); u8g2.sendBuffer(); } @@ -67,41 +61,22 @@ void displayLogo(String displaymessagetext, String displaymessagetext2) { // Rancilio startup logo switch (machine) { case RancilioSilvia: // Rancilio - u8g2.drawXBMP(41, 2, startLogoRancilio_width, startLogoRancilio_height, - startLogoRancilio_bits); + u8g2.drawXBMP(41, 2, startLogoRancilio_width, startLogoRancilio_height, startLogoRancilio_bits); break; case RancilioSilviaE: // Rancilio - u8g2.drawXBMP(41, 2, startLogoRancilio_width, startLogoRancilio_height, - startLogoRancilio_bits); + u8g2.drawXBMP(41, 2, startLogoRancilio_width, startLogoRancilio_height, startLogoRancilio_bits); break; case Gaggia: // Gaggia - u8g2.drawXBMP(0, 2, startLogoGaggia_width, startLogoGaggia_height, - startLogoGaggia_bits); + u8g2.drawXBMP(0, 2, startLogoGaggia_width, startLogoGaggia_height, startLogoGaggia_bits); break; case QuickMill: // Quickmill - u8g2.drawXBMP(22, 0, startLogoQuickMill_width, startLogoQuickMill_height, - startLogoQuickMill_bits); + u8g2.drawXBMP(22, 0, startLogoQuickMill_width, startLogoQuickMill_height, startLogoQuickMill_bits); break; } - displayIcons(); - u8g2.sendBuffer(); -} -/** - * @brief calibration mode - * - * @param display_distance - */ -void displayDistance(int display_distance) { - u8g2.clearBuffer(); - u8g2.setCursor(13, 12); - u8g2.setFont(u8g2_font_fub20_tf); - u8g2.printf("%d", display_distance); - u8g2.print("mm"); - displayIcons(); u8g2.sendBuffer(); } @@ -118,7 +93,7 @@ void displayShottimer(void) { u8g2.setCursor(64, 25); u8g2.print(timeBrewed / 1000, 1); u8g2.setFont(u8g2_font_profont11_tf); - displayIcons(); + displayWaterIcon(119, 1); u8g2.sendBuffer(); } @@ -133,7 +108,7 @@ void displayShottimer(void) { u8g2.setCursor(64, 25); u8g2.print(lastbrewTime / 1000, 1); u8g2.setFont(u8g2_font_profont11_tf); - displayIcons(); + displayWaterIcon(119, 1); u8g2.sendBuffer(); } @@ -151,7 +126,7 @@ void displayShottimer(void) { u8g2.print(weightBrew, 0); u8g2.print("g"); u8g2.setFont(u8g2_font_profont11_tf); - displayIcons(); + displayWaterIcon(119, 1); u8g2.sendBuffer(); } @@ -166,7 +141,7 @@ void displayShottimer(void) { u8g2.print(weightBrew, 0); u8g2.print(" g"); u8g2.setFont(u8g2_font_profont11_tf); - displayIcons(); + displayWaterIcon(119, 1); u8g2.sendBuffer(); } #endif @@ -191,7 +166,8 @@ void Displaymachinestate() { for (int b = 0; b <= signalBars; b++) { u8g2.drawVLine(45 + (b * 2), 10 - (b * 2), b * 2); } - } else { + } + else { u8g2.drawXBMP(40, 2, 8, 8, antenna_NOK_u8g2); u8g2.setCursor(88, 1); u8g2.print("RC: "); @@ -203,7 +179,8 @@ void Displaymachinestate() { u8g2.setCursor(60, 1); u8g2.setFont(u8g2_font_profont11_tf); u8g2.print("MQTT"); - } else { + } + else { u8g2.setCursor(60, 2); u8g2.print(""); } @@ -231,7 +208,6 @@ void Displaymachinestate() { u8g2.setCursor(92, 30); u8g2.setFont(u8g2_font_profont17_tf); u8g2.print(temperature, 1); - displayIcons(); u8g2.sendBuffer(); } @@ -242,7 +218,6 @@ void Displaymachinestate() { u8g2.setCursor(0, 55); u8g2.setFont(u8g2_font_profont10_tf); u8g2.print("PID is disabled manually"); - displayIcons(); u8g2.sendBuffer(); } @@ -252,7 +227,6 @@ void Displaymachinestate() { u8g2.setCursor(36, 55); u8g2.setFont(u8g2_font_profont10_tf); u8g2.print("Standby mode"); - displayIcons(); u8g2.sendBuffer(); } @@ -264,7 +238,7 @@ void Displaymachinestate() { u8g2.setFont(u8g2_font_profont22_tf); u8g2.print(temperature, 0); u8g2.setCursor(64, 25); - displayIcons(); + displayWaterIcon(119, 1); u8g2.sendBuffer(); } @@ -283,11 +257,13 @@ void Displaymachinestate() { #if OLED_DISPLAY != 0 displayMessage(langstring_bckffinished[0], langstring_bckffinished[1], "", "", "", ""); #endif - } else if (backflushState == 10) { + } + else if (backflushState == 10) { #if OLED_DISPLAY != 0 displayMessage(langstring_bckfactivated[0], langstring_bckfactivated[1], "", "", "", ""); #endif - } else if (backflushState > 10) { + } + else if (backflushState > 10) { #if OLED_DISPLAY != 0 displayMessage(langstring_bckfrunning[0], String(flushCycles), langstring_bckfrunning[1], String(maxflushCycles), "", ""); #endif @@ -323,7 +299,6 @@ void Displaymachinestate() { u8g2.print("PID STOPPED"); } - displayIcons(); u8g2.sendBuffer(); } @@ -339,4 +314,5 @@ void Displaymachinestate() { displayMessage("EEPROM Error, please set Values", "", "", "", "", ""); } } + #endif From 6789193b48f44bce5f8bd9bd603510342c83b993 Mon Sep 17 00:00:00 2001 From: Makuro Date: Mon, 8 Jan 2024 13:53:33 +0100 Subject: [PATCH 5/6] Removed duplicate Setemergencystoptemp --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 02d7be84..1730da3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2322,7 +2322,6 @@ void looppid() { brew(); } - setEmergencyStopTemp(); checkSteamSwitch(); checkPowerSwitch(); From 52f919e868ab3aa316330fb866089f8f66b11dd3 Mon Sep 17 00:00:00 2001 From: Makuro Date: Mon, 8 Jan 2024 14:08:32 +0100 Subject: [PATCH 6/6] waterCheckInterval variable name updated --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1730da3c..0bf3dee3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -253,7 +253,7 @@ int backflushState = 10; // counter for state machine // Water sensor boolean waterFull = true; unsigned long lastWaterCheck; -const unsigned long WaterCheckInterval = 200; // Check water level every 200 ms +const unsigned long waterCheckInterval = 200; // Check water level every 200 ms int waterCheckConsecutiveReads = 0; // Counter for consecutive readings of water sensor const int waterCountsNeeded = 3; // Number of same readings to change water sensing @@ -2474,7 +2474,7 @@ void loopLED() { } void loopWater() { - if ((millis() - lastWaterCheck) > WaterCheckInterval) { + if ((millis() - lastWaterCheck) > waterCheckInterval) { lastWaterCheck = millis(); bool isWaterDetected = digitalRead(PIN_WATERSENSOR) == (WATER_SENS == 1 ? LOW : HIGH);