update ctcss getfreq and example

This commit is contained in:
Morgan Redfield 2018-08-15 19:30:20 -07:00
parent 96d02c3bd9
commit afbecf6e5e
3 changed files with 17 additions and 14 deletions

View File

@ -95,12 +95,13 @@ void setup() {
radio.setRfPower(0);
// CTCSS Setup code
ctcss_tone = 103.5;
ctcss_tone = 134.4;
radio.setCtcss(ctcss_tone);
radio.enableCtcss();
Serial.print("ctcss tone: ");
Serial.println(radio.getCtcssFreqHz());
// mute audio until we get a CTCSS tone
radio.setMute();
// radio.setMute();
muted = true;
// configure Arduino LED for
@ -116,13 +117,13 @@ void loop() {
if (radio.getCtcssToneDetected()) {
if (muted) {
muted = false;
radio.setUnmute();
// radio.setUnmute();
Serial.println("tone");
}
} else {
if (!muted) {
muted = true;
radio.setMute();
// radio.setMute();
Serial.println("no tone");
}
}
@ -171,4 +172,4 @@ void loop() {
Serial.println(radio.readRSSI());
rssi_timeout = millis();
}
}
}

View File

@ -1,7 +1,7 @@
/* Hamshield
* Example: Morse Code Transceiver
*
* Serail to Morse transceiver. Sends characters from the Serial
* Serial to Morse transceiver. Sends characters from the Serial
* port over the air, and vice versa.
* Connect the HamShield to your Arduino. Screw the antenna
* into the HamShield RF jack. Connect the Arduino to wall

View File

@ -770,23 +770,25 @@ void HamShield::setCtcss(float freq_Hz) {
}
void HamShield::setCtcssFreq(uint16_t freq_milliHz){
HSwriteWord(devAddr, A1846S_CTCSS_FREQ_REG, freq_milliHz);
// set RX Ctcss match thresholds (based on frequency)
// calculate thresh based on freq
float f = ((float) freq_milliHz)/100;
uint8_t thresh = (uint8_t)(-0.1*f + 25);
setCtcssDetThreshIn(thresh);
setCtcssDetThreshOut(thresh);
HSwriteWord(devAddr, A1846S_CTCSS_FREQ_REG, freq_milliHz);
}
uint16_t HamShield::getCtcssFreqMilliHz(){
HSreadWord(devAddr, A1846S_CTCSS_FREQ_REG, radio_i2c_buf);
return radio_i2c_buf[0];
return getCtcssFreqHz()*100;
}
float HamShield::getCtcssFreqHz() {
return ((float)(getCtcssFreqMilliHz()))/100;
//y = mx + b
float m = 1.678;
float b = -3.3;
HSreadWord(devAddr, A1846S_CTCSS_FREQ_REG, radio_i2c_buf);
float f = (float) radio_i2c_buf[0];
return (f/m-b)/100;
}
void HamShield::setCtcssFreqToStandard(){