From 9d4fae90e10676f5433286eaae0613b688fe9018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Sun, 2 Jun 2024 17:20:53 +0200 Subject: [PATCH] Final with options --- Mk2_3phase_RFdatalog_temp/config.h | 8 ++++---- Mk2_3phase_RFdatalog_temp/main.cpp | 11 +++++++---- Mk2_3phase_RFdatalog_temp/platformio.ini | 11 ++++++----- Mk2_3phase_RFdatalog_temp/utils.h | 25 ++++++++++++++---------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Mk2_3phase_RFdatalog_temp/config.h b/Mk2_3phase_RFdatalog_temp/config.h index deddfeb..ae06f8e 100644 --- a/Mk2_3phase_RFdatalog_temp/config.h +++ b/Mk2_3phase_RFdatalog_temp/config.h @@ -44,9 +44,9 @@ inline constexpr RotationModes PRIORITY_ROTATION{ RotationModes::PIN }; /**< man inline constexpr bool OVERRIDE_PIN_PRESENT{ true }; /**< managed through EmonESP */ #else inline constexpr bool EMONESP_CONTROL{ false }; -inline constexpr bool DIVERSION_PIN_PRESENT{ false }; /**< set it to 'true' if you want to control diversion ON/OFF */ +inline constexpr bool DIVERSION_PIN_PRESENT{ true }; /**< set it to 'true' if you want to control diversion ON/OFF */ inline constexpr RotationModes PRIORITY_ROTATION{ RotationModes::OFF }; /**< set it to 'OFF/AUTO/PIN' if you want manual/automatic rotation of priorities */ -inline constexpr bool OVERRIDE_PIN_PRESENT{ false }; /**< set it to 'true' if there's a override pin */ +inline constexpr bool OVERRIDE_PIN_PRESENT{ true }; /**< set it to 'true' if there's a override pin */ #endif inline constexpr bool WATCHDOG_PIN_PRESENT{ false }; /**< set it to 'true' if there's a watch led */ @@ -76,9 +76,9 @@ inline constexpr uint8_t loadPrioritiesAtStartup[NO_OF_DUMPLOADS]{ 0, 1 }; /**< // Set the value to 0xff when the pin is not needed (feature deactivated) inline constexpr uint8_t dualTariffPin{ 0xff }; /**< for 3-phase PCB, off-peak trigger */ -inline constexpr uint8_t diversionPin{ 0xff }; /**< if LOW, set diversion on standby */ +inline constexpr uint8_t diversionPin{ 2 }; /**< if LOW, set diversion on standby */ inline constexpr uint8_t rotationPin{ 0xff }; /**< if LOW, trigger a load priority rotation */ -inline constexpr uint8_t forcePin{ 0xff }; /**< for 3-phase PCB, force pin */ +inline constexpr uint8_t forcePin{ 3 }; /**< for 3-phase PCB, force pin */ inline constexpr uint8_t watchDogPin{ 0xff }; /**< watch dog LED */ inline constexpr RelayEngine relays{ { { 7, 1000, 200, 1, 1 } } }; /**< config for relay diversion, see class definition for defaults and advanced options */ diff --git a/Mk2_3phase_RFdatalog_temp/main.cpp b/Mk2_3phase_RFdatalog_temp/main.cpp index 4b4746f..f866f64 100644 --- a/Mk2_3phase_RFdatalog_temp/main.cpp +++ b/Mk2_3phase_RFdatalog_temp/main.cpp @@ -302,10 +302,13 @@ bool proceedLoadPrioritiesAndOverriding(const int16_t currentTemperature_x100) { const auto pinState{ getPinState(forcePin) }; - for (auto &bOverrideLoad : b_overrideLoadOn) - { - bOverrideLoad = !pinState; - } + // for (auto &bOverrideLoad : b_overrideLoadOn) + // { + // bOverrideLoad = !pinState; + // } + + // Override only load #1 + b_overrideLoadOn[0] = !pinState; } return false; diff --git a/Mk2_3phase_RFdatalog_temp/platformio.ini b/Mk2_3phase_RFdatalog_temp/platformio.ini index f300258..be41c03 100644 --- a/Mk2_3phase_RFdatalog_temp/platformio.ini +++ b/Mk2_3phase_RFdatalog_temp/platformio.ini @@ -34,6 +34,11 @@ monitor_filters = log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory [env:basic] +build_src_flags = + -DTEMP_ENABLED +lib_deps = + paulstoffregen/OneWire @ ^2.3.8 + adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 [env:basic_debug] build_type = debug @@ -42,11 +47,7 @@ build_type = debug build_src_flags = -DTEMP_ENABLED lib_deps = - paulstoffregen/OneWire @ ^2.3.7 - adafruit/Adafruit BusIO@^1.16.1 - adafruit/Adafruit GFX Library@^1.11.9 - adafruit/Adafruit seesaw Library@^1.7.7 - arduino-libraries/SD@^1.2.4 + paulstoffregen/OneWire @ ^2.3.8 adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 [env:emonesp] diff --git a/Mk2_3phase_RFdatalog_temp/utils.h b/Mk2_3phase_RFdatalog_temp/utils.h index 81c8e68..5f3dd8a 100644 --- a/Mk2_3phase_RFdatalog_temp/utils.h +++ b/Mk2_3phase_RFdatalog_temp/utils.h @@ -305,16 +305,21 @@ inline void printForSerialText() continue; } - tft.fillScreen(ST77XX_BLACK); - - tft.setTextColor(tx_data.temperature_x100[0] > 4500 ? ST77XX_GREEN : ST7735_RED); - tft.setCursor(10, 52); - tft.print(tx_data.temperature_x100[0] * 0.01F, 1); - const auto curr_x = tft.getCursorX(); - const auto curr_y = tft.getCursorY(); - tft.drawCircle(curr_x + 6, curr_y - 28, 4, ST7735_WHITE); - tft.setTextColor(ST7735_WHITE); - tft.print(F(" C")); + static int16_t temp_previous{ 0 }; + + if (temp_previous != tx_data.temperature_x100[0]) + { + // Skip refresh if the temp didn't change + tft.fillScreen(ST77XX_BLACK); + + tft.setTextColor(tx_data.temperature_x100[0] > 5500 ? ST77XX_GREEN : ST7735_RED); + tft.setCursor(10, 52); + tft.print(tx_data.temperature_x100[0] * 0.01F, 1); + tft.drawCircle(tft.getCursorX() + 6, tft.getCursorY() - 28, 4, ST7735_WHITE); + tft.setTextColor(ST7735_WHITE); + tft.print(F(" C")); + temp_previous = tx_data.temperature_x100[0]; + } Serial.print(F(", T")); Serial.print(idx + 1);