merging
This commit is contained in:
commit
705884497a
|
@ -1290,10 +1290,13 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
|
|||
if(buffer[i] == ' ') {
|
||||
// We delay by 4 here, if we previously sent a symbol. Otherwise 7.
|
||||
// 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);
|
||||
else
|
||||
} else {
|
||||
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 4);
|
||||
delay(HAMSHIELD_MORSE_DOT*4);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Otherwise, lookup our character symbol
|
||||
|
@ -1301,17 +1304,19 @@ 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, 1000, HAMSHIELD_MORSE_DOT * 3);
|
||||
tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT * 3);
|
||||
delay(HAMSHIELD_MORSE_DOT*3);
|
||||
} else {
|
||||
tone(HAMSHIELD_PWM_PIN, 1000, HAMSHIELD_MORSE_DOT);
|
||||
tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT);
|
||||
delay(HAMSHIELD_MORSE_DOT);
|
||||
}
|
||||
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT);
|
||||
delay(HAMSHIELD_MORSE_DOT);
|
||||
bits >>= 1; // Shift into the next symbol
|
||||
} while(bits != 1); // Wait for 1 termination to be all we have left
|
||||
}
|
||||
// End of character
|
||||
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 3);
|
||||
delay(HAMSHIELD_MORSE_DOT * 3);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#define DDS_REFCLK_DEFAULT 9600
|
||||
|
||||
#include <HamShield.h>
|
||||
|
@ -14,7 +13,6 @@
|
|||
#define RESET_PIN A3
|
||||
#define SWITCH_PIN 2
|
||||
|
||||
|
||||
HamShield radio;
|
||||
DDS dds;
|
||||
String messagebuff = "";
|
||||
|
@ -47,16 +45,12 @@ void setup() {
|
|||
Serial.println("HELLO");
|
||||
}
|
||||
|
||||
String temp[1] = "";
|
||||
|
||||
|
||||
void loop() {
|
||||
messagebuff = "KC7IBT,KC7IBT,:HAMSHIELD TEST";
|
||||
prepMessage();
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
|
||||
void prepMessage() {
|
||||
radio.setModeTransmit();
|
||||
delay(500);
|
||||
|
@ -76,7 +70,6 @@ void prepMessage() {
|
|||
packet->print(textmessage);
|
||||
packet->finish();
|
||||
|
||||
|
||||
bool ret = radio.afsk.putTXPacket(packet);
|
||||
|
||||
if(radio.afsk.txReady()) {
|
||||
|
@ -99,18 +92,14 @@ void prepMessage() {
|
|||
delay(50);
|
||||
}
|
||||
Serial.println("Done sending");
|
||||
delay(3000);
|
||||
radio.setModeReceive();
|
||||
}
|
||||
|
||||
|
||||
ISR(TIMER2_OVF_vect) {
|
||||
TIFR2 = _BV(TOV2);
|
||||
static uint8_t tcnt = 0;
|
||||
if(++tcnt == 8) {
|
||||
digitalWrite(2, HIGH);
|
||||
dds.clockTick();
|
||||
digitalWrite(2, LOW);
|
||||
tcnt = 0;
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +107,6 @@ ISR(TIMER2_OVF_vect) {
|
|||
ISR(ADC_vect) {
|
||||
static uint8_t tcnt = 0;
|
||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
||||
PORTD |= _BV(2); // Diagnostic pin (D2)
|
||||
dds.clockTick();
|
||||
if(++tcnt == 1) {
|
||||
if(radio.afsk.encoder.isSending()) {
|
||||
|
@ -126,7 +114,4 @@ ISR(ADC_vect) {
|
|||
}
|
||||
tcnt = 0;
|
||||
}
|
||||
PORTD &= ~(_BV(2)); // Pin D2 off again
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
#include <HamShield.h>
|
||||
|
||||
HamShield radio;
|
||||
DDS dds;
|
||||
|
||||
#define PWM_PIN 3
|
||||
#define RESET_PIN A3
|
||||
#define SWITCH_PIN 2
|
||||
|
||||
#define DON(p) PORTD |= _BV((p))
|
||||
#define DOFF(p) PORTD &= ~(_BV((p)))
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
pinMode(4, OUTPUT);
|
||||
pinMode(5, OUTPUT);
|
||||
pinMode(6, OUTPUT);
|
||||
pinMode(7, OUTPUT);
|
||||
|
||||
// NOTE: if not using PWM out, it should be held low to avoid tx noise
|
||||
pinMode(PWM_PIN, OUTPUT);
|
||||
digitalWrite(PWM_PIN, LOW);
|
||||
|
||||
// prep the switch
|
||||
pinMode(SWITCH_PIN, INPUT_PULLUP);
|
||||
|
||||
// set up the reset control pin
|
||||
pinMode(RESET_PIN, OUTPUT);
|
||||
// turn on pwr to the radio
|
||||
digitalWrite(RESET_PIN, HIGH);
|
||||
|
||||
Serial.println(F("Radio test connection"));
|
||||
Serial.println(radio.testConnection(), DEC);
|
||||
Serial.println(F("Initialize"));
|
||||
delay(100);
|
||||
radio.initialize();
|
||||
Serial.println(F("Frequency"));
|
||||
delay(100);
|
||||
radio.frequency(145010);
|
||||
//radio.setRfPower(0);
|
||||
delay(100);
|
||||
dds.start();
|
||||
delay(100);
|
||||
radio.afsk.start(&dds);
|
||||
delay(100);
|
||||
dds.setFrequency(0);
|
||||
dds.on();
|
||||
dds.setAmplitude(255);
|
||||
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0b0000011111111111);
|
||||
//I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x53, 0x0);
|
||||
//I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x32, 0xffff);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
DON(6);
|
||||
AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32);
|
||||
packet->start();
|
||||
packet->appendCallsign("VE6SLP",0);
|
||||
packet->appendCallsign("VA6GA",15,true);
|
||||
packet->appendFCS(0x03);
|
||||
packet->appendFCS(0xf0);
|
||||
packet->print(F("Hello "));
|
||||
packet->print(millis());
|
||||
packet->println(F("\r\nThis is a test of the HamShield Kickstarter prototype. de VE6SLP"));
|
||||
packet->finish();
|
||||
|
||||
bool ret = radio.afsk.putTXPacket(packet);
|
||||
|
||||
if(radio.afsk.txReady()) {
|
||||
Serial.println(F("txReady"));
|
||||
radio.setModeTransmit();
|
||||
if(radio.afsk.txStart()) {
|
||||
Serial.println(F("txStart"));
|
||||
} else {
|
||||
Serial.println(F("Tx Start failure"));
|
||||
radio.setModeReceive();
|
||||
}
|
||||
}
|
||||
// Wait 2 seconds before we send our beacon again.
|
||||
Serial.println("tick");
|
||||
// Wait up to 2.5 seconds to finish sending, and stop transmitter.
|
||||
// TODO: This is hackery.
|
||||
DOFF(6);
|
||||
for(int i = 0; i < 500; i++) {
|
||||
if(radio.afsk.encoder.isDone())
|
||||
break;
|
||||
delay(50);
|
||||
Serial.println("Not done");
|
||||
}
|
||||
Serial.println("Done sending");
|
||||
delay(100);
|
||||
radio.setModeReceive();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
ISR(ADC_vect) {
|
||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
||||
DON(4);
|
||||
dds.clockTick();
|
||||
DON(5);
|
||||
radio.afsk.timer();
|
||||
DOFF(5);
|
||||
DOFF(4);
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
// Example sketch to show how to transmit arbitrary tones.
|
||||
// In this case, the sketch alternates between 1200Hz and 2200Hz at 1s intervals.
|
||||
|
||||
#define DDS_REFCLK_DEFAULT 9600
|
||||
#include <HamShield.h>
|
||||
|
||||
|
||||
#define PWM_PIN 3
|
||||
#define RESET_PIN A3
|
||||
#define SWITCH_PIN 2
|
||||
|
@ -24,7 +26,7 @@ void setup() {
|
|||
|
||||
radio.initialize();
|
||||
radio.setRfPower(0);
|
||||
radio.setFrequency(145060);
|
||||
radio.frequency(438000);
|
||||
radio.setModeTransmit();
|
||||
dds.start();
|
||||
dds.playWait(600, 3000);
|
||||
|
@ -48,10 +50,8 @@ ISR(ADC_vect) {
|
|||
static unsigned char tcnt = 0;
|
||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
||||
if(++tcnt == 4) {
|
||||
//digitalWrite(2, HIGH);
|
||||
tcnt = 0;
|
||||
}
|
||||
dds.clockTick();
|
||||
//digitalWrite(2, LOW);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -3,16 +3,18 @@ Morse Code Beacon
|
|||
|
||||
Test beacon will transmit and wait 30 seconds.
|
||||
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>
|
||||
|
||||
#define PWM_PIN 3
|
||||
#define RESET_PIN A3
|
||||
#define SWITCH_PIN 2
|
||||
|
||||
// Create a new instance of our HamSheild class, called 'radio'
|
||||
HamShield radio;
|
||||
|
||||
// Run our start up things here
|
||||
|
@ -42,8 +44,9 @@ void setup() {
|
|||
// Tell the HamShield to start up
|
||||
radio.initialize();
|
||||
radio.setRfPower(0);
|
||||
|
||||
// Configure the HamShield to transmit and recieve on 446.000MHz
|
||||
radio.frequency(145570);
|
||||
radio.frequency(438000);
|
||||
|
||||
Serial.println("Radio Configured.");
|
||||
}
|
||||
|
@ -66,7 +69,7 @@ void loop() {
|
|||
radio.setModeReceive();
|
||||
Serial.println("Done.");
|
||||
|
||||
// Wait 30 seconds before we send our beacon again.
|
||||
// Wait a second before we send our beacon again.
|
||||
delay(1000);
|
||||
} else {
|
||||
// If we get here, the channel is busy. Let's also print out the RSSI.
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#define RESET_PIN A3
|
||||
#define SWITCH_PIN 2
|
||||
|
||||
// transmit for 1 minute, every 10 minutes
|
||||
|
||||
#define TRANSMITLENGTH 1
|
||||
// In milliseconds
|
||||
#define TRANSMITLENGTH 60000
|
||||
// In minutes
|
||||
#define INTERVAL 10
|
||||
#define RANDOMCHANCE 3
|
||||
|
||||
|
@ -27,23 +27,23 @@ void setup() {
|
|||
digitalWrite(RESET_PIN, HIGH);
|
||||
|
||||
radio.initialize();
|
||||
radio.frequency(145510);
|
||||
radio.setRfPower(0);
|
||||
radio.frequency(438000);
|
||||
radio.setModeReceive();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
waitMinute(INTERVAL + random(0,RANDOMCHANCE)); // wait before transmitting, randomly up to 3 minutes later
|
||||
if(radio.waitForChannel(30000,2000, -90)) { // wait for a clear channel, abort after 30 seconds, wait 2 seconds of dead air for breakers
|
||||
radio.setModeTransmit(); // turn on transmit mode
|
||||
tone(1000,11,TRANSMITLENGTH * 60 * 1000); // play a long solid tone
|
||||
tone(PWM_PIN, 1000, TRANSMITLENGTH); // play a long solid tone
|
||||
delay(TRANSMITLENGTH);
|
||||
radio.morseOut(" 1ZZ9ZZ/B FOXHUNT"); // identify the fox hunt transmitter
|
||||
radio.setModeReceive(); // turn off the transmit mode
|
||||
}
|
||||
waitMinute(INTERVAL + random(0,RANDOMCHANCE)); // wait before transmitting, randomly
|
||||
}
|
||||
|
||||
// a function so we can wait by minutes
|
||||
|
||||
void waitMinute(int period) {
|
||||
void waitMinute(unsigned long period) {
|
||||
delay(period * 60 * 1000);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue