From a38ac4bf27f975e1650a6cf7a01288a045cdff64 Mon Sep 17 00:00:00 2001 From: morgan Date: Sun, 21 Oct 2018 19:27:24 -0700 Subject: [PATCH] update examples, rev arduino version --- examples/CTCSS/CTCSS.ino | 2 +- examples/Morse/Morse.ino | 25 ++++++++++++++++++------- library.properties | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/examples/CTCSS/CTCSS.ino b/examples/CTCSS/CTCSS.ino index 9a09a28..d2729be 100644 --- a/examples/CTCSS/CTCSS.ino +++ b/examples/CTCSS/CTCSS.ino @@ -95,7 +95,7 @@ void setup() { radio.setRfPower(0); // CTCSS Setup code - ctcss_tone = 134.4; + ctcss_tone = 131.8; radio.setCtcss(ctcss_tone); radio.enableCtcss(); Serial.print("ctcss tone: "); diff --git a/examples/Morse/Morse.ino b/examples/Morse/Morse.ino index beab6f8..e80738a 100644 --- a/examples/Morse/Morse.ino +++ b/examples/Morse/Morse.ino @@ -22,7 +22,17 @@ #define MORSE_FREQ 600 #define MORSE_DOT 100 // ms // Note that all timing is defined in terms of MORSE_DOT relative durations -// You may want to tweak those timings in the receiver below +// You may want to tweak those timings below + +#define SYMBOL_END_TIME 5 //millis +#define CHAR_END_TIME (MORSE_DOT*2.3) +#define MESSAGE_END_TIME (MORSE_DOT*15) + +#define MIN_DOT_TIME (MORSE_DOT*0.7) +#define MAX_DOT_TIME (MORSE_DOT*1.3) +#define MIN_DASH_TIME (MORSE_DOT*2.7) +#define MAX_DASH_TIME (MORSE_DOT*3.3) + HamShield radio; @@ -98,7 +108,7 @@ void loop() { // we wait for a bit of silence before ending the last // symbol in order to smooth out the detector - if ((millis() - space_in_progress) > 5) //MORSE_DOT*0.05) + if ((millis() - space_in_progress) > SYMBOL_END_TIME) { if (tone_in_progress != 0) { // end the last tone @@ -109,7 +119,7 @@ void loop() { } // we might be done with a character if the space is long enough - if ((millis() - space_in_progress) > MORSE_DOT*2.3) { + if ((millis() - space_in_progress) > CHAR_END_TIME) { char m = parseMorse(); if (m != 0) { rx_msg[rx_idx++] = m; @@ -117,7 +127,7 @@ void loop() { } // we might be done with a message if the space is long enough - if ((millis() - space_in_progress) > MORSE_DOT*15) { + if ((millis() - space_in_progress) > MESSAGE_END_TIME) { if (rx_idx > 0) { // we got a message, print it now rx_msg[rx_idx] = '\0'; // null terminate @@ -163,16 +173,17 @@ void loop() { void handleTone(uint16_t tone_time) { //Serial.println(tone_time); - if (tone_time > (MORSE_DOT*0.7) && tone_time < (MORSE_DOT*1.3)) { + if (tone_time > MIN_DOT_TIME && tone_time < MAX_DOT_TIME) { // add a dot //Serial.print("."); //nothing to do for this bit position, since . = 0 - } else if (tone_time > (MORSE_DOT*2.7) && tone_time < (MORSE_DOT*3.3)) { + } else if (tone_time > MIN_DASH_TIME && tone_time < MAX_DASH_TIME) { // add a dash //Serial.print("-"); rx_morse_char += rx_morse_bit; } + // prep for the next bit rx_morse_bit = rx_morse_bit << 1; } @@ -189,4 +200,4 @@ char parseMorse() { rx_morse_bit = 1; return c; } - + diff --git a/library.properties b/library.properties index 12cfa86..362030a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=HamShield -version=1.0.6 +version=1.1.0 author=Morgan Redfield , Casey Halverson maintainer=Morgan Redfield sentence=A library for use with HamShield by Enhanced Radio Devices.