From 5874e6b8e5297e8f9df1f17eea241cedd59925ac Mon Sep 17 00:00:00 2001 From: morgan Date: Mon, 19 Dec 2016 11:40:44 -0800 Subject: [PATCH] make morse tone freq user settable --- examples/FMBeacon/FMBeacon.ino | 2 ++ src/HamShield.cpp | 18 ++++++++++++++++-- src/HamShield.h | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/FMBeacon/FMBeacon.ino b/examples/FMBeacon/FMBeacon.ino index cf12f6c..98042fd 100644 --- a/examples/FMBeacon/FMBeacon.ino +++ b/examples/FMBeacon/FMBeacon.ino @@ -52,6 +52,8 @@ void setup() { // Tell the HamShield to start up radio.initialize(); radio.setRfPower(0); + + radio.setMorseFreq(400); // Configure the HamShield to transmit and recieve on 446.000MHz radio.frequency(438000); diff --git a/src/HamShield.cpp b/src/HamShield.cpp index 62c0f9b..9edd28c 100644 --- a/src/HamShield.cpp +++ b/src/HamShield.cpp @@ -24,6 +24,9 @@ const uint32_t MURS[] PROGMEM = {0,151820,151880,151940,154570,154600}; const uint32_t WX[] PROGMEM = {0,162550,162400,162475,162425,162450,162500,162525}; + +unsigned int morse_freq = 600; + /* morse code lookup table */ // This is the Morse table in reverse binary format. // It will occupy 108 bytes of memory (or program memory if defined) @@ -1283,6 +1286,17 @@ bool HamShield::waitForChannel(long timeout = 0, long breakwindow = 0, int setRS return false; } +// Get current morse code tone frequency (in Hz) + +unsigned int HamShield::getMorseFreq() { + return morse_freq; +} + +// Set current morse code tone frequency (in Hz) + +void HamShield::setMorseFreq(unsigned int morse_freq_hz) { + morse_freq = morse_freq_hz; +} /* Morse code out, blocking */ @@ -1308,10 +1322,10 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) { if(bits) { // If it is a valid character... do { if(bits & 1) { - tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT * 3); + tone(HAMSHIELD_PWM_PIN, morse_freq, HAMSHIELD_MORSE_DOT * 3); delay(HAMSHIELD_MORSE_DOT*3); } else { - tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT); + tone(HAMSHIELD_PWM_PIN, morse_freq, HAMSHIELD_MORSE_DOT); delay(HAMSHIELD_MORSE_DOT); } tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT); diff --git a/src/HamShield.h b/src/HamShield.h index f7efe6e..9093526 100644 --- a/src/HamShield.h +++ b/src/HamShield.h @@ -481,6 +481,8 @@ class HamShield { void buttonMode(uint8_t mode); static void isr_ptt(); static void isr_reset(); + unsigned int getMorseFreq(); + void setMorseFreq(unsigned int morse_freq_hz); void morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]); uint8_t morseLookup(char letter); bool waitForChannel(long timeout, long breakwindow, int setRSSI);