[RN8209] Publish on change detect and heap usage optim (#1630)
Publish the RN8209 depending on a threshold added to a frequency Also merge the 2 tasks into one to save heap
This commit is contained in:
1 parent
9bb322daf8
commit
25991bfbb4
5 files changed
+74
-65
No files matched your search
+12
-17
@@ -94,9 +94,6 @@ void ONOFFConfig_load(){};
|
||||
# endif
|
||||
|
||||
void setupONOFF() {
|
||||
# ifdef MAX_CURRENT_ACTUATOR
|
||||
xTaskCreate(overLimitCurrent, "overLimitCurrent", 4000, NULL, 10, NULL);
|
||||
# endif
|
||||
# ifdef MAX_TEMP_ACTUATOR
|
||||
xTaskCreate(overLimitTemp, "overLimitTemp", 4000, NULL, 10, NULL);
|
||||
# endif
|
||||
@@ -248,23 +245,21 @@ void overLimitTemp(void* pvParameters) {
|
||||
|
||||
// Check regularly current the relay and switch it OFF if the current is more than MAX_CURRENT_ACTUATOR
|
||||
# ifdef MAX_CURRENT_ACTUATOR
|
||||
void overLimitCurrent(void* pvParameters) {
|
||||
for (;;) {
|
||||
static float previousCurrent = 0;
|
||||
float current = getRN8209current();
|
||||
Log.trace(F("RN8209 Current %F" CR), current);
|
||||
// We switch OFF the actuator if the current of the RN8209 is more than MAX_CURRENT_ACTUATOR.
|
||||
if (current > MAX_CURRENT_ACTUATOR && previousCurrent > MAX_CURRENT_ACTUATOR) {
|
||||
if (digitalRead(ACTUATOR_ONOFF_GPIO) == ACTUATOR_ON) { // This could be with the previous condition, but it is better to trigger the digitalRead only if the previous condition is met to avoid the digitalRead
|
||||
Log.error(F("[ActuatorONOFF] OverCurrent detected ( %F > %F ) switching OFF Actuator" CR), current, MAX_CURRENT_ACTUATOR);
|
||||
ActuatorTrigger();
|
||||
CriticalIndicatorON();
|
||||
}
|
||||
void overLimitCurrent(float RN8209current) {
|
||||
static float RN8209previousCurrent = 0;
|
||||
Log.trace(F("RN8209 Current %F" CR), RN8209current);
|
||||
// We switch OFF the actuator if the current of the RN8209 is more than MAX_CURRENT_ACTUATOR.
|
||||
if (RN8209current > MAX_CURRENT_ACTUATOR && RN8209previousCurrent > MAX_CURRENT_ACTUATOR) {
|
||||
if (digitalRead(ACTUATOR_ONOFF_GPIO) == ACTUATOR_ON) { // This could be with the previous condition, but it is better to trigger the digitalRead only if the previous condition is met to avoid the digitalRead
|
||||
Log.error(F("[ActuatorONOFF] OverCurrent detected ( %F > %F ) switching OFF Actuator" CR), RN8209current, MAX_CURRENT_ACTUATOR);
|
||||
ActuatorTrigger();
|
||||
CriticalIndicatorON();
|
||||
}
|
||||
previousCurrent = current;
|
||||
vTaskDelay(TimeBetweenReadingCurrent);
|
||||
}
|
||||
RN8209previousCurrent = RN8209current;
|
||||
}
|
||||
# else
|
||||
void overLimitCurrent(float RN8209current) {}
|
||||
# endif
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user