From 6a5815d9b5c782c8937afdaab787299bc78f079f Mon Sep 17 00:00:00 2001 From: Stephen Olesen Date: Tue, 30 Jun 2015 16:37:55 -0600 Subject: [PATCH] Move singleton to the initializer to be used by more things later. Made public. --- HamShield.cpp | 3 ++- HamShield.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HamShield.cpp b/HamShield.cpp index afadace..334dfcc 100644 --- a/HamShield.cpp +++ b/HamShield.cpp @@ -11,6 +11,7 @@ /* don't change this regulatory value, use dangerMode() and safeMode() instead */ bool restrictions = true; +HamShield *HamShield::sHamShield = NULL; /* channel lookup tables */ @@ -47,6 +48,7 @@ volatile long bouncer = 0; */ HamShield::HamShield() { devAddr = A1846S_DEV_ADDR_SENLOW; + sHamShield = this; } /** Specific address constructor. @@ -1133,7 +1135,6 @@ uint32_t HamShield::findWhitespaceChannels(uint32_t buffer[],uint8_t buffsize, u 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 - 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); } } diff --git a/HamShield.h b/HamShield.h index 45949a1..d43be05 100644 --- a/HamShield.h +++ b/HamShield.h @@ -541,6 +541,8 @@ class HamShield { uint32_t GMRS[]; uint32_t MURS[]; uint32_t WX[]; + + public: 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);