From ad987adb3c8656df25ae16569238804068f2ae86 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 7 Jun 2023 14:05:01 -0500 Subject: [PATCH] light --- components/ratgdo/ratgdo.cpp | 15 ++++++--------- components/ratgdo/ratgdo.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 39bd8ef..8a334b8 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -505,10 +505,8 @@ namespace ratgdo { transmit(Commands::REBOOT5); delay(65); - transmit(Commands::REBOOT6); + sendCommandAndSaveCounter(Commands::REBOOT6); delay(65); - - this->pref_.save(&this->rollingCodeCounter); } void RATGDOComponent::openDoor() @@ -541,9 +539,8 @@ namespace ratgdo { void RATGDOComponent::toggleDoor() { transmit(Commands::DOOR1); - delay(65); - transmit(Commands::DOOR2); - this->pref_.save(&this->rollingCodeCounter); + delay(40); + sendCommandAndSaveCounter(Commands::DOOR2); } void RATGDOComponent::lightOn() @@ -566,7 +563,7 @@ namespace ratgdo { void RATGDOComponent::toggleLight() { - sendCommand(Commands::LIGHT); + sendCommandAndSaveCounter(Commands::LIGHT); } // Lock functions @@ -590,10 +587,10 @@ namespace ratgdo { void RATGDOComponent::toggleLock() { - sendCommand(Commands::LOCK); + sendCommandAndSaveCounter(Commands::LOCK); } - void RATGDOComponent::sendCommand(Commands command) + void RATGDOComponent::sendCommandAndSaveCounter(Commands command) { transmit(command); this->pref_.save(&this->rollingCodeCounter); diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 93839c0..6791f31 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -128,7 +128,7 @@ namespace ratgdo { void gdoStateLoop(); void statusUpdateLoop(); void readRollingCode(uint8_t& door, uint8_t& light, uint8_t& lock, uint8_t& motion, uint8_t& obstruction); - void sendCommand(Commands command); + void sendCommandAndSaveCounter(Commands command); /** Register a child component. */ void register_child(RATGDOClient* obj);