From cc748f346c62754b76bcc10ed5dc30e997773f70 Mon Sep 17 00:00:00 2001 From: Gregg Date: Tue, 22 Dec 2020 17:27:56 -0600 Subject: [PATCH] Updated RFControl Changed enum class PHASE back to simple uint8. Was too complicated to have a dedicted structure just to represent HIGH and LOW. --- src/extras/RFControl.cpp | 12 +++++------- src/extras/RFControl.h | 10 +--------- src/extras/extras.ino | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/extras/RFControl.cpp b/src/extras/RFControl.cpp index 5938089..0e5990a 100644 --- a/src/extras/RFControl.cpp +++ b/src/extras/RFControl.cpp @@ -56,13 +56,13 @@ void RFControl::clear(){ void RFControl::add(uint16_t onTime, uint16_t offTime){ - phase(onTime,RF_HIGH); - phase(offTime,RF_LOW); + phase(onTime,HIGH); + phase(offTime,LOW); } /////////////////// -void RFControl::phase(uint16_t numTicks, PHASE phase){ +void RFControl::phase(uint16_t numTicks, uint8_t phase){ if(pCount==1023){ // maximum number of entries reached (saving one space for end-marker) Serial.print("\n*** ERROR: Can't add more than 1023 entries to RF Control Module\n\n"); @@ -77,9 +77,9 @@ void RFControl::phase(uint16_t numTicks, PHASE phase){ int index=pCount/2; if(pCount%2==0) - pRMT[index]=numTicks | (int)phase; // load entry into lower 16 bits of 32-bit memory + pRMT[index]=numTicks | (phase?(1<<15):0); // load entry into lower 16 bits of 32-bit memory else - pRMT[index]=pRMT[index] & 0xFFFF | (numTicks<<16) | ((int)phase<<16); // load entry into upper 16 bits of 32-bit memory, preserving lower 16 bits + pRMT[index]=pRMT[index] & 0xFFFF | (numTicks<<16) | (phase?(1<<31):0); // load entry into upper 16 bits of 32-bit memory, preserving lower 16 bits pCount++; } @@ -101,5 +101,3 @@ boolean RFControl::configured=false; volatile int RFControl::numCycles; uint32_t *RFControl::pRMT=(uint32_t *)RMT_CHANNEL_MEM(0); int RFControl::pCount=0; -RFControl::PHASE RF_LOW=RFControl::PHASE::Low; -RFControl::PHASE RF_HIGH=RFControl::PHASE::High; diff --git a/src/extras/RFControl.h b/src/extras/RFControl.h index 99a3433..1c26111 100644 --- a/src/extras/RFControl.h +++ b/src/extras/RFControl.h @@ -13,19 +13,11 @@ class RFControl { static void eot_int(void *arg); public: - - enum class PHASE { - Low=0, - High=0x8000 - }; - RFControl(int pin); // creates transmitter on pin static void clear(); // clears transmitter memory static void add(uint16_t onTime, uint16_t offTime); // adds pulse of onTime ticks HIGH followed by offTime ticks LOW - static void phase(uint16_t numTicks, PHASE phase); // adds either a HIGH phase or LOW phase lasting numTicks ticks + static void phase(uint16_t numTicks, uint8_t phase); // adds either a HIGH phase or LOW phase lasting numTicks ticks void start(uint8_t _numCycles, uint8_t tickTime=1); // starts transmission of pulses, repeated for numCycles, where each tick in pulse is tickTime microseconds long }; -extern RFControl::PHASE RF_LOW; -extern RFControl::PHASE RF_HIGH; diff --git a/src/extras/extras.ino b/src/extras/extras.ino index 1f85782..d07e894 100644 --- a/src/extras/extras.ino +++ b/src/extras/extras.ino @@ -18,7 +18,7 @@ void setup(){ rf.clear(); for(int i=0;i<3;i++) rf.add(2000,2000); - rf.phase(10000,RF_LOW); + rf.phase(10000,0); rf.start(5,100); Serial.println("Done!");