Update HamShield examples to work with seperated libraries.
This commit is contained in:
parent
bce0b1e0d8
commit
9e0db9d537
|
@ -15,6 +15,8 @@
|
||||||
#define DDS_REFCLK_DEFAULT 9600
|
#define DDS_REFCLK_DEFAULT 9600
|
||||||
|
|
||||||
#include <HamShield.h>
|
#include <HamShield.h>
|
||||||
|
#include <DDS.h>
|
||||||
|
#include <AFSK.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
#define PWM_PIN 3
|
#define PWM_PIN 3
|
||||||
|
@ -23,6 +25,7 @@
|
||||||
|
|
||||||
HamShield radio;
|
HamShield radio;
|
||||||
DDS dds;
|
DDS dds;
|
||||||
|
AFSK afsk;
|
||||||
String messagebuff = "";
|
String messagebuff = "";
|
||||||
String origin_call = "";
|
String origin_call = "";
|
||||||
String destination_call = "";
|
String destination_call = "";
|
||||||
|
@ -48,7 +51,7 @@ void setup() {
|
||||||
radio.frequency(144390);
|
radio.frequency(144390);
|
||||||
radio.setRfPower(0);
|
radio.setRfPower(0);
|
||||||
dds.start();
|
dds.start();
|
||||||
radio.afsk.start(&dds);
|
afsk.start(&dds);
|
||||||
delay(100);
|
delay(100);
|
||||||
Serial.println("HELLO");
|
Serial.println("HELLO");
|
||||||
}
|
}
|
||||||
|
@ -78,13 +81,13 @@ void prepMessage() {
|
||||||
packet->print(textmessage);
|
packet->print(textmessage);
|
||||||
packet->finish();
|
packet->finish();
|
||||||
|
|
||||||
bool ret = radio.afsk.putTXPacket(packet);
|
bool ret = afsk.putTXPacket(packet);
|
||||||
|
|
||||||
if(radio.afsk.txReady()) {
|
if(afsk.txReady()) {
|
||||||
Serial.println(F("txReady"));
|
Serial.println(F("txReady"));
|
||||||
radio.setModeTransmit();
|
radio.setModeTransmit();
|
||||||
//delay(100);
|
//delay(100);
|
||||||
if(radio.afsk.txStart()) {
|
if(afsk.txStart()) {
|
||||||
Serial.println(F("txStart"));
|
Serial.println(F("txStart"));
|
||||||
} else {
|
} else {
|
||||||
radio.setModeReceive();
|
radio.setModeReceive();
|
||||||
|
@ -95,7 +98,7 @@ void prepMessage() {
|
||||||
// Wait up to 2.5 seconds to finish sending, and stop transmitter.
|
// Wait up to 2.5 seconds to finish sending, and stop transmitter.
|
||||||
// TODO: This is hackery.
|
// TODO: This is hackery.
|
||||||
for(int i = 0; i < 500; i++) {
|
for(int i = 0; i < 500; i++) {
|
||||||
if(radio.afsk.encoder.isDone())
|
if(afsk.encoder.isDone())
|
||||||
break;
|
break;
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
@ -117,8 +120,8 @@ ISR(ADC_vect) {
|
||||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
TIFR1 = _BV(ICF1); // Clear the timer flag
|
||||||
dds.clockTick();
|
dds.clockTick();
|
||||||
if(++tcnt == 1) {
|
if(++tcnt == 1) {
|
||||||
if(radio.afsk.encoder.isSending()) {
|
if(afsk.encoder.isSending()) {
|
||||||
radio.afsk.timer();
|
afsk.timer();
|
||||||
}
|
}
|
||||||
tcnt = 0;
|
tcnt = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#define DDS_REFCLK_DEFAULT 9600
|
#define DDS_REFCLK_DEFAULT 9600
|
||||||
|
|
||||||
#include <HamShield.h>
|
#include <HamShield.h>
|
||||||
|
#include <DDS.h>
|
||||||
|
#include <AFSK.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
#define PWM_PIN 3
|
#define PWM_PIN 3
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
|
|
||||||
HamShield radio;
|
HamShield radio;
|
||||||
DDS dds;
|
DDS dds;
|
||||||
|
AFSK afsk;
|
||||||
String messagebuff = "";
|
String messagebuff = "";
|
||||||
String origin_call = "";
|
String origin_call = "";
|
||||||
String destination_call = "";
|
String destination_call = "";
|
||||||
|
@ -49,7 +52,7 @@ void setup() {
|
||||||
radio.frequency(145570);
|
radio.frequency(145570);
|
||||||
radio.setRfPower(0);
|
radio.setRfPower(0);
|
||||||
dds.start();
|
dds.start();
|
||||||
radio.afsk.start(&dds);
|
afsk.start(&dds);
|
||||||
delay(100);
|
delay(100);
|
||||||
Serial.println("HELLO");
|
Serial.println("HELLO");
|
||||||
}
|
}
|
||||||
|
@ -91,13 +94,13 @@ void prepMessage() {
|
||||||
|
|
||||||
textmessage = "";
|
textmessage = "";
|
||||||
|
|
||||||
bool ret = radio.afsk.putTXPacket(packet);
|
bool ret = afsk.putTXPacket(packet);
|
||||||
|
|
||||||
if(radio.afsk.txReady()) {
|
if(afsk.txReady()) {
|
||||||
Serial.println(F("txReady"));
|
Serial.println(F("txReady"));
|
||||||
//radio.setModeTransmit();
|
//radio.setModeTransmit();
|
||||||
//delay(100);
|
//delay(100);
|
||||||
if(radio.afsk.txStart()) {
|
if(afsk.txStart()) {
|
||||||
Serial.println(F("txStart"));
|
Serial.println(F("txStart"));
|
||||||
} else {
|
} else {
|
||||||
radio.setModeReceive();
|
radio.setModeReceive();
|
||||||
|
@ -108,7 +111,7 @@ void prepMessage() {
|
||||||
// Wait up to 2.5 seconds to finish sending, and stop transmitter.
|
// Wait up to 2.5 seconds to finish sending, and stop transmitter.
|
||||||
// TODO: This is hackery.
|
// TODO: This is hackery.
|
||||||
for(int i = 0; i < 500; i++) {
|
for(int i = 0; i < 500; i++) {
|
||||||
if(radio.afsk.encoder.isDone())
|
if(afsk.encoder.isDone())
|
||||||
break;
|
break;
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
@ -136,8 +139,8 @@ ISR(ADC_vect) {
|
||||||
//PORTD |= _BV(2); // Diagnostic pin (D2)
|
//PORTD |= _BV(2); // Diagnostic pin (D2)
|
||||||
dds.clockTick();
|
dds.clockTick();
|
||||||
if(++tcnt == 1) {
|
if(++tcnt == 1) {
|
||||||
if(radio.afsk.encoder.isSending()) {
|
if(afsk.encoder.isSending()) {
|
||||||
radio.afsk.timer();
|
afsk.timer();
|
||||||
}
|
}
|
||||||
tcnt = 0;
|
tcnt = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <HamShield.h>
|
#include <HamShield.h>
|
||||||
|
#include <DDS.h>
|
||||||
|
#include <AFSK.h>
|
||||||
|
|
||||||
#define PWM_PIN 3
|
#define PWM_PIN 3
|
||||||
#define RESET_PIN A3
|
#define RESET_PIN A3
|
||||||
|
@ -20,6 +22,7 @@
|
||||||
|
|
||||||
HamShield radio;
|
HamShield radio;
|
||||||
DDS dds;
|
DDS dds;
|
||||||
|
AFSK afsk;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// NOTE: if not using PWM out, it should be held low to avoid tx noise
|
// NOTE: if not using PWM out, it should be held low to avoid tx noise
|
||||||
|
@ -55,7 +58,7 @@ void setup() {
|
||||||
dds.start();
|
dds.start();
|
||||||
Serial.println(F("AFSK start"));
|
Serial.println(F("AFSK start"));
|
||||||
delay(100);
|
delay(100);
|
||||||
radio.afsk.start(&dds);
|
afsk.start(&dds);
|
||||||
Serial.println(F("Starting..."));
|
Serial.println(F("Starting..."));
|
||||||
delay(100);
|
delay(100);
|
||||||
dds.setAmplitude(255);
|
dds.setAmplitude(255);
|
||||||
|
@ -63,11 +66,11 @@ void setup() {
|
||||||
|
|
||||||
uint32_t last = 0;
|
uint32_t last = 0;
|
||||||
void loop() {
|
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
|
// A true return means something was put onto the packet FIFO
|
||||||
// If we actually have data packets in the buffer, process them all now
|
// If we actually have data packets in the buffer, process them all now
|
||||||
while(radio.afsk.rxPacketCount()) {
|
while(afsk.rxPacketCount()) {
|
||||||
AFSK::Packet *packet = radio.afsk.getRXPacket();
|
AFSK::Packet *packet = afsk.getRXPacket();
|
||||||
Serial.print(F("Packet: "));
|
Serial.print(F("Packet: "));
|
||||||
if(packet) {
|
if(packet) {
|
||||||
packet->printPacket(&Serial);
|
packet->printPacket(&Serial);
|
||||||
|
@ -83,6 +86,6 @@ ISR(ADC_vect) {
|
||||||
TIFR1 = _BV(ICF1); // Clear the timer flag
|
TIFR1 = _BV(ICF1); // Clear the timer flag
|
||||||
//PORTD |= _BV(2); // Diagnostic pin (D2)
|
//PORTD |= _BV(2); // Diagnostic pin (D2)
|
||||||
//dds.clockTick();
|
//dds.clockTick();
|
||||||
radio.afsk.timer();
|
afsk.timer();
|
||||||
//PORTD &= ~(_BV(2)); // Pin D2 off again
|
//PORTD &= ~(_BV(2)); // Pin D2 off again
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
|
|
||||||
#include <HamShield.h>
|
#include <HamShield.h>
|
||||||
#include <KISS.h>
|
#include <KISS.h>
|
||||||
|
#include <AFSK.h>
|
||||||
|
|
||||||
HamShield radio;
|
HamShield radio;
|
||||||
DDS dds;
|
DDS dds;
|
||||||
KISS kiss(&Serial, &radio, &dds);
|
KISS kiss(&Serial, &radio, &dds);
|
||||||
|
AFSK afsk;
|
||||||
|
|
||||||
//TODO: move these into library
|
//TODO: move these into library
|
||||||
#define PWM_PIN 3
|
#define PWM_PIN 3
|
||||||
|
@ -46,7 +48,7 @@ void setup() {
|
||||||
//I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0x05FF);
|
//I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0x05FF);
|
||||||
|
|
||||||
dds.start();
|
dds.start();
|
||||||
radio.afsk.start(&dds);
|
afsk.start(&dds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
Loading…
Reference in New Issue