Fixed FMBeacon example, required slight modification to library. TO-DO notes in example header.

This commit is contained in:
Nigel Vander Houwen 2016-06-05 12:41:35 -07:00
parent 3c9965fd62
commit 8c90a134ad
2 changed files with 17 additions and 9 deletions

View File

@ -1288,10 +1288,13 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
if(buffer[i] == ' ') { if(buffer[i] == ' ') {
// We delay by 4 here, if we previously sent a symbol. Otherwise 7. // We delay by 4 here, if we previously sent a symbol. Otherwise 7.
// This could probably just be always 7 and go relatively unnoticed. // This could probably just be always 7 and go relatively unnoticed.
if(prev == 0 || prev == ' ') if(prev == 0 || prev == ' '){
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 7);
delay(HAMSHIELD_MORSE_DOT*7); delay(HAMSHIELD_MORSE_DOT*7);
else } else {
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 4);
delay(HAMSHIELD_MORSE_DOT*4); delay(HAMSHIELD_MORSE_DOT*4);
}
continue; continue;
} }
// Otherwise, lookup our character symbol // Otherwise, lookup our character symbol
@ -1299,17 +1302,19 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
if(bits) { // If it is a valid character... if(bits) { // If it is a valid character...
do { do {
if(bits & 1) { if(bits & 1) {
tone(HAMSHIELD_PWM_PIN, 1000, HAMSHIELD_MORSE_DOT * 3); tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT * 3);
delay(HAMSHIELD_MORSE_DOT*3); delay(HAMSHIELD_MORSE_DOT*3);
} else { } else {
tone(HAMSHIELD_PWM_PIN, 1000, HAMSHIELD_MORSE_DOT); tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT);
delay(HAMSHIELD_MORSE_DOT); delay(HAMSHIELD_MORSE_DOT);
} }
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT);
delay(HAMSHIELD_MORSE_DOT); delay(HAMSHIELD_MORSE_DOT);
bits >>= 1; // Shift into the next symbol bits >>= 1; // Shift into the next symbol
} while(bits != 1); // Wait for 1 termination to be all we have left } while(bits != 1); // Wait for 1 termination to be all we have left
} }
// End of character // End of character
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 3);
delay(HAMSHIELD_MORSE_DOT * 3); delay(HAMSHIELD_MORSE_DOT * 3);
} }
return; return;

View File

@ -3,16 +3,18 @@ Morse Code Beacon
Test beacon will transmit and wait 30 seconds. Test beacon will transmit and wait 30 seconds.
Beacon will check to see if the channel is clear before it will transmit. Beacon will check to see if the channel is clear before it will transmit.
TO-DO: Radio chip audio AGC too slow in responding to tones, worked around by playing a 6khz tone between actual dits/dahs.
Should work on adjusting AGC to not require this.
*/ */
// Include the HamSheild #define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h> #include <HamShield.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
#define SWITCH_PIN 2 #define SWITCH_PIN 2
// Create a new instance of our HamSheild class, called 'radio'
HamShield radio; HamShield radio;
// Run our start up things here // Run our start up things here
@ -42,8 +44,9 @@ void setup() {
// Tell the HamShield to start up // Tell the HamShield to start up
radio.initialize(); radio.initialize();
radio.setRfPower(0); radio.setRfPower(0);
// Configure the HamShield to transmit and recieve on 446.000MHz // Configure the HamShield to transmit and recieve on 446.000MHz
radio.frequency(145570); radio.frequency(438000);
Serial.println("Radio Configured."); Serial.println("Radio Configured.");
} }
@ -60,13 +63,13 @@ void loop() {
radio.setModeTransmit(); radio.setModeTransmit();
// Send a message out in morse code // Send a message out in morse code
radio.morseOut("KC7IBT ARDUINO HAMSHIELD"); radio.morseOut(" KC7IBT ARDUINO HAMSHIELD");
// We're done sending the message, set the radio back into recieve mode. // We're done sending the message, set the radio back into recieve mode.
radio.setModeReceive(); radio.setModeReceive();
Serial.println("Done."); Serial.println("Done.");
// Wait 30 seconds before we send our beacon again. // Wait a second before we send our beacon again.
delay(1000); delay(1000);
} else { } else {
// If we get here, the channel is busy. Let's also print out the RSSI. // If we get here, the channel is busy. Let's also print out the RSSI.