Update to separated libraries

This commit is contained in:
nick6x
2016-08-26 11:22:41 -07:00
27 changed files with 118 additions and 1796 deletions

View File

@@ -8,11 +8,15 @@
* this program to your adruino, open the Serial Monitor to
* monitor the process of the HamShield. Check for output on
* AFSK receiver.
*/
* Note: add message receive code
*/
#define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h>
#include <DDS.h>
#include <packet.h>
#include <avr/wdt.h>
#define PWM_PIN 3
@@ -21,6 +25,7 @@
HamShield radio;
DDS dds;
AFSK afsk;
String messagebuff = "";
String origin_call = "";
String destination_call = "";
@@ -46,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");
}
@@ -76,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();
@@ -93,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);
}
@@ -115,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;
}

View File

@@ -16,6 +16,8 @@
#define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h>
#include <DDS.h>
#include <packet.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;
}

View File

@@ -13,6 +13,8 @@
*/
#include <HamShield.h>
#include <DDS.h>
#include <packet.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
}

View File

@@ -15,6 +15,7 @@
#define DDS_DEBUG_SERIAL
#include <HamShield.h>
#include <DDS.h>
#define PWM_PIN 3
#define RESET_PIN A3
@@ -117,7 +118,7 @@ void loop() {
}
while(Serial.available()) {
char c = Serial.read();
Serial.print(c);
Serial.println(c);
switch(c) {
case 'h':
Serial.println(F("Commands:"));

View File

@@ -12,6 +12,7 @@
#define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h>
#include <DDS.h>
#define PWM_PIN 3
#define RESET_PIN A3

View File

@@ -44,7 +44,7 @@ void setup() {
void loop() {
radio.setModeReceive();
radio.setSQLoThresh(0);
radio.setSQOn();
radio.setSQOff();
radio.setVolume1(0xF);
radio.setVolume2(0xF);
delay(1000);

View File

@@ -24,13 +24,6 @@
HamShield radio;
void clr() {
/* Serial.write(27);
Serial.print("[2J"); // cursor to home command */
Serial.write(27);
Serial.print("[H"); // cursor to home command
}
void setup() {
// NOTE: if not using PWM out, it should be held low to avoid tx noise
pinMode(PWM_PIN, OUTPUT);
@@ -68,7 +61,6 @@ int txc = 0;
int mode = 0;
void loop() {
clr();
int16_t rssi = radio.readRSSI();
gauge = map(rssi,-123,-50,0,8);
Serial.print("[");

View File

@@ -12,7 +12,7 @@
* '6' => turn robot right
* '2' => move robot forward
* '5' => tell robot to send morse code identity
/*
*/
#include <ArduinoRobot.h> // include the robot library
#include <HamShield.h>

View File

@@ -39,7 +39,6 @@ void setup() {
Serial.println("Setting radio to its defaults..");
radio.initialize();
radio.setRfPower(0);
//radio.setChanMode(3);
}
void loop() {

View File

@@ -11,10 +11,12 @@
#include <HamShield.h>
#include <KISS.h>
#include <packet.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() {

View File

@@ -11,6 +11,7 @@
*/
#include <HamShield.h>
#include <DDS.h>
#include "varicode.h"
#define PWM_PIN 3

View File

@@ -8,7 +8,11 @@
* into the HamShield RF jack. Plug a pair of headphones into
* the HamShield. Connect the Arduino to wall power and then to
* your computer via USB. To test the output, tune you HT to
<<<<<<< HEAD
* 446MHz. The HamShield should make a recording of the next
=======
* 446MHz. The HamShield should make a recording ofthe next
>>>>>>> 8b8fd7a9a141e015aceecf604357ecf277df0c1f
* broadcast on that frequncy. The recording should then be
* repeated ten times by the HamShield.
*/
@@ -56,16 +60,16 @@ void loop() {
if(x == -1) {
for(x = 0; x < SIZE; x++) {
if(mode == 4) {
sample1 = analogRead(0);
sample1 = analogRead(2);
sound[x] = sample1 >> 4;
delayMicroseconds(RATE); x++;
sample1 = analogRead(0);
sample1 = analogRead(2);
sound[x] = (sample1 & 0xF0) | sound[x];
delayMicroseconds(RATE);
} else {
sound[x] = analogRead(0);
sound[x] = analogRead(2);
delayMicroseconds(RATE); x++;
sound[x] = analogRead(0);
sound[x] = analogRead(2);
delayMicroseconds(RATE);
}
}

View File

@@ -9,7 +9,9 @@
* wait to receive the message "Why hello there, friend.
* Nice to meet you. Welcome to QPSK63. 73, VE6SLP sk"
*/
#include <HamShield.h>
#include <DDS.h>
#include "varicode.h"
#define PWM_PIN 3

View File

@@ -14,6 +14,7 @@
#define DDS_REFCLK_DEFAULT (34965/2)
#include <HamShield.h>
#include <DDS.h>
#define PWM_PIN 3
#define RESET_PIN A3

View File

@@ -8,6 +8,12 @@
* to your computer via USB. After uploading this program to
* your adruino, open the Serial Monitor. Use the bar at the
* top of the serial monitor to enter commands as seen below.
*
* EXAMPLE: To change the repeater offset to 144.425MHz,
* enable offset, then key in, use the following commands:
* T144425;
* R1;
* [Just a space]
Commands:
@@ -90,14 +96,14 @@ void setup() {
digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600);
Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;");
Serial.println(";;;;;;;;;;;;;;;;;;;;;;;;;;");
int result = radio.testConnection();
Serial.print("*");
Serial.print(result,DEC);
Serial.print(";");
Serial.println(";");
radio.initialize(); // initializes automatically for UHF 12.5kHz channel
Serial.print("*START;");
Serial.println("*START;");
radio.frequency(freq);
radio.setVolume1(0xF);
radio.setVolume2(0xF);
@@ -127,14 +133,14 @@ void loop() {
if(repeater == 1) { radio.frequency(tx); }
radio.setModeTransmit();
state = 10;
Serial.print("#TX,ON;");
Serial.println("#TX,ON;");
timer = millis();
break;
case 63: // ? - RSSI
Serial.print(":");
Serial.print(radio.readRSSI(),DEC);
Serial.print(";");
Serial.println(";");
break;
case 65: // A - CTCSS In
@@ -155,7 +161,7 @@ void loop() {
case 70: // F - frequency
getValue();
freq = atol(cmdbuff);
if(radio.frequency(freq) == true) { Serial.print("@"); Serial.print(freq,DEC); Serial.print(";!;"); } else { Serial.print("X1;"); }
if(radio.frequency(freq) == true) { Serial.print("@"); Serial.print(freq,DEC); Serial.println(";!;"); } else { Serial.println("X1;"); }
break;
case 'M':
@@ -194,14 +200,14 @@ void loop() {
case 94: // ^ - VSSI (voice) level
Serial.print(":");
Serial.print(radio.readVSSI(),DEC);
Serial.print(";");
Serial.println(";");
}
break;
}
}
if(state == 10) {
if(millis() > (timer + 500)) { Serial.print("#TX,OFF;");radio.setModeReceive(); if(repeater == 1) { radio.frequency(freq); } state = 0; txcount = 0; }
if(millis() > (timer + 500)) { Serial.println("#TX,OFF;");radio.setModeReceive(); if(repeater == 1) { radio.frequency(freq); } state = 0; txcount = 0; }
}
}
@@ -212,7 +218,8 @@ void getValue() {
if(Serial.available()) {
temp = Serial.read();
if(temp == 59) { cmdbuff[p] = 0; Serial.print("@");
for(int x = 0; x < 32; x++) { Serial.print(cmdbuff[x]); }
for(int x = 0; x < 32; x++) { Serial.print(cmdbuff[x]);}
Serial.println();
return;
}
cmdbuff[p] = temp;
@@ -220,12 +227,12 @@ void getValue() {
if(p == 32) {
Serial.print("@");
for(int x = 0; x < 32; x++) {
Serial.print(cmdbuff[x]);
Serial.println(cmdbuff[x]);
}
cmdbuff[0] = 0;
Serial.print("X0;"); return; } // some sort of alignment issue? lets not feed junk into whatever takes this string in
Serial.println("X0;"); return; } // some sort of alignment issue? lets not feed junk into whatever takes this string in
}
}
}

View File

@@ -2,7 +2,9 @@
* Example: Signal Test
* Plays back the current signal strength level and morses out
* it's call sign at the end. You will need a HandyTalkie (HT)
* to test the output of this example.
* to test the output of this example. You will also need to
* download the PCM library from
* https://github.com/damellis/PCM
* Connect the HamShield to your Arduino. Screw the antenna
* into the HamShield RF jack. Plug a pair of headphones into
* the HamShield. Connect the Arduino to wall power and then
@@ -16,7 +18,7 @@
*/
#define DOT 100
#define CALLSIGN "1ZZ9ZZ/B"
char CALLSIGN[] = "1ZZ9ZZ/B";
/* Standard libraries and variable init */