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
|
||||
|
||||
#include <HamShield.h>
|
||||
#include <DDS.h>
|
||||
#include <AFSK.h>
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define DDS_REFCLK_DEFAULT 9600
|
||||
|
||||
#include <HamShield.h>
|
||||
#include <DDS.h>
|
||||
#include <AFSK.h>
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*/
|
||||
|
||||
#include <HamShield.h>
|
||||
#include <DDS.h>
|
||||
#include <AFSK.h>
|
||||
|
||||
#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
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
|
||||
#include <HamShield.h>
|
||||
#include <KISS.h>
|
||||
#include <AFSK.h>
|
||||
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue