Skip to content

Commit

Permalink
Add relay cfg during startup
Browse files Browse the repository at this point in the history
  • Loading branch information
FredM67 committed May 26, 2023
1 parent 368df2c commit 0acaabf
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Mk2_3phase_RFdatalog_temp/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ You'll need to install additional extension(s). The most popular and used extens
- **dualtariff.h** : definitions for the dual tariff feature
- **main.cpp** : source code
- **main.h** : functions prototypes
- **movingAvg.h** : source code for sliding-window average
- **processing.cpp** : source code for the processing engine
- **processing.h** : functions prototype of the processing engine
- **Readme.md** : this file
- **types.h** : definitions of types, ...
- **type_traits.h** : some STL stuff not yet available in the avr-package
- **utils_relay.h** : source code for the *relay-diversion* feature
- **utils_rf.h** : source code for the *RF* feature
- **utils_temp.h** : source code for the *temperature* feature
- **utils.h** : helper functions and misc stuff
Expand Down
2 changes: 1 addition & 1 deletion Mk2_3phase_RFdatalog_temp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ inline constexpr uint8_t watchDogPin{ 0xff }; /**< watch dog LED */

inline constexpr uint8_t tempSensorPin{ 0xff }; /**< for 3-phase PCB, sensor pin */

inline relayOutput relay_Output{ relayPin }; /**< config for relay diversion, see class definition for defaults */
inline relayOutput<> relay_Output{ relayPin }; /**< 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 */
Expand Down
14 changes: 14 additions & 0 deletions Mk2_3phase_RFdatalog_temp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ inline void printConfiguration()
{
DBUGLN(F("is NOT present"));
}

DBUG(F("Dual-tariff capability "));
if constexpr (DUAL_TARIFF)
{
Expand All @@ -102,6 +103,7 @@ inline void printConfiguration()
{
DBUGLN(F("is NOT present"));
}

DBUG(F("Load rotation feature "));
if constexpr (PRIORITY_ROTATION != RotationModes::OFF)
{
Expand All @@ -112,6 +114,18 @@ inline void printConfiguration()
DBUGLN(F("is NOT present"));
}

DBUG(F("Relay diversion feature "));
if constexpr (RELAY_DIVERSION)
{
DBUGLN(F("is present"));

relayOutput<>::printRelayConfiguration(relay_Output);
}
else
{
DBUGLN(F("is NOT present"));
}

DBUG(F("RF capability "));
#ifdef RF_PRESENT
DBUG(F("IS present, Freq = "));
Expand Down
30 changes: 29 additions & 1 deletion Mk2_3phase_RFdatalog_temp/utils_relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template< uint8_t T = 1 > class relayOutput
*
* @param _relay_pin Control pin for the relay
*/
explicit constexpr relayOutput(uint8_t _relay_pin)
explicit constexpr relayOutput(const uint8_t _relay_pin)
: relay_pin(_relay_pin)
{
}
Expand Down Expand Up @@ -145,6 +145,30 @@ template< uint8_t T = 1 > class relayOutput
sliding_Average.addValue(currentPower);
}

/**
* @brief Print the configuration of the current relay-diversion
*
*/
static void printRelayConfiguration(const relayOutput& relay)
{
Serial.println(F("\tRelay configuration:"));

Serial.print(F("\t\tPin is "));
Serial.println(relay.relay_pin);

Serial.print(F("\t\tSurplus threshold: "));
Serial.println(relay.surplusThreshold);

Serial.print(F("\t\tImport threshold: "));
Serial.println(relay.importThreshold);

Serial.print(F("\t\tMinimum working time in minutes: "));
Serial.println(relay.minON / 60);

Serial.print(F("\t\tMinimum stop time in minutes: "));
Serial.println(relay.minOFF / 60);
}

private:
/**
* @brief Turn ON the relay if the 'time' condition is met
Expand All @@ -159,6 +183,8 @@ template< uint8_t T = 1 > class relayOutput

setPinON(relay_pin);

DBUGLN(F("Relay turned ON!"));

relayState = true;
duration = 0;
}
Expand All @@ -176,6 +202,8 @@ template< uint8_t T = 1 > class relayOutput

setPinOFF(relay_pin);

DBUGLN(F("Relay turned OFF!"));

relayState = false;
duration = 0;
}
Expand Down

0 comments on commit 0acaabf

Please sign in to comment.