From 001102656722262465ce7b45e6be074ad035f729 Mon Sep 17 00:00:00 2001 From: morgan Date: Sun, 17 Apr 2016 17:19:33 -0700 Subject: [PATCH] fix dangermode --- HamShield.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/HamShield.cpp b/HamShield.cpp index ee9cfd8..d2b49d0 100644 --- a/HamShield.cpp +++ b/HamShield.cpp @@ -121,6 +121,11 @@ volatile long bouncer = 0; HamShield::HamShield() { devAddr = A1846S_DEV_ADDR_SENLOW; sHamShield = this; + + pinMode(A1, OUTPUT); + digitalWrite(A1, HIGH); + pinMode(A4, OUTPUT); + pinMode(A5, OUTPUT); } /** Specific address constructor. @@ -131,6 +136,11 @@ HamShield::HamShield() { */ HamShield::HamShield(uint8_t address) { devAddr = address; + + pinMode(A1, OUTPUT); + digitalWrite(A1, HIGH); + pinMode(A4, OUTPUT); + pinMode(A5, OUTPUT); } /** Power on and prepare for general usage. @@ -142,11 +152,6 @@ void HamShield::initialize() { uint16_t tx_data; - pinMode(A1, OUTPUT); - digitalWrite(A1, HIGH); - pinMode(A4, OUTPUT); - pinMode(A5, OUTPUT); - // reset all registers in A1846S softReset(); @@ -485,12 +490,16 @@ bool HamShield::getRX(){ void HamShield::setModeTransmit(){ // check to see if we should allow them to do this if(restrictions == true) { - if((radio_frequency > 139999) & (radio_frequency < 148001)) { setRX(false); } - if((radio_frequency > 218999) & (radio_frequency < 225001)) { setRX(false); } - if((radio_frequency > 419999) & (radio_frequency < 450001)) { setRX(false); } - } else { - setTX(true); - } + if(((radio_frequency > 139999) & (radio_frequency < 148001)) || + ((radio_frequency > 218999) & (radio_frequency < 225001)) || + ((radio_frequency > 419999) & (radio_frequency < 450001))) + { // we're good, so just drop down to the rest of this function + } else { + setRX(false); + return; + } + } + setTX(true); } void HamShield::setModeReceive(){ // turn on rx, turn off tx @@ -995,7 +1004,7 @@ bool HamShield::getPreDeEmphEnabled(){ int16_t HamShield::readRSSI(){ HSreadBitsW(devAddr, A1846S_RSSI_REG, A1846S_RSSI_BIT, A1846S_RSSI_LENGTH, radio_i2c_buf); - int16_t rssi = (radio_i2c_buf[0] & 0xFF); // - 137; + int16_t rssi = (radio_i2c_buf[0] & 0xFF) - 137; return rssi; } uint16_t HamShield::readVSSI(){