mirror of
https://github.com/ratgdo/esphome-ratgdo.git
synced 2025-02-09 01:04:30 +00:00
fix
This commit is contained in:
parent
a886293122
commit
32bc91a480
@ -24,6 +24,8 @@ namespace ratgdo {
|
|||||||
/*************************** DRY CONTACT CONTROL OF LIGHT & DOOR
|
/*************************** DRY CONTACT CONTROL OF LIGHT & DOOR
|
||||||
* ***************************/
|
* ***************************/
|
||||||
void IRAM_ATTR HOT RATGDOStore::isrDoorOpen(RATGDOStore *arg) {
|
void IRAM_ATTR HOT RATGDOStore::isrDoorOpen(RATGDOStore *arg) {
|
||||||
|
static unsigned long lastOpenDoorTime = 0;
|
||||||
|
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
// Prevent ISR during the first 2 seconds after reboot
|
// Prevent ISR during the first 2 seconds after reboot
|
||||||
if (currentMillis < STARTUP_DELAY)
|
if (currentMillis < STARTUP_DELAY)
|
||||||
@ -31,8 +33,8 @@ namespace ratgdo {
|
|||||||
|
|
||||||
if (!arg->trigger_open.digital_read()) {
|
if (!arg->trigger_open.digital_read()) {
|
||||||
// save the time of the falling edge
|
// save the time of the falling edge
|
||||||
arg->lastOpenDoorTime = currentMillis;
|
lastOpenDoorTime = currentMillis;
|
||||||
} else if (currentMillis - arg->lastOpenDoorTime > 500 && currentMillis - arg->lastOpenDoorTime < 10000) {
|
} else if (currentMillis - arg->lastOpenDoorTime > 500 && currentMillis - lastOpenDoorTime < 10000) {
|
||||||
// now see if the rising edge was between 500ms and 10 seconds after the
|
// now see if the rising edge was between 500ms and 10 seconds after the
|
||||||
// falling edge
|
// falling edge
|
||||||
arg->dryContactDoorOpen = true;
|
arg->dryContactDoorOpen = true;
|
||||||
@ -40,6 +42,8 @@ namespace ratgdo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR HOT RATGDOStore::isrDoorClose(RATGDOStore *arg) {
|
void IRAM_ATTR HOT RATGDOStore::isrDoorClose(RATGDOStore *arg) {
|
||||||
|
static unsigned long lastCloseDoorTime = 0;
|
||||||
|
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
// Prevent ISR during the first 2 seconds after reboot
|
// Prevent ISR during the first 2 seconds after reboot
|
||||||
if (currentMillis < STARTUP_DELAY)
|
if (currentMillis < STARTUP_DELAY)
|
||||||
@ -47,8 +51,8 @@ namespace ratgdo {
|
|||||||
|
|
||||||
if (!arg->trigger_close.digital_read()) {
|
if (!arg->trigger_close.digital_read()) {
|
||||||
// save the time of the falling edge
|
// save the time of the falling edge
|
||||||
arg->lastCloseDoorTime = currentMillis;
|
lastCloseDoorTime = currentMillis;
|
||||||
} else if (currentMillis - arg->lastCloseDoorTime > 500 && currentMillis - arg->lastCloseDoorTime < 10000) {
|
} else if (currentMillis - arg->lastCloseDoorTime > 500 && currentMillis - lastCloseDoorTime < 10000) {
|
||||||
// now see if the rising edge was between 500ms and 10 seconds after the
|
// now see if the rising edge was between 500ms and 10 seconds after the
|
||||||
// falling edge
|
// falling edge
|
||||||
arg->dryContactDoorClose = true;
|
arg->dryContactDoorClose = true;
|
||||||
@ -56,6 +60,8 @@ namespace ratgdo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR HOT RATGDOStore::isrLight(RATGDOStore *arg) {
|
void IRAM_ATTR HOT RATGDOStore::isrLight(RATGDOStore *arg) {
|
||||||
|
static unsigned long lastToggleLightTime = 0;
|
||||||
|
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
// Prevent ISR during the first 2 seconds after reboot
|
// Prevent ISR during the first 2 seconds after reboot
|
||||||
if (currentMillis < STARTUP_DELAY)
|
if (currentMillis < STARTUP_DELAY)
|
||||||
@ -63,8 +69,8 @@ namespace ratgdo {
|
|||||||
|
|
||||||
if (!arg->trigger_light.digital_read()) {
|
if (!arg->trigger_light.digital_read()) {
|
||||||
// save the time of the falling edge
|
// save the time of the falling edge
|
||||||
arg->lastToggleLightTime = currentMillis;
|
lastToggleLightTime = currentMillis;
|
||||||
} else if (currentMillis - arg->lastToggleLightTime > 500 && currentMillis - arg->lastToggleLightTime < 10000) {
|
} else if (currentMillis - lastToggleLightTime > 500 && currentMillis - lastToggleLightTime < 10000) {
|
||||||
// now see if the rising edge was between 500ms and 10 seconds after the
|
// now see if the rising edge was between 500ms and 10 seconds after the
|
||||||
// falling edge
|
// falling edge
|
||||||
arg->dryContactToggleLight = true;
|
arg->dryContactToggleLight = true;
|
||||||
|
@ -35,10 +35,6 @@ namespace ratgdo {
|
|||||||
ISRInternalGPIOPin trigger_close;
|
ISRInternalGPIOPin trigger_close;
|
||||||
ISRInternalGPIOPin trigger_light;
|
ISRInternalGPIOPin trigger_light;
|
||||||
|
|
||||||
unsigned long lastOpenDoorTime { 0 };
|
|
||||||
unsigned long lastCloseDoorTime { 0 };
|
|
||||||
unsigned long lastToggleLightTime { 0 };
|
|
||||||
|
|
||||||
bool dryContactDoorOpen { false };
|
bool dryContactDoorOpen { false };
|
||||||
bool dryContactDoorClose { false };
|
bool dryContactDoorClose { false };
|
||||||
bool dryContactToggleLight { false };
|
bool dryContactToggleLight { false };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user