diff --git a/HamShield.cpp b/HamShield.cpp index 430e2f4..afadace 100644 --- a/HamShield.cpp +++ b/HamShield.cpp @@ -1129,23 +1129,14 @@ uint32_t HamShield::findWhitespaceChannels(uint32_t buffer[],uint8_t buffsize, u } -/* -BUG: I cannot figure out how to attach these interrupt handlers without the error: - -/Users/casey/Documents/Arduino/libraries/HamShield/HamShield.cpp: In member function 'void HamShield::buttonMode(uint8_t)': -/Users/casey/Documents/Arduino/libraries/HamShield/HamShield.cpp:1125: error: argument of type 'void (HamShield::)()' does not match 'void (*)()' -/Users/casey/Documents/Arduino/libraries/HamShield/HamShield.cpp:1126: error: argument of type 'void (HamShield::)()' does not match 'void (*)()' -*/ - - -/* +/* Setup the auxiliary button input mode and register the ISR */ void HamShield::buttonMode(uint8_t mode) { pinMode(HAMSHIELD_AUX_BUTTON,INPUT); // set the pin mode to input - digitalWrite(HAMSHIELD_AUX_BUTTON,HIGH); // turn on internal pull up - if(mode == PTT_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, isr_ptt, CHANGE); } - if(mode == RESET_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, isr_reset, CHANGE); } + digitalWrite(HAMSHIELD_AUX_BUTTON,HIGH); // turn on internal pull up + sHamShield = this; + if(mode == PTT_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, HamShield::isr_ptt, CHANGE); } + if(mode == RESET_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, HamShield::isr_reset, CHANGE); } } -*/ /* Interrupt routines */ @@ -1162,12 +1153,12 @@ void HamShield::isr_ptt() { if((bouncer + 200) > millis()) { if(ptt == false) { ptt = true; - HamShield::setModeTransmit(); + sHamShield->setModeTransmit(); bouncer = millis(); } if(ptt == true) { ptt = false; - HamShield::setModeReceive(); + sHamShield->setModeReceive(); bouncer = millis(); } } } @@ -1359,4 +1350,4 @@ void HamShield::AFSKOut(char buffer[80]) { startPlayback(AFSK_space, sizeof(AFSK_space)); delay(8); } } -*/ \ No newline at end of file +*/ diff --git a/HamShield.h b/HamShield.h index 7f2aa97..45949a1 100644 --- a/HamShield.h +++ b/HamShield.h @@ -519,8 +519,8 @@ class HamShield { uint32_t scanChannels(uint32_t buffer[],uint8_t buffsize, uint8_t speed, uint16_t threshold); uint32_t findWhitespaceChannels(uint32_t buffer[],uint8_t buffsize, uint8_t dwell, uint16_t threshold); void buttonMode(uint8_t mode); - void isr_ptt(); - void isr_reset(); + static void isr_ptt(); + static void isr_reset(); void morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]); char morseLookup(char letter); bool waitForChannel(long timeout, long breakwindow, int setRSSI); @@ -541,7 +541,7 @@ class HamShield { uint32_t GMRS[]; uint32_t MURS[]; uint32_t WX[]; - + static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly // int8_t A1846S::readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout); // int8_t A1846S::readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout);