From 09a8647d0d24ede304bcaa85337f65d6618f80a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Tue, 2 May 2023 22:02:58 +0200 Subject: [PATCH] Next step --- Mk2_3phase_RFdatalog_temp/config.h | 3 ++- Mk2_3phase_RFdatalog_temp/utils_relay.h | 6 +++--- Mk2_3phase_RFdatalog_temp/validation.h | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Mk2_3phase_RFdatalog_temp/config.h b/Mk2_3phase_RFdatalog_temp/config.h index 8e3348e4..839bda3e 100644 --- a/Mk2_3phase_RFdatalog_temp/config.h +++ b/Mk2_3phase_RFdatalog_temp/config.h @@ -50,6 +50,7 @@ inline constexpr bool OVERRIDE_PIN_PRESENT{ false }; /**< set #endif inline constexpr bool WATCHDOG_PIN_PRESENT{ false }; /**< set it to 'true' if there's a watch led */ +inline constexpr bool RELAY_DIVERSION{ false }; /**< set it to 'true' if a relay is used for diversion */ inline constexpr bool DUAL_TARIFF{ false }; /**< set it to 'true' if there's a dual tariff each day AND the router is connected to the billing meter */ // ----------- Pinout assignments ----------- @@ -82,7 +83,7 @@ inline constexpr uint8_t watchDogPin{ 0xff }; /**< inline constexpr uint8_t tempSensorPin{ 0xff }; /**< for 3-phase PCB, sensor pin */ -inline constexpr relayConfig relay_Config; /**< config for relay diversion */ +inline constexpr relayConfig relay_Config; /**< config for relay diversion, see class definition for defaults */ inline constexpr uint8_t ul_OFF_PEAK_DURATION{ 8 }; /**< Duration of the off-peak period in hours */ inline constexpr pairForceLoad rg_ForceLoad[NO_OF_DUMPLOADS]{ { -3, 2 } }; /**< force config for load #1 ONLY for dual tariff */ diff --git a/Mk2_3phase_RFdatalog_temp/utils_relay.h b/Mk2_3phase_RFdatalog_temp/utils_relay.h index 14fc49d5..14a9f6d5 100644 --- a/Mk2_3phase_RFdatalog_temp/utils_relay.h +++ b/Mk2_3phase_RFdatalog_temp/utils_relay.h @@ -18,7 +18,7 @@ * @brief Config parameters for relay diversion * */ -class relayConfig +template< uint8_t T = 1 > class relayConfig { public: constexpr relayConfig() = default; @@ -39,8 +39,8 @@ class relayConfig * * @param _surplusThreshold Surplus threshold to turn relay ON * @param _importThreshold Import threshold to turn relay OFF - * @param _minON Minimum duration to leave relay ON - * @param _minOFF Minimum duration in minutes to l + * @param _minON Minimum duration in minutes to leave relay ON + * @param _minOFF Minimum duration in minutes to leave relay OFF */ constexpr relayConfig(int16_t _surplusThreshold, int16_t _importThreshold, uint16_t _minON, uint16_t _minOFF) : surplusThreshold(abs(_surplusThreshold)), importThreshold(abs(_importThreshold)), minON(_minON * 60), minOFF(_minOFF * 60) diff --git a/Mk2_3phase_RFdatalog_temp/validation.h b/Mk2_3phase_RFdatalog_temp/validation.h index 5961de91..77e2fc33 100644 --- a/Mk2_3phase_RFdatalog_temp/validation.h +++ b/Mk2_3phase_RFdatalog_temp/validation.h @@ -30,6 +30,8 @@ static_assert((PRIORITY_ROTATION == RotationModes::PIN) ^ (rotationPin == 0xff), static_assert(OVERRIDE_PIN_PRESENT ^ (forcePin == 0xff), "******** Wrong pin value for override command. Please check your config.h ! ********"); static_assert(WATCHDOG_PIN_PRESENT ^ (watchDogPin == 0xff), "******** Wrong pin value for watchdog. Please check your config.h ! ********"); +static_assert(RELAY_DIVERSION ^ (relayPin == 0xff), "******** Wrong pin value for relay diversion. Please check your config.h ! ********"); + static_assert(DUAL_TARIFF ^ (dualTariffPin == 0xff), "******** Wrong pin value for dual tariff. Please check your config.h ! ********"); static_assert(!DUAL_TARIFF | (ul_OFF_PEAK_DURATION == 0), "******** Off-peak duration cannot be zero. Please check your config.h ! ********"); static_assert(!(DUAL_TARIFF & (ul_OFF_PEAK_DURATION > 12)), "******** Off-peak duration cannot last more than 12 hours. Please check your config.h ! ********");