From 9e0db9d537a788b1d34bd116a71f1d62af86ad14 Mon Sep 17 00:00:00 2001 From: nick6x Date: Wed, 17 Aug 2016 14:17:56 -0700 Subject: [PATCH] Update HamShield examples to work with seperated libraries. --- .../AFSK_PacketTester/AFSK_PacketTester.ino | 17 ++++++++++------- .../AFSK_SerialMessenger.ino | 17 ++++++++++------- examples/AX25Receive/AX25Receive.ino | 13 ++++++++----- examples/KISS/KISS.ino | 4 +++- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/examples/AFSK_PacketTester/AFSK_PacketTester.ino b/examples/AFSK_PacketTester/AFSK_PacketTester.ino index fc505d1..bd8e47d 100644 --- a/examples/AFSK_PacketTester/AFSK_PacketTester.ino +++ b/examples/AFSK_PacketTester/AFSK_PacketTester.ino @@ -15,6 +15,8 @@ #define DDS_REFCLK_DEFAULT 9600 #include +#include +#include #include #define PWM_PIN 3 @@ -23,6 +25,7 @@ HamShield radio; DDS dds; +AFSK afsk; String messagebuff = ""; String origin_call = ""; String destination_call = ""; @@ -48,7 +51,7 @@ void setup() { radio.frequency(144390); radio.setRfPower(0); dds.start(); - radio.afsk.start(&dds); + afsk.start(&dds); delay(100); Serial.println("HELLO"); } @@ -78,13 +81,13 @@ void prepMessage() { packet->print(textmessage); packet->finish(); - bool ret = radio.afsk.putTXPacket(packet); + bool ret = afsk.putTXPacket(packet); - if(radio.afsk.txReady()) { + if(afsk.txReady()) { Serial.println(F("txReady")); radio.setModeTransmit(); //delay(100); - if(radio.afsk.txStart()) { + if(afsk.txStart()) { Serial.println(F("txStart")); } else { radio.setModeReceive(); @@ -95,7 +98,7 @@ void prepMessage() { // Wait up to 2.5 seconds to finish sending, and stop transmitter. // TODO: This is hackery. for(int i = 0; i < 500; i++) { - if(radio.afsk.encoder.isDone()) + if(afsk.encoder.isDone()) break; delay(50); } @@ -117,8 +120,8 @@ ISR(ADC_vect) { TIFR1 = _BV(ICF1); // Clear the timer flag dds.clockTick(); if(++tcnt == 1) { - if(radio.afsk.encoder.isSending()) { - radio.afsk.timer(); + if(afsk.encoder.isSending()) { + afsk.timer(); } tcnt = 0; } diff --git a/examples/AFSK_SerialMessenger/AFSK_SerialMessenger.ino b/examples/AFSK_SerialMessenger/AFSK_SerialMessenger.ino index 96434bc..276ec48 100644 --- a/examples/AFSK_SerialMessenger/AFSK_SerialMessenger.ino +++ b/examples/AFSK_SerialMessenger/AFSK_SerialMessenger.ino @@ -16,6 +16,8 @@ #define DDS_REFCLK_DEFAULT 9600 #include +#include +#include #include #define PWM_PIN 3 @@ -24,6 +26,7 @@ HamShield radio; DDS dds; +AFSK afsk; String messagebuff = ""; String origin_call = ""; String destination_call = ""; @@ -49,7 +52,7 @@ void setup() { radio.frequency(145570); radio.setRfPower(0); dds.start(); - radio.afsk.start(&dds); + afsk.start(&dds); delay(100); Serial.println("HELLO"); } @@ -91,13 +94,13 @@ void prepMessage() { textmessage = ""; - bool ret = radio.afsk.putTXPacket(packet); + bool ret = afsk.putTXPacket(packet); - if(radio.afsk.txReady()) { + if(afsk.txReady()) { Serial.println(F("txReady")); //radio.setModeTransmit(); //delay(100); - if(radio.afsk.txStart()) { + if(afsk.txStart()) { Serial.println(F("txStart")); } else { radio.setModeReceive(); @@ -108,7 +111,7 @@ void prepMessage() { // Wait up to 2.5 seconds to finish sending, and stop transmitter. // TODO: This is hackery. for(int i = 0; i < 500; i++) { - if(radio.afsk.encoder.isDone()) + if(afsk.encoder.isDone()) break; delay(50); } @@ -136,8 +139,8 @@ ISR(ADC_vect) { //PORTD |= _BV(2); // Diagnostic pin (D2) dds.clockTick(); if(++tcnt == 1) { - if(radio.afsk.encoder.isSending()) { - radio.afsk.timer(); + if(afsk.encoder.isSending()) { + afsk.timer(); } tcnt = 0; } diff --git a/examples/AX25Receive/AX25Receive.ino b/examples/AX25Receive/AX25Receive.ino index f06332d..d26ebf3 100644 --- a/examples/AX25Receive/AX25Receive.ino +++ b/examples/AX25Receive/AX25Receive.ino @@ -13,6 +13,8 @@ */ #include +#include +#include #define PWM_PIN 3 #define RESET_PIN A3 @@ -20,6 +22,7 @@ HamShield radio; DDS dds; +AFSK afsk; void setup() { // NOTE: if not using PWM out, it should be held low to avoid tx noise @@ -55,7 +58,7 @@ void setup() { dds.start(); Serial.println(F("AFSK start")); delay(100); - radio.afsk.start(&dds); + afsk.start(&dds); Serial.println(F("Starting...")); delay(100); dds.setAmplitude(255); @@ -63,11 +66,11 @@ void setup() { uint32_t last = 0; void loop() { - if(radio.afsk.decoder.read() || radio.afsk.rxPacketCount()) { + if(afsk.decoder.read() || afsk.rxPacketCount()) { // A true return means something was put onto the packet FIFO // If we actually have data packets in the buffer, process them all now - while(radio.afsk.rxPacketCount()) { - AFSK::Packet *packet = radio.afsk.getRXPacket(); + while(afsk.rxPacketCount()) { + AFSK::Packet *packet = afsk.getRXPacket(); Serial.print(F("Packet: ")); if(packet) { packet->printPacket(&Serial); @@ -83,6 +86,6 @@ ISR(ADC_vect) { TIFR1 = _BV(ICF1); // Clear the timer flag //PORTD |= _BV(2); // Diagnostic pin (D2) //dds.clockTick(); - radio.afsk.timer(); + afsk.timer(); //PORTD &= ~(_BV(2)); // Pin D2 off again } diff --git a/examples/KISS/KISS.ino b/examples/KISS/KISS.ino index 16d7d64..e5e0956 100644 --- a/examples/KISS/KISS.ino +++ b/examples/KISS/KISS.ino @@ -11,10 +11,12 @@ #include #include +#include HamShield radio; DDS dds; KISS kiss(&Serial, &radio, &dds); +AFSK afsk; //TODO: move these into library #define PWM_PIN 3 @@ -46,7 +48,7 @@ void setup() { //I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0x05FF); dds.start(); - radio.afsk.start(&dds); + afsk.start(&dds); } void loop() {