Merge pull request #6 from slepp/master

Move singleton to the initializer to be used by more things later
This commit is contained in:
Nigel VH 2015-07-03 22:55:20 -07:00
commit 167c792116
2 changed files with 4 additions and 1 deletions

View File

@ -11,6 +11,7 @@
/* don't change this regulatory value, use dangerMode() and safeMode() instead */ /* don't change this regulatory value, use dangerMode() and safeMode() instead */
bool restrictions = true; bool restrictions = true;
HamShield *HamShield::sHamShield = NULL;
/* channel lookup tables */ /* channel lookup tables */
@ -119,6 +120,7 @@ volatile long bouncer = 0;
*/ */
HamShield::HamShield() { HamShield::HamShield() {
devAddr = A1846S_DEV_ADDR_SENLOW; devAddr = A1846S_DEV_ADDR_SENLOW;
sHamShield = this;
} }
/** Specific address constructor. /** Specific address constructor.
@ -1198,7 +1200,6 @@ uint32_t HamShield::findWhitespaceChannels(uint32_t buffer[],uint8_t buffsize, u
void HamShield::buttonMode(uint8_t mode) { void HamShield::buttonMode(uint8_t mode) {
pinMode(HAMSHIELD_AUX_BUTTON,INPUT); // set the pin mode to input pinMode(HAMSHIELD_AUX_BUTTON,INPUT); // set the pin mode to input
digitalWrite(HAMSHIELD_AUX_BUTTON,HIGH); // turn on internal pull up 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 == PTT_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, HamShield::isr_ptt, CHANGE); }
if(mode == RESET_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, HamShield::isr_reset, CHANGE); } if(mode == RESET_MODE) { attachInterrupt(HAMSHIELD_AUX_BUTTON, HamShield::isr_reset, CHANGE); }
} }

View File

@ -544,6 +544,8 @@ class HamShield {
uint32_t GMRS[]; uint32_t GMRS[];
uint32_t MURS[]; uint32_t MURS[];
uint32_t WX[]; uint32_t WX[];
public:
static HamShield *sHamShield; // HamShield singleton, used for ISRs mostly 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::readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout);