Updated RFControl
Changed enum class PHASE back to simple uint8. Was too complicated to have a dedicted structure just to represent HIGH and LOW.
This commit is contained in:
parent
e7e6d4de61
commit
cc748f346c
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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!");
|
||||
|
|
|
|||
Loading…
Reference in New Issue