Skip to content

Commit

Permalink
Set limit to duration
Browse files Browse the repository at this point in the history
  • Loading branch information
FredM67 committed May 7, 2023
1 parent 515cab7 commit ca16002
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Mk2_3phase_RFdatalog_temp/utils_relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include "utils_pins.h"

/**
* @brief Config parameters for relay diversion
* @brief Relay diversion config and engine
*
* @tparam T Duration in minutes of the sliding average
*/
template< uint8_t T = 1 > class relayOutput
{
Expand Down Expand Up @@ -105,11 +106,15 @@ template< uint8_t T = 1 > class relayOutput

/**
* @brief Increment the duration of the current state
* @details This function must be called every second.
*
*/
void inc_duration()
{
++duration;
if (duration < UINT16_MAX)
{
++duration;
}
}

/**
Expand Down Expand Up @@ -177,8 +182,8 @@ template< uint8_t T = 1 > class relayOutput
const uint16_t minON{ 5 * 60 }; /**< Minimum duration in seconds the relay is turned ON */
const uint16_t minOFF{ 5 * 60 }; /**< Minimum duration in seconds the relay is turned OFF */

uint16_t duration{ 0 }; /**< Duration of the current state */
bool relayState{ false }; /**< State of the relay */
uint16_t duration{ 0 }; /**< Duration of the current state */
bool relayState{ false }; /**< State of the relay */

static inline movingAvg< int16_t, T * 60 / DATALOG_PERIOD_IN_SECONDS > sliding_Average;
};
Expand Down

0 comments on commit ca16002

Please sign in to comment.