From 91c159758f5703b8e6f830376171f7d5d127f757 Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:32:11 +0100 Subject: [PATCH 01/12] WIP - adjustments for MonoMenu --- platformio.ini | 3 +++ src/hardware/GPIOPin.cpp | 4 ++++ src/hardware/GPIOPin.h | 6 ++++++ src/hardware/pinmapping.h | 5 +++++ src/main.cpp | 26 ++++++++++++++++++++++++++ 5 files changed, 44 insertions(+) diff --git a/platformio.ini b/platformio.ini index 6f1a522e7..b4b5f6896 100644 --- a/platformio.ini +++ b/platformio.ini @@ -24,6 +24,9 @@ lib_deps = git+https://github.com/esphome/AsyncTCP @ 2.1.3 git+https://github.com/esphome/ESPAsyncWebServer#f2a65ff git+https://github.com/tzapu/WiFiManager @ 2.0.17 + git+https://github.com/madhephaestus/ESP32Encoder#9979722 + git+https://github.com/craftmetrics/esp32-button.git#36c6c0a + git+https://github.com/chris-dot-exe/MonoMenu#7f03578 extra_scripts = pre:auto_firmware_version.py pre:run_clangformat.py diff --git a/src/hardware/GPIOPin.cpp b/src/hardware/GPIOPin.cpp index b2fd9bf32..872e0a3a9 100644 --- a/src/hardware/GPIOPin.cpp +++ b/src/hardware/GPIOPin.cpp @@ -55,3 +55,7 @@ void GPIOPin::setType(Type pinType) { break; } } + +int GPIOPin::getPinNumber() const { + return pin; +} \ No newline at end of file diff --git a/src/hardware/GPIOPin.h b/src/hardware/GPIOPin.h index 7c72ed6d7..77553fd48 100644 --- a/src/hardware/GPIOPin.h +++ b/src/hardware/GPIOPin.h @@ -59,6 +59,12 @@ class GPIOPin { */ Type getType() const; + /** + * @brief Returns pin number of this GPIO pin + * @return Pin number of this pin + */ + int getPinNumber() const; + private: /** * @brief Set the type of the GPIO pin diff --git a/src/hardware/pinmapping.h b/src/hardware/pinmapping.h index 3baa39585..dd9f1fca7 100644 --- a/src/hardware/pinmapping.h +++ b/src/hardware/pinmapping.h @@ -21,6 +21,11 @@ #define PIN_ROTARY_CLK 3 // Rotary encoder clock pin #define PIN_ROTARY_SW 5 // Rotary encoder switch +// Menu Input +#define PIN_MENU_OUT_A 4 // Menu Input - Rotary encoder Output A / Data pin or down button +#define PIN_MENU_OUT_B 3 // Menu Input - Rotary encoder Output B / CLK pin or up button +#define PIN_MENU_ENTER 5 // Menu Input - Rotary encoder switch or enter button + // Sensors #define PIN_TEMPSENSOR 16 #define PIN_WATERSENSOR 23 diff --git a/src/main.cpp b/src/main.cpp index 6efc0cbae..ec10daeac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -328,6 +328,8 @@ Timer logbrew([&]() { LOGF(DEBUG, "(tB,T,hra) --> %5.2f %6.2f %8.2f", (double)(m // Embedded HTTP Server #include "embeddedWebserver.h" +#include "menuHandler.h" + enum SectionNames { sPIDSection, sTempSection, @@ -1644,6 +1646,9 @@ void setup() { u8g2_prepare(); displayLogo(String("Version "), String(sysVersion)); delay(2000); // caused crash with wifi manager on esp8266, should be ok on esp32 + + initMenu(u8g2); + #endif // Fallback offline @@ -1859,6 +1864,27 @@ void looppid() { // Check if PID should run or not. If not, set to manual and force output to zero #if OLED_DISPLAY != 0 printDisplayTimer(); + + if (menu != nullptr) { + menu->EventHandler(); + menu->Loop(); + } + + if (menu == nullptr || !menu->IsOpen()) { + unsigned long currentMillisDisplay = millis(); + + if (currentMillisDisplay - previousMillisDisplay >= 100) { + displayShottimer(); + } + + if (currentMillisDisplay - previousMillisDisplay >= intervalDisplay) { + previousMillisDisplay = currentMillisDisplay; +#if DISPLAYTEMPLATE < 20 // not using vertical template + displayMachineState(); +#endif + printScreen(); // refresh display + } + } #endif if (machineState == kPidDisabled || machineState == kWaterEmpty || machineState == kSensorError || machineState == kEmergencyStop || machineState == kEepromError || machineState == kStandby || brewPIDDisabled) { From 961849680706956bc062521c4f02613ec980127e Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:33:25 +0100 Subject: [PATCH 02/12] WIP - adjustments for MonoMenu --- src/menuHandler.h | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 src/menuHandler.h diff --git a/src/menuHandler.h b/src/menuHandler.h new file mode 100644 index 000000000..9c54061f7 --- /dev/null +++ b/src/menuHandler.h @@ -0,0 +1,131 @@ + +#pragma once + +#include +#include +#include +#include + +enum MENUINPUT { + BUTTONS, + ROTARY, +}; + +Menu* menu; +GPIOPin* menuEnterPin; +GPIOPin* menuUpPin; +GPIOPin* menuDownPin; +QueueHandle_t button_events; +button_event_t ev; + + +bool showMaintenance() { + return BREWCONTROL_TYPE > 0; +} + +bool showBrewPIDSettings() { + return FEATURE_BREWDETECTION > 0; +} + + +void menuInputInit() { + if (MENU_INPUT == MENUINPUT::BUTTONS) { + menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); + menuUpPin = new GPIOPin(PIN_MENU_OUT_A, GPIOPin::IN_PULLUP); + menuDownPin = new GPIOPin(PIN_MENU_OUT_B, GPIOPin::IN_PULLUP); + + button_events = pulled_button_init( + PIN_BIT(menuEnterPin->getPinNumber()) | + PIN_BIT(menuUpPin->getPinNumber()) | + PIN_BIT(menuDownPin->getPinNumber()), GPIO_PULLUP_ONLY + ); + } +} + +void initMenu(U8G2& display) { + menu = new Menu(display); + + menuInputInit(); + + /* Main Menu */ + menu->AddInputItem("Brew Temp.", "Brew Temperature", "", "°C", BREW_SETPOINT_MIN, BREW_SETPOINT_MAX, []() { sysParaPidOn.setStorage(); }, brewSetpoint, bitmap_icon_temp, 0.1, 0.5, true); + menu->AddInputItem("Steam Temp.", "Steam Temperature", "", "°C", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, []() { sysParaSteamSetpoint.setStorage(); }, steamSetpoint, bitmap_icon_steam); + + menu->AddToggleItem("PID", []() { sysParaPidOn.setStorage(); }, reinterpret_cast(pidON), bitmap_icon_pid); + + menu->SetEventHandler([&]() { + if (xQueueReceive(button_events, &ev, 1 / portTICK_PERIOD_MS)) { + if (ev.pin == menuEnterPin->getPinNumber()) { + menu->Event(EVENT_ENTER, EventState(ev.event)); + } else if (ev.pin == menuUpPin->getPinNumber()) { + menu->Event(EVENT_UP, EventState(ev.event)); + } else if (ev.pin == menuDownPin->getPinNumber()) { + menu->Event(EVENT_DOWN, EventState(ev.event)); + } + } + }); + + /* Brew Weight & Time */ + Menu* weightNTime = new Menu(display); + weightNTime->AddInputItem("Brew by Time", "Brew Time", "", " s", BREW_TIME_MIN, BREW_TIME_MAX, []() { sysParaBrewTime.setStorage(); }, brewTime, bitmap_icon_clock); + weightNTime->AddInputItem("Brew by Weight", "Brew Weight", "", "g", WEIGHTSETPOINT_MIN, WEIGHTSETPOINT_MAX, []() { sysParaWeightSetpoint.setStorage(); }, weightSetpoint, bitmap_icon_scale); + weightNTime->AddBackItem("Back", bitmap_icon_back); + menu->AddSubMenu("Brew Time & Weight", *weightNTime, false); + + /* Preinfusion */ + Menu* preInfusion = new Menu(display); + preInfusion->AddInputItem("Preinfusion Pause", "Pause", "", "s", PRE_INFUSION_PAUSE_MIN, PRE_INFUSION_PAUSE_MAX, []() { sysParaPreInfPause.setStorage(); }, preinfusionPause, 1.0, 2.0, true); + preInfusion->AddInputItem("Preinfusion", "Time", "", "s", PRE_INFUSION_TIME_MIN, PRE_INFUSION_TIME_MAX, []() { sysParaPreInfTime.setStorage(); }, preinfusion, 1.0, 2.0, true); + preInfusion->AddBackItem("Back", bitmap_icon_back); + menu->AddSubMenu("Preinfusion", *preInfusion, false); + /* + * Maintenance Menu + * */ + Menu* maintenanceMenu = new Menu(display); + maintenanceMenu->AddToggleItem("Backflush", reinterpret_cast(backflushOn), bitmap_icon_refresh); + maintenanceMenu->AddBackItem("Back", bitmap_icon_back); + + menu->AddSubMenu("Maintenance", *maintenanceMenu, bitmap_icon_tools, showMaintenance()); + + /* + * Advanced Menu + */ + + Menu* advancedMenu = new Menu(display); + advancedMenu->AddInputItem("Brew Temp. Offset", "Brew temp. offset", "", "°C", BREW_TEMP_OFFSET_MIN, BREW_TEMP_OFFSET_MAX, []() { sysParaTempOffset.setStorage(); }, brewTempOffset, bitmap_icon_temp); + /* + * Standby Menu + */ + Menu* standbyMenu = new Menu(display); + standbyMenu->AddToggleItem("Standby", []() { sysParaStandbyModeOn.setStorage(); }, reinterpret_cast(standbyModeOn), true); + standbyMenu->AddInputItem("Standby Time", "Standby Time", "", " m", STANDBY_MODE_TIME_MIN, STANDBY_MODE_TIME_MAX, []() { sysParaStandbyModeTime.setStorage(); }, standbyModeTime, bitmap_icon_clock, 1.0, 2.0, true); + + standbyMenu->AddBackItem("Back", bitmap_icon_back); + advancedMenu->AddSubMenu("Standby", *standbyMenu, bitmap_icon_sleep_mode); + + /* PID Settings */ + Menu* pidSettings = new Menu(display); + pidSettings->AddToggleItem("Enable PonM", []() { sysParaUsePonM.setStorage(); }, reinterpret_cast(usePonM)); + pidSettings->AddInputItem("Start Kp", "Start Kp", "", "", PID_KP_START_MIN, PID_KP_START_MAX, []() { (sysParaPidKpStart.setStorage()); }, startKp); + pidSettings->AddInputItem("Start Tn", "Start Tn", "", "", PID_TN_START_MIN, PID_TN_START_MAX, []() { sysParaPidTnStart.setStorage(); }, startTn); + pidSettings->AddInputItem("Kp", "Kp", "", "", PID_KP_REGULAR_MIN, PID_KP_REGULAR_MAX, []() { sysParaPidKpReg.setStorage(); }, aggKp); + pidSettings->AddInputItem("Tn", "Tn (=Kp/Ki)", "", "", PID_TN_REGULAR_MIN, PID_TN_REGULAR_MAX, []() { sysParaPidTnReg.setStorage(); }, aggTn); + pidSettings->AddInputItem("Tv", "Tv (=Kd/Kp)", "", "", PID_TV_REGULAR_MIN, PID_TV_REGULAR_MAX, []() { sysParaPidTvReg.setStorage(); }, aggTv); + pidSettings->AddInputItem("Integrator Max", "Integrator Max", "", "", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, []() { sysParaPidIMaxReg.setStorage(); }, aggIMax); + pidSettings->AddInputItem("Steam Kp", "Steam Kp", "", "", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, []() { sysParaPidKpSteam.setStorage(); }, steamKp); + pidSettings->AddBackItem("Back", bitmap_icon_back); + + /* Brew PID Settings */ + + + advancedMenu->AddSubMenu("PID Settings", *pidSettings, bitmap_icon_pid); + advancedMenu->AddBackItem("Back", bitmap_icon_back); + menu->AddSubMenu("Advanced", *advancedMenu, bitmap_icon_settings); + + menu->AddBackItem("Close Menu", bitmap_icon_back); + menu->Init(); +} + +void menuLoop() { + menu->Loop(); +} \ No newline at end of file From 32e908242c6abae9d2733012fab36bf205566990 Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Wed, 17 Apr 2024 01:04:25 +0200 Subject: [PATCH 03/12] Save functions; added more items; exit standby with display buttons; added visible logic --- src/menuHandler.h | 106 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 25 deletions(-) diff --git a/src/menuHandler.h b/src/menuHandler.h index 9c54061f7..19f43797d 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -19,15 +19,40 @@ QueueHandle_t button_events; button_event_t ev; -bool showMaintenance() { +void saveBrewTemp() { + sysParaBrewSetpoint.setStorage(true); +} + +void saveSteamTemp() { + sysParaSteamSetpoint.setStorage(true); +} + +void savePIDOn() { + sysParaPidOn.setStorage(true); +} + +void saveStandby() { + sysParaStandbyModeOn.setStorage(true); +} + +void saveStandbyTime() { + sysParaStandbyModeTime.setStorage(true); +} + +bool hasBrewControl() { return BREWCONTROL_TYPE > 0; } -bool showBrewPIDSettings() { - return FEATURE_BREWDETECTION > 0; +bool hasScale() { + return FEATURE_SCALE > 0; +} + +bool hasSoftwareDetection() { + return BREWDETECTION_TYPE == 1; } + void menuInputInit() { if (MENU_INPUT == MENUINPUT::BUTTONS) { menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); @@ -48,18 +73,40 @@ void initMenu(U8G2& display) { menuInputInit(); /* Main Menu */ - menu->AddInputItem("Brew Temp.", "Brew Temperature", "", "°C", BREW_SETPOINT_MIN, BREW_SETPOINT_MAX, []() { sysParaPidOn.setStorage(); }, brewSetpoint, bitmap_icon_temp, 0.1, 0.5, true); - menu->AddInputItem("Steam Temp.", "Steam Temperature", "", "°C", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, []() { sysParaSteamSetpoint.setStorage(); }, steamSetpoint, bitmap_icon_steam); + menu->AddInputItem("Brew Temp.", "Brew Temperature", "", "°C", BREW_SETPOINT_MIN, BREW_SETPOINT_MAX, saveBrewTemp, brewSetpoint, bitmap_icon_temp, 0.1, 0.5); + menu->AddInputItem("Steam Temp.", "Steam Temperature", "", "°C", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, saveSteamTemp, steamSetpoint, bitmap_icon_steam, 0.1, 0.5); - menu->AddToggleItem("PID", []() { sysParaPidOn.setStorage(); }, reinterpret_cast(pidON), bitmap_icon_pid); + menu->AddToggleItem("PID", savePIDOn, reinterpret_cast(pidON), bitmap_icon_pid); menu->SetEventHandler([&]() { if (xQueueReceive(button_events, &ev, 1 / portTICK_PERIOD_MS)) { + if (ev.pin == menuEnterPin->getPinNumber()) { + if (standbyModeRemainingTimeMillis == 0) { + resetStandbyTimer(); + display.setPowerSave(0); + pidON = 1; + if (steamON) { + machineState = kSteam; + } + else if (isBrewDetected) { + machineState = kBrew; + } + else { + machineState = kPidOffline; + } + return; + } + if (ev.event == EventState::STATE_DOWN) { + resetStandbyTimer(); + } menu->Event(EVENT_ENTER, EventState(ev.event)); + } else if (ev.pin == menuUpPin->getPinNumber()) { + resetStandbyTimer(); menu->Event(EVENT_UP, EventState(ev.event)); } else if (ev.pin == menuDownPin->getPinNumber()) { + resetStandbyTimer(); menu->Event(EVENT_DOWN, EventState(ev.event)); } } @@ -67,17 +114,17 @@ void initMenu(U8G2& display) { /* Brew Weight & Time */ Menu* weightNTime = new Menu(display); - weightNTime->AddInputItem("Brew by Time", "Brew Time", "", " s", BREW_TIME_MIN, BREW_TIME_MAX, []() { sysParaBrewTime.setStorage(); }, brewTime, bitmap_icon_clock); - weightNTime->AddInputItem("Brew by Weight", "Brew Weight", "", "g", WEIGHTSETPOINT_MIN, WEIGHTSETPOINT_MAX, []() { sysParaWeightSetpoint.setStorage(); }, weightSetpoint, bitmap_icon_scale); + weightNTime->AddInputItem("Brew by Time", "Brew Time", "", " s", BREW_TIME_MIN, BREW_TIME_MAX, []() { sysParaBrewTime.setStorage(true); }, brewTime, bitmap_icon_clock); + weightNTime->AddInputItem("Brew by Weight", "Brew Weight", "", "g", WEIGHTSETPOINT_MIN, WEIGHTSETPOINT_MAX, []() { sysParaWeightSetpoint.setStorage(true); }, weightSetpoint, bitmap_icon_scale, hasScale()); weightNTime->AddBackItem("Back", bitmap_icon_back); - menu->AddSubMenu("Brew Time & Weight", *weightNTime, false); + menu->AddSubMenu("Brew Time & Weight", *weightNTime, hasBrewControl()); /* Preinfusion */ Menu* preInfusion = new Menu(display); - preInfusion->AddInputItem("Preinfusion Pause", "Pause", "", "s", PRE_INFUSION_PAUSE_MIN, PRE_INFUSION_PAUSE_MAX, []() { sysParaPreInfPause.setStorage(); }, preinfusionPause, 1.0, 2.0, true); - preInfusion->AddInputItem("Preinfusion", "Time", "", "s", PRE_INFUSION_TIME_MIN, PRE_INFUSION_TIME_MAX, []() { sysParaPreInfTime.setStorage(); }, preinfusion, 1.0, 2.0, true); + preInfusion->AddInputItem("Preinfusion Pause", "Pause", "", "s", PRE_INFUSION_PAUSE_MIN, PRE_INFUSION_PAUSE_MAX, []() { sysParaPreInfPause.setStorage(true); }, preinfusionPause, 1.0, 2.0, true); + preInfusion->AddInputItem("Preinfusion", "Time", "", "s", PRE_INFUSION_TIME_MIN, PRE_INFUSION_TIME_MAX, []() { sysParaPreInfTime.setStorage(true); }, preinfusion, 1.0, 2.0, true); preInfusion->AddBackItem("Back", bitmap_icon_back); - menu->AddSubMenu("Preinfusion", *preInfusion, false); + menu->AddSubMenu("Preinfusion", *preInfusion, hasBrewControl()); /* * Maintenance Menu * */ @@ -85,38 +132,47 @@ void initMenu(U8G2& display) { maintenanceMenu->AddToggleItem("Backflush", reinterpret_cast(backflushOn), bitmap_icon_refresh); maintenanceMenu->AddBackItem("Back", bitmap_icon_back); - menu->AddSubMenu("Maintenance", *maintenanceMenu, bitmap_icon_tools, showMaintenance()); + menu->AddSubMenu("Maintenance", *maintenanceMenu, bitmap_icon_tools, hasBrewControl()); /* * Advanced Menu */ Menu* advancedMenu = new Menu(display); - advancedMenu->AddInputItem("Brew Temp. Offset", "Brew temp. offset", "", "°C", BREW_TEMP_OFFSET_MIN, BREW_TEMP_OFFSET_MAX, []() { sysParaTempOffset.setStorage(); }, brewTempOffset, bitmap_icon_temp); + advancedMenu->AddInputItem("Brew Temp. Offset", "Brew temp. offset", "", "°C", BREW_TEMP_OFFSET_MIN, BREW_TEMP_OFFSET_MAX, []() { sysParaTempOffset.setStorage(true); }, brewTempOffset, bitmap_icon_temp); /* * Standby Menu */ Menu* standbyMenu = new Menu(display); - standbyMenu->AddToggleItem("Standby", []() { sysParaStandbyModeOn.setStorage(); }, reinterpret_cast(standbyModeOn), true); - standbyMenu->AddInputItem("Standby Time", "Standby Time", "", " m", STANDBY_MODE_TIME_MIN, STANDBY_MODE_TIME_MAX, []() { sysParaStandbyModeTime.setStorage(); }, standbyModeTime, bitmap_icon_clock, 1.0, 2.0, true); + standbyMenu->AddToggleItem("Standby", saveStandby, reinterpret_cast(standbyModeOn), true); + standbyMenu->AddInputItem("Standby Time", "Standby Time", "", " m", STANDBY_MODE_TIME_MIN, STANDBY_MODE_TIME_MAX, saveStandbyTime, standbyModeTime, bitmap_icon_clock, 1.0, 2.0, true); standbyMenu->AddBackItem("Back", bitmap_icon_back); advancedMenu->AddSubMenu("Standby", *standbyMenu, bitmap_icon_sleep_mode); /* PID Settings */ Menu* pidSettings = new Menu(display); - pidSettings->AddToggleItem("Enable PonM", []() { sysParaUsePonM.setStorage(); }, reinterpret_cast(usePonM)); - pidSettings->AddInputItem("Start Kp", "Start Kp", "", "", PID_KP_START_MIN, PID_KP_START_MAX, []() { (sysParaPidKpStart.setStorage()); }, startKp); - pidSettings->AddInputItem("Start Tn", "Start Tn", "", "", PID_TN_START_MIN, PID_TN_START_MAX, []() { sysParaPidTnStart.setStorage(); }, startTn); - pidSettings->AddInputItem("Kp", "Kp", "", "", PID_KP_REGULAR_MIN, PID_KP_REGULAR_MAX, []() { sysParaPidKpReg.setStorage(); }, aggKp); - pidSettings->AddInputItem("Tn", "Tn (=Kp/Ki)", "", "", PID_TN_REGULAR_MIN, PID_TN_REGULAR_MAX, []() { sysParaPidTnReg.setStorage(); }, aggTn); - pidSettings->AddInputItem("Tv", "Tv (=Kd/Kp)", "", "", PID_TV_REGULAR_MIN, PID_TV_REGULAR_MAX, []() { sysParaPidTvReg.setStorage(); }, aggTv); - pidSettings->AddInputItem("Integrator Max", "Integrator Max", "", "", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, []() { sysParaPidIMaxReg.setStorage(); }, aggIMax); - pidSettings->AddInputItem("Steam Kp", "Steam Kp", "", "", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, []() { sysParaPidKpSteam.setStorage(); }, steamKp); + pidSettings->AddToggleItem("Enable PonM", []() { sysParaUsePonM.setStorage(true); }, reinterpret_cast(usePonM)); + pidSettings->AddInputItem("Start Kp", "Start Kp", "", "", PID_KP_START_MIN, PID_KP_START_MAX, []() { (sysParaPidKpStart.setStorage(true)); }, startKp); + pidSettings->AddInputItem("Start Tn", "Start Tn", "", "", PID_TN_START_MIN, PID_TN_START_MAX, []() { sysParaPidTnStart.setStorage(true); }, startTn); + pidSettings->AddInputItem("Kp", "Kp", "", "", PID_KP_REGULAR_MIN, PID_KP_REGULAR_MAX, []() { sysParaPidKpReg.setStorage(true); }, aggKp); + pidSettings->AddInputItem("Tn", "Tn (=Kp/Ki)", "", "", PID_TN_REGULAR_MIN, PID_TN_REGULAR_MAX, []() { sysParaPidTnReg.setStorage(true); }, aggTn); + pidSettings->AddInputItem("Tv", "Tv (=Kd/Kp)", "", "", PID_TV_REGULAR_MIN, PID_TV_REGULAR_MAX, []() { sysParaPidTvReg.setStorage(true); }, aggTv); + pidSettings->AddInputItem("Integrator Max", "Integrator Max", "", "", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, []() { sysParaPidIMaxReg.setStorage(true); }, aggIMax); + pidSettings->AddInputItem("Steam Kp", "Steam Kp", "", "", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, []() { sysParaPidKpSteam.setStorage(true); }, steamKp); pidSettings->AddBackItem("Back", bitmap_icon_back); /* Brew PID Settings */ - + Menu * brewPidSettings = new Menu(display); + brewPidSettings->AddToggleItem("Enable Brew PID", []() { sysParaUsePonM.setStorage(true); }, reinterpret_cast(useBDPID)); + brewPidSettings->AddInputItem("BD Kp", "BD Kp", "", "", PID_KP_BD_MIN, PID_KP_BD_MAX, []() { sysParaPidKpBd.setStorage(true); }, aggbKp); + brewPidSettings->AddInputItem("BD Tn", "BD Tn (=Kp/Ki)", "", "", PID_TN_BD_MIN, PID_TN_BD_MAX, []() { sysParaPidTnBd.setStorage(true); }, aggbTn); + brewPidSettings->AddInputItem("BD Tv", "BD Tv (=Kd/Kp)", "", "", PID_TV_BD_MIN, PID_TV_BD_MAX, []() { sysParaPidTvBd.setStorage(true); }, aggbTv); + brewPidSettings->AddInputItem("PID BD Time", "PID BD Time", "", "s", BREW_SW_TIME_MIN, BREW_SW_TIME_MAX, []() { sysParaBrewSwTime.setStorage(true); }, brewtimesoftware, hasSoftwareDetection()); + brewPidSettings->AddInputItem("PID BD Sensitivity", "Sensitivity", "", "", BD_THRESHOLD_MIN, BD_THRESHOLD_MAX, []() { sysParaBrewThresh.setStorage(true); }, brewSensitivity, hasSoftwareDetection()); + brewPidSettings->AddBackItem("Back", bitmap_icon_back); + + pidSettings->AddSubMenu("Brew PID", *brewPidSettings); advancedMenu->AddSubMenu("PID Settings", *pidSettings, bitmap_icon_pid); advancedMenu->AddBackItem("Back", bitmap_icon_back); From 4ca71b28c6765a8ea71c2cb79f0e7ef69aa3e5ad Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:56:04 +0200 Subject: [PATCH 04/12] Updated to latest master of clever coffee. Updated MonoMenu version. --- platformio.ini | 2 +- src/menuHandler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index b4b5f6896..b7ca18d1f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -26,7 +26,7 @@ lib_deps = git+https://github.com/tzapu/WiFiManager @ 2.0.17 git+https://github.com/madhephaestus/ESP32Encoder#9979722 git+https://github.com/craftmetrics/esp32-button.git#36c6c0a - git+https://github.com/chris-dot-exe/MonoMenu#7f03578 + git+https://github.com/chris-dot-exe/MonoMenu @ 0.1.2 extra_scripts = pre:auto_firmware_version.py pre:run_clangformat.py diff --git a/src/menuHandler.h b/src/menuHandler.h index 19f43797d..25101e1f4 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -93,7 +93,7 @@ void initMenu(U8G2& display) { machineState = kBrew; } else { - machineState = kPidOffline; + machineState = kPidDisabled; } return; } From a5a5cc8ca2e8b531b6a21ecf103aca75a3cfcd4b Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:00:54 +0200 Subject: [PATCH 05/12] code formatting --- src/hardware/pinmapping.h | 6 ++-- src/menuHandler.h | 74 ++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/hardware/pinmapping.h b/src/hardware/pinmapping.h index dd9f1fca7..9b0a47ccb 100644 --- a/src/hardware/pinmapping.h +++ b/src/hardware/pinmapping.h @@ -22,9 +22,9 @@ #define PIN_ROTARY_SW 5 // Rotary encoder switch // Menu Input -#define PIN_MENU_OUT_A 4 // Menu Input - Rotary encoder Output A / Data pin or down button -#define PIN_MENU_OUT_B 3 // Menu Input - Rotary encoder Output B / CLK pin or up button -#define PIN_MENU_ENTER 5 // Menu Input - Rotary encoder switch or enter button +#define PIN_MENU_OUT_A 4 // Menu Input - Rotary encoder Output A / Data pin or down button +#define PIN_MENU_OUT_B 3 // Menu Input - Rotary encoder Output B / CLK pin or up button +#define PIN_MENU_ENTER 5 // Menu Input - Rotary encoder switch or enter button // Sensors #define PIN_TEMPSENSOR 16 diff --git a/src/menuHandler.h b/src/menuHandler.h index 25101e1f4..9301654d1 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -2,9 +2,9 @@ #pragma once #include +#include #include #include -#include enum MENUINPUT { BUTTONS, @@ -18,7 +18,6 @@ GPIOPin* menuDownPin; QueueHandle_t button_events; button_event_t ev; - void saveBrewTemp() { sysParaBrewSetpoint.setStorage(true); } @@ -51,19 +50,13 @@ bool hasSoftwareDetection() { return BREWDETECTION_TYPE == 1; } - - void menuInputInit() { if (MENU_INPUT == MENUINPUT::BUTTONS) { menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); menuUpPin = new GPIOPin(PIN_MENU_OUT_A, GPIOPin::IN_PULLUP); menuDownPin = new GPIOPin(PIN_MENU_OUT_B, GPIOPin::IN_PULLUP); - button_events = pulled_button_init( - PIN_BIT(menuEnterPin->getPinNumber()) | - PIN_BIT(menuUpPin->getPinNumber()) | - PIN_BIT(menuDownPin->getPinNumber()), GPIO_PULLUP_ONLY - ); + button_events = pulled_button_init(PIN_BIT(menuEnterPin->getPinNumber()) | PIN_BIT(menuUpPin->getPinNumber()) | PIN_BIT(menuDownPin->getPinNumber()), GPIO_PULLUP_ONLY); } } @@ -74,42 +67,43 @@ void initMenu(U8G2& display) { /* Main Menu */ menu->AddInputItem("Brew Temp.", "Brew Temperature", "", "°C", BREW_SETPOINT_MIN, BREW_SETPOINT_MAX, saveBrewTemp, brewSetpoint, bitmap_icon_temp, 0.1, 0.5); - menu->AddInputItem("Steam Temp.", "Steam Temperature", "", "°C", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, saveSteamTemp, steamSetpoint, bitmap_icon_steam, 0.1, 0.5); + menu->AddInputItem("Steam Temp.", "Steam Temperature", "", "°C", STEAM_SETPOINT_MIN, STEAM_SETPOINT_MAX, saveSteamTemp, steamSetpoint, bitmap_icon_steam, 0.1, 0.5); menu->AddToggleItem("PID", savePIDOn, reinterpret_cast(pidON), bitmap_icon_pid); menu->SetEventHandler([&]() { - if (xQueueReceive(button_events, &ev, 1 / portTICK_PERIOD_MS)) { - - if (ev.pin == menuEnterPin->getPinNumber()) { - if (standbyModeRemainingTimeMillis == 0) { - resetStandbyTimer(); - display.setPowerSave(0); - pidON = 1; - if (steamON) { - machineState = kSteam; - } - else if (isBrewDetected) { - machineState = kBrew; - } - else { - machineState = kPidDisabled; - } - return; - } - if (ev.event == EventState::STATE_DOWN) { - resetStandbyTimer(); - } - menu->Event(EVENT_ENTER, EventState(ev.event)); - - } else if (ev.pin == menuUpPin->getPinNumber()) { - resetStandbyTimer(); - menu->Event(EVENT_UP, EventState(ev.event)); - } else if (ev.pin == menuDownPin->getPinNumber()) { - resetStandbyTimer(); - menu->Event(EVENT_DOWN, EventState(ev.event)); + if (xQueueReceive(button_events, &ev, 1 / portTICK_PERIOD_MS)) { + + if (ev.pin == menuEnterPin->getPinNumber()) { + if (standbyModeRemainingTimeMillis == 0) { + resetStandbyTimer(); + display.setPowerSave(0); + pidON = 1; + if (steamON) { + machineState = kSteam; + } + else if (isBrewDetected) { + machineState = kBrew; } + else { + machineState = kPidDisabled; + } + return; + } + if (ev.event == EventState::STATE_DOWN) { + resetStandbyTimer(); } + menu->Event(EVENT_ENTER, EventState(ev.event)); + } + else if (ev.pin == menuUpPin->getPinNumber()) { + resetStandbyTimer(); + menu->Event(EVENT_UP, EventState(ev.event)); + } + else if (ev.pin == menuDownPin->getPinNumber()) { + resetStandbyTimer(); + menu->Event(EVENT_DOWN, EventState(ev.event)); + } + } }); /* Brew Weight & Time */ @@ -163,7 +157,7 @@ void initMenu(U8G2& display) { pidSettings->AddBackItem("Back", bitmap_icon_back); /* Brew PID Settings */ - Menu * brewPidSettings = new Menu(display); + Menu* brewPidSettings = new Menu(display); brewPidSettings->AddToggleItem("Enable Brew PID", []() { sysParaUsePonM.setStorage(true); }, reinterpret_cast(useBDPID)); brewPidSettings->AddInputItem("BD Kp", "BD Kp", "", "", PID_KP_BD_MIN, PID_KP_BD_MAX, []() { sysParaPidKpBd.setStorage(true); }, aggbKp); brewPidSettings->AddInputItem("BD Tn", "BD Tn (=Kp/Ki)", "", "", PID_TN_BD_MIN, PID_TN_BD_MAX, []() { sysParaPidTnBd.setStorage(true); }, aggbTn); From ab59aaa0e68e47989b78a98771768ae4b9220cb6 Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:56:36 +0200 Subject: [PATCH 06/12] corrected order of pidSettings Brew Pid and Back item. --- src/menuHandler.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/menuHandler.h b/src/menuHandler.h index 9301654d1..5d16f26c5 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -154,7 +154,7 @@ void initMenu(U8G2& display) { pidSettings->AddInputItem("Tv", "Tv (=Kd/Kp)", "", "", PID_TV_REGULAR_MIN, PID_TV_REGULAR_MAX, []() { sysParaPidTvReg.setStorage(true); }, aggTv); pidSettings->AddInputItem("Integrator Max", "Integrator Max", "", "", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, []() { sysParaPidIMaxReg.setStorage(true); }, aggIMax); pidSettings->AddInputItem("Steam Kp", "Steam Kp", "", "", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, []() { sysParaPidKpSteam.setStorage(true); }, steamKp); - pidSettings->AddBackItem("Back", bitmap_icon_back); + /* Brew PID Settings */ Menu* brewPidSettings = new Menu(display); @@ -167,6 +167,7 @@ void initMenu(U8G2& display) { brewPidSettings->AddBackItem("Back", bitmap_icon_back); pidSettings->AddSubMenu("Brew PID", *brewPidSettings); + pidSettings->AddBackItem("Back", bitmap_icon_back); advancedMenu->AddSubMenu("PID Settings", *pidSettings, bitmap_icon_pid); advancedMenu->AddBackItem("Back", bitmap_icon_back); From d9edfb9419305b082b594e26905244d82e06ff97 Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:06:15 +0200 Subject: [PATCH 07/12] Readded usage of FEATURE_MENU --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ec10daeac..c5c2af73a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1647,8 +1647,9 @@ void setup() { displayLogo(String("Version "), String(sysVersion)); delay(2000); // caused crash with wifi manager on esp8266, should be ok on esp32 - initMenu(u8g2); - + #if FEATURE_MENU == 1 + initMenu(u8g2); + #endif #endif // Fallback offline From 6ac26a84735197a0e4c81465a680b93b4b250052 Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:08:12 +0200 Subject: [PATCH 08/12] Added menu defines to userConfig_sample.h --- src/main.cpp | 6 +++--- src/menuHandler.h | 1 - src/userConfig_sample.h | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c5c2af73a..7f4f20793 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1647,9 +1647,9 @@ void setup() { displayLogo(String("Version "), String(sysVersion)); delay(2000); // caused crash with wifi manager on esp8266, should be ok on esp32 - #if FEATURE_MENU == 1 - initMenu(u8g2); - #endif +#if FEATURE_MENU == 1 + initMenu(u8g2); +#endif #endif // Fallback offline diff --git a/src/menuHandler.h b/src/menuHandler.h index 5d16f26c5..fcfcd3bdd 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -155,7 +155,6 @@ void initMenu(U8G2& display) { pidSettings->AddInputItem("Integrator Max", "Integrator Max", "", "", PID_I_MAX_REGULAR_MIN, PID_I_MAX_REGULAR_MAX, []() { sysParaPidIMaxReg.setStorage(true); }, aggIMax); pidSettings->AddInputItem("Steam Kp", "Steam Kp", "", "", PID_KP_STEAM_MIN, PID_KP_STEAM_MAX, []() { sysParaPidKpSteam.setStorage(true); }, steamKp); - /* Brew PID Settings */ Menu* brewPidSettings = new Menu(display); brewPidSettings->AddToggleItem("Enable Brew PID", []() { sysParaUsePonM.setStorage(true); }, reinterpret_cast(useBDPID)); diff --git a/src/userConfig_sample.h b/src/userConfig_sample.h index 86e883d42..956a09194 100644 --- a/src/userConfig_sample.h +++ b/src/userConfig_sample.h @@ -40,7 +40,11 @@ enum MACHINE { #define FEATURE_PIDOFF_LOGO 1 // 0 = deactivated, 1 = activated #define SHOTTIMERDISPLAYDELAY 3000 // time in ms that shot timer will be shown after brew finished -#define LANGUAGE 0 // LANGUAGE = 0 (DE), LANGUAGE = 1 (EN), LANGUAGE = 2 (ES) +// Display Menu +#define FEATURE_MENU 0 // 0 = deactivated, 1 = enabled +#define MENU_INPUT MENUINPUT::BUTTONS // MENUINPUT::BUTTONS = input with three buttons, MENUINPUT::ROTARY = input with rotary encoder with shaft switch + +#define LANGUAGE 0 // LANGUAGE = 0 (DE), LANGUAGE = 1 (EN), LANGUAGE = 2 (ES) // Connectivity #define CONNECTMODE 1 // 0 = offline 1 = WIFI-MODE From 790aa5e3e694c9165d0187a81164b9965d643bac Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:22:23 +0200 Subject: [PATCH 09/12] Adding rotary encoder --- platformio.ini | 2 +- src/defaults.h | 2 ++ src/hardware/pinmapping.h | 4 --- src/menuHandler.h | 67 +++++++++++++++++++++++++++++++-------- 4 files changed, 57 insertions(+), 18 deletions(-) diff --git a/platformio.ini b/platformio.ini index b7ca18d1f..b62762f8a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -24,9 +24,9 @@ lib_deps = git+https://github.com/esphome/AsyncTCP @ 2.1.3 git+https://github.com/esphome/ESPAsyncWebServer#f2a65ff git+https://github.com/tzapu/WiFiManager @ 2.0.17 - git+https://github.com/madhephaestus/ESP32Encoder#9979722 git+https://github.com/craftmetrics/esp32-button.git#36c6c0a git+https://github.com/chris-dot-exe/MonoMenu @ 0.1.2 + madhephaestus/ESP32Encoder @ 0.11.5 extra_scripts = pre:auto_firmware_version.py pre:run_clangformat.py diff --git a/src/defaults.h b/src/defaults.h index 86ef035c6..d5f2f07e8 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -91,3 +91,5 @@ int writeSysParamsToStorage(void); #define PID_KP_STEAM_MAX 500 #define STANDBY_MODE_TIME_MIN 30 #define STANDBY_MODE_TIME_MAX 120 + +#define ENCODER_CLICKS_PER_NOTCH 4 \ No newline at end of file diff --git a/src/hardware/pinmapping.h b/src/hardware/pinmapping.h index 9b0a47ccb..36569d7fd 100644 --- a/src/hardware/pinmapping.h +++ b/src/hardware/pinmapping.h @@ -17,10 +17,6 @@ #define PIN_STEAMSWITCH 35 #define PIN_WATERSWITCH 36 -#define PIN_ROTARY_DT 4 // Rotary encoder data pin -#define PIN_ROTARY_CLK 3 // Rotary encoder clock pin -#define PIN_ROTARY_SW 5 // Rotary encoder switch - // Menu Input #define PIN_MENU_OUT_A 4 // Menu Input - Rotary encoder Output A / Data pin or down button #define PIN_MENU_OUT_B 3 // Menu Input - Rotary encoder Output B / CLK pin or up button diff --git a/src/menuHandler.h b/src/menuHandler.h index fcfcd3bdd..21f62b60a 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -1,6 +1,7 @@ #pragma once +#include #include #include #include @@ -15,9 +16,14 @@ Menu* menu; GPIOPin* menuEnterPin; GPIOPin* menuUpPin; GPIOPin* menuDownPin; +ESP32Encoder encoder; QueueHandle_t button_events; button_event_t ev; +double menuRotaryLast = 0; +double initialValue = 0; +int last = 0; + void saveBrewTemp() { sysParaBrewSetpoint.setStorage(true); } @@ -51,12 +57,29 @@ bool hasSoftwareDetection() { } void menuInputInit() { - if (MENU_INPUT == MENUINPUT::BUTTONS) { - menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); - menuUpPin = new GPIOPin(PIN_MENU_OUT_A, GPIOPin::IN_PULLUP); - menuDownPin = new GPIOPin(PIN_MENU_OUT_B, GPIOPin::IN_PULLUP); - - button_events = pulled_button_init(PIN_BIT(menuEnterPin->getPinNumber()) | PIN_BIT(menuUpPin->getPinNumber()) | PIN_BIT(menuDownPin->getPinNumber()), GPIO_PULLUP_ONLY); + switch (MENU_INPUT) { + case MENUINPUT::BUTTONS: + menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); + menuUpPin = new GPIOPin(PIN_MENU_OUT_A, GPIOPin::IN_PULLUP); + menuDownPin = new GPIOPin(PIN_MENU_OUT_B, GPIOPin::IN_PULLUP); + + button_events = pulled_button_init(PIN_BIT(menuEnterPin->getPinNumber()) | PIN_BIT(menuUpPin->getPinNumber()) | PIN_BIT(menuDownPin->getPinNumber()), GPIO_PULLUP_ONLY); + break; + case MENUINPUT::ROTARY: + // TODO add rotary setup + menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); + menuUpPin = new GPIOPin(PIN_MENU_OUT_A, GPIOPin::IN_PULLUP); + menuDownPin = new GPIOPin(PIN_MENU_OUT_B, GPIOPin::IN_PULLUP); + + button_events = pulled_button_init(PIN_BIT(menuEnterPin->getPinNumber()), GPIO_PULLUP_ONLY); + + encoder.useInternalWeakPullResistors = puType::up; + encoder.attachFullQuad(PIN_MENU_OUT_A, PIN_MENU_OUT_B); + encoder.setCount(0); + + break; + default: + break; } } @@ -73,7 +96,6 @@ void initMenu(U8G2& display) { menu->SetEventHandler([&]() { if (xQueueReceive(button_events, &ev, 1 / portTICK_PERIOD_MS)) { - if (ev.pin == menuEnterPin->getPinNumber()) { if (standbyModeRemainingTimeMillis == 0) { resetStandbyTimer(); @@ -95,14 +117,33 @@ void initMenu(U8G2& display) { } menu->Event(EVENT_ENTER, EventState(ev.event)); } - else if (ev.pin == menuUpPin->getPinNumber()) { - resetStandbyTimer(); - menu->Event(EVENT_UP, EventState(ev.event)); + else { + if (MENU_INPUT == MENUINPUT::BUTTONS) { + if (ev.pin == menuUpPin->getPinNumber()) { + resetStandbyTimer(); + menu->Event(EVENT_UP, EventState(ev.event)); + } + else if (ev.pin == menuDownPin->getPinNumber()) { + resetStandbyTimer(); + menu->Event(EVENT_DOWN, EventState(ev.event)); + } + } + } + } + if (MENU_INPUT == MENUINPUT::ROTARY) { + int32_t pos = encoder.getCount() / ENCODER_CLICKS_PER_NOTCH; + if (pos < last) { + menu->Event(EVENT_UP, EventState(EventState::STATE_DOWN)); + LOG(DEBUG, "Menu: Up\n"); + menu->Event(EVENT_UP, EventState(EventState::STATE_UP)); } - else if (ev.pin == menuDownPin->getPinNumber()) { - resetStandbyTimer(); - menu->Event(EVENT_DOWN, EventState(ev.event)); + else if (pos > last) { + menu->Event(EVENT_DOWN, EventState(EventState::STATE_DOWN)); + LOG(DEBUG, "Menu: Down\n"); + menu->Event(EVENT_DOWN, EventState(EventState::STATE_UP)); } + + last = pos; } }); From 53d372047778579e006a76a0ea0c43fec2794935 Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:49:31 +0200 Subject: [PATCH 10/12] Removed unused variables --- src/menuHandler.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/menuHandler.h b/src/menuHandler.h index 21f62b60a..c4e1c2024 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -20,8 +20,6 @@ ESP32Encoder encoder; QueueHandle_t button_events; button_event_t ev; -double menuRotaryLast = 0; -double initialValue = 0; int last = 0; void saveBrewTemp() { From a547f983a69777a3538c87b100acecb6f92a85ad Mon Sep 17 00:00:00 2001 From: chris-dot-exe <49272981+chris-dot-exe@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:49:43 +0200 Subject: [PATCH 11/12] Inverted triggered events on rotary rotation. --- src/menuHandler.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/menuHandler.h b/src/menuHandler.h index c4e1c2024..7f9b49ee5 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -64,7 +64,6 @@ void menuInputInit() { button_events = pulled_button_init(PIN_BIT(menuEnterPin->getPinNumber()) | PIN_BIT(menuUpPin->getPinNumber()) | PIN_BIT(menuDownPin->getPinNumber()), GPIO_PULLUP_ONLY); break; case MENUINPUT::ROTARY: - // TODO add rotary setup menuEnterPin = new GPIOPin(PIN_MENU_ENTER, GPIOPin::IN_PULLUP); menuUpPin = new GPIOPin(PIN_MENU_OUT_A, GPIOPin::IN_PULLUP); menuDownPin = new GPIOPin(PIN_MENU_OUT_B, GPIOPin::IN_PULLUP); @@ -130,12 +129,12 @@ void initMenu(U8G2& display) { } if (MENU_INPUT == MENUINPUT::ROTARY) { int32_t pos = encoder.getCount() / ENCODER_CLICKS_PER_NOTCH; - if (pos < last) { + if (pos > last) { menu->Event(EVENT_UP, EventState(EventState::STATE_DOWN)); LOG(DEBUG, "Menu: Up\n"); menu->Event(EVENT_UP, EventState(EventState::STATE_UP)); } - else if (pos > last) { + else if (pos < last) { menu->Event(EVENT_DOWN, EventState(EventState::STATE_DOWN)); LOG(DEBUG, "Menu: Down\n"); menu->Event(EVENT_DOWN, EventState(EventState::STATE_UP)); From 15a2e2ff1aaa122176eaa896aa35bbafb2fff97f Mon Sep 17 00:00:00 2001 From: Lorenz Uhlig <98092139+LoQue90@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:06:58 +0200 Subject: [PATCH 12/12] fix Brewcontrol check in display menu --- src/menuHandler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/menuHandler.h b/src/menuHandler.h index 7f9b49ee5..5ca78631c 100644 --- a/src/menuHandler.h +++ b/src/menuHandler.h @@ -43,7 +43,7 @@ void saveStandbyTime() { } bool hasBrewControl() { - return BREWCONTROL_TYPE > 0; + return FEATURE_BREWCONTROL > 0; } bool hasScale() { @@ -216,4 +216,4 @@ void initMenu(U8G2& display) { void menuLoop() { menu->Loop(); -} \ No newline at end of file +}