Initial commit of HamShield library and example sketches. Probably not fully functional.
This commit is contained in:
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
||||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.window.create("window.html", {
|
||||
"bounds": {
|
||||
"width": 400,
|
||||
"height": 500
|
||||
}
|
||||
});
|
||||
});
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "",
|
||||
"description": "HAMShield",
|
||||
"version": "1.0.0",
|
||||
"app": {
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
chromeApp
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
body{}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Power
|
||||
</div>
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
|
||||
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.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
HAMShield radio;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("starting up..");
|
||||
Wire.begin();
|
||||
|
||||
pinMode(11, OUTPUT);
|
||||
|
||||
//testing
|
||||
//Wire.beginTransmission(42);
|
||||
//Wire.write('T');
|
||||
//Wire.write('e');
|
||||
//Wire.write('s');
|
||||
//Wire.write('t');
|
||||
//Wire.endTransmission();
|
||||
|
||||
|
||||
Serial.print("Radio status: ");
|
||||
int result = radio.testConnection();
|
||||
Serial.println(result,DEC);
|
||||
radio.initialize(); // setup radio
|
||||
radio.setFrequency(446000); // set to 70 cm call frequency
|
||||
Serial.println("Done with radio beacon setup.");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//while(1){}
|
||||
//if(radio.waitForChannel(30000,2000)) { // wait up to 30 seconds for a clear channel, and then 2 seconds of empty channel
|
||||
Serial.println("Signal is clear -- Transmitting");
|
||||
radio.setModeTransmit(); // turn on the transmitter
|
||||
radio.morseOut("1ZZ9ZZ/B CN87 ARDUINO HAMSHIELD");
|
||||
radio.setModeReceive(); // turn off the transmitter (receive mode)
|
||||
Serial.print("TX Off");
|
||||
//delay(30000);
|
||||
//} else { Serial.println("The channel was busy. Waiting 10 seconds."); delay(10000); }
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
|
||||
Executable
+283
@@ -0,0 +1,283 @@
|
||||
|
||||
// BlueHAM Proto01 Connection Guide
|
||||
/**********************
|
||||
**
|
||||
** BlueHAM Proto01 <--> Arduino
|
||||
** ADC_SCL A5
|
||||
** ADC_DIO A4
|
||||
** GND GND
|
||||
** PWM_RF_CTL D9
|
||||
**
|
||||
** Setting Connections
|
||||
** MODE -> GND
|
||||
** SENB -> GND
|
||||
** PDN -> 3.3V
|
||||
** AVDD -> 5V (note this should be a beefy supply, could draw up to 4As)
|
||||
**
|
||||
**
|
||||
**
|
||||
** Pinout information for RadioPeripheral01 Prototype board
|
||||
** GPIO0 -
|
||||
** GPIO1 -
|
||||
** GPIO2 - VHF_SEL
|
||||
** GPIO3 - UHF_SEL
|
||||
** GPIO4 - RX_EN
|
||||
** GPIO5 - TX_EN
|
||||
** GPIO6 -
|
||||
** GPIO7 -
|
||||
**************************/
|
||||
|
||||
// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
|
||||
// is used in I2Cdev.h
|
||||
#include "Wire.h"
|
||||
#include "HAMShield.h"
|
||||
|
||||
#include <Goertzel.h>
|
||||
|
||||
//typedef enum {
|
||||
#define MAIN_S 0
|
||||
#define RX_S 1
|
||||
#define TX_S 2
|
||||
#define FREQ_S 3
|
||||
#define UHF_S 4
|
||||
#define VHF_S 5
|
||||
#define PWR_S 6
|
||||
#define GPIO_S 7
|
||||
//} menu_view;
|
||||
|
||||
int state;
|
||||
|
||||
/* goertzel routines */
|
||||
|
||||
int sensorPin = A0;
|
||||
int led = 13;
|
||||
const float TARGET_FREQUENCY = 2200;
|
||||
const int N = 100;
|
||||
const float THRESHOLD = 4000;
|
||||
const float SAMPLING_FREQUENCY = 8900;
|
||||
Goertzel goertzel = Goertzel(TARGET_FREQUENCY, N, SAMPLING_FREQUENCY);
|
||||
|
||||
// create object for RDA
|
||||
HAMShield radio;
|
||||
|
||||
|
||||
#define LED_PIN 13
|
||||
bool blinkState = false;
|
||||
|
||||
void setup() {
|
||||
// initialize serial communication
|
||||
Serial.begin(115200);
|
||||
Serial.println("beginning radio setup");
|
||||
|
||||
// join I2C bus (I2Cdev library doesn't do this automatically)
|
||||
Wire.begin();
|
||||
|
||||
// verify connection
|
||||
Serial.println("Testing device connections...");
|
||||
Serial.println(radio.testConnection() ? "RDA radio connection successful" : "RDA radio connection failed");
|
||||
|
||||
// initialize device
|
||||
Serial.println("Initializing I2C devices...");
|
||||
radio.initialize(); // initializes automatically for UHF 12.5kHz channel
|
||||
|
||||
Serial.println("setting default Radio configuration");
|
||||
|
||||
|
||||
// set frequency
|
||||
Serial.println("changing frequency");
|
||||
|
||||
|
||||
radio.setFrequency(446000); // in kHz
|
||||
radio.setModeReceive();
|
||||
|
||||
// configure Arduino LED for
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
|
||||
state = MAIN_S;
|
||||
print_menu();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
goertzel.sample(sensorPin);
|
||||
float magnitude = goertzel.detect();
|
||||
if(magnitude>THRESHOLD) digitalWrite(led, HIGH); //if found, enable led
|
||||
else digitalWrite(led, LOW);
|
||||
while (Serial.available()) {
|
||||
if (state == FREQ_S) {
|
||||
char freq_khz[6];
|
||||
int i = 0;
|
||||
while(i < 6) {
|
||||
if (Serial.available()) {
|
||||
freq_khz[i] = Serial.read();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// interpret frequency
|
||||
uint32_t freq = 0;
|
||||
i = 0;
|
||||
while (i < 6) {
|
||||
uint32_t temp = freq_khz[i] - '0';
|
||||
for (int k = 5-i; k > 0; k--) {
|
||||
temp = temp * 10;
|
||||
}
|
||||
freq += temp;
|
||||
i++;
|
||||
}
|
||||
Serial.print("setting frequency to: ");
|
||||
Serial.println(freq);
|
||||
radio.setFrequency(freq);
|
||||
state = MAIN_S;
|
||||
|
||||
} else if (state == PWR_S) {
|
||||
uint8_t pwr_raw[3];
|
||||
int i = 0;
|
||||
while(i < 3) {
|
||||
if (Serial.available()) {
|
||||
pwr_raw[i] = Serial.read();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// interpret power
|
||||
uint8_t pwr = 0;
|
||||
i = 0;
|
||||
while (i < 3) {
|
||||
uint8_t temp = pwr_raw[i] - '0';
|
||||
for (int k = 2-i; k > 0; k--) {
|
||||
temp = temp * 10;
|
||||
}
|
||||
pwr += temp;
|
||||
i++;
|
||||
}
|
||||
|
||||
Serial.print("Setting power to: ");
|
||||
Serial.println(pwr);
|
||||
radio.setRfPower(pwr);
|
||||
state = MAIN_S;
|
||||
|
||||
} else if (state == GPIO_S) {
|
||||
uint8_t gpio_raw[2];
|
||||
int i = 0;
|
||||
while(i < 2) {
|
||||
if (Serial.available()) {
|
||||
gpio_raw[i] = Serial.read();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
uint16_t gpio_pin = gpio_raw[0] - 48; // '0';
|
||||
uint16_t gpio_mode = gpio_raw[1] - 48;
|
||||
|
||||
radio.setGpioMode(gpio_pin, gpio_mode);
|
||||
state = MAIN_S;
|
||||
|
||||
} else {
|
||||
char action = Serial.read();
|
||||
if (action == 'r') { // get current state
|
||||
state = RX_S;
|
||||
} else if (action == 't') {
|
||||
state = TX_S;
|
||||
} else if (action == 'f') {
|
||||
state = FREQ_S;
|
||||
} else if (action == 'u') {
|
||||
state = UHF_S;
|
||||
} else if (action == 'v') {
|
||||
state = VHF_S;
|
||||
} else if (action == '1') {
|
||||
turn_on(state);
|
||||
state = MAIN_S;
|
||||
} else if (action == '0') {
|
||||
turn_off(state);
|
||||
state = MAIN_S;
|
||||
} else if (action == 'p') {
|
||||
state = PWR_S;
|
||||
} else if (action == 'g') {
|
||||
state = GPIO_S;
|
||||
} else if (action == 's') {
|
||||
int16_t rssi = radio.readRSSI();
|
||||
Serial.print("rssi: ");
|
||||
Serial.println(rssi);
|
||||
} else if (action == 'i') {
|
||||
int16_t vssi = radio.readVSSI();
|
||||
Serial.print("vssi: ");
|
||||
Serial.println(vssi);
|
||||
}
|
||||
|
||||
Serial.println(action);
|
||||
}
|
||||
Serial.flush();
|
||||
print_menu();
|
||||
}
|
||||
}
|
||||
|
||||
void turn_off(int dev) {
|
||||
switch (dev) {
|
||||
case RX_S:
|
||||
radio.setRX(0);
|
||||
break;
|
||||
case TX_S:
|
||||
radio.setTX(0);
|
||||
break;
|
||||
case UHF_S:
|
||||
radio.setGpioMode(3, 3); // set GPIO3 high (uhf is active low)
|
||||
break;
|
||||
case VHF_S:
|
||||
radio.setGpioMode(2, 3); // set GPIO2 high (vhf is active low)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void turn_on(int dev) {
|
||||
switch (dev) {
|
||||
case RX_S:
|
||||
radio.setRX(1);
|
||||
break;
|
||||
case TX_S:
|
||||
radio.setTX(1);
|
||||
break;
|
||||
case UHF_S:
|
||||
radio.setGpioMode(3, 2); // set GPIO3 low (uhf is active low)
|
||||
break;
|
||||
case VHF_S:
|
||||
radio.setGpioMode(2, 2); // set GPIO2 low (uhf is active low)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void print_menu() {
|
||||
Serial.println("MENU");
|
||||
switch (state) {
|
||||
case MAIN_S:
|
||||
Serial.println("select step: [r]x, [t]x, [f]req, [u]hf, [v]hf, [p]wr, [g]pio control, r[s]si, vss[i] ...");
|
||||
break;
|
||||
case RX_S:
|
||||
Serial.println("enter 1 to turn on rx, 0 to turn off rx");
|
||||
break;
|
||||
case TX_S:
|
||||
Serial.println("enter 1 to turn on tx, 0 to turn off tx");
|
||||
break;
|
||||
case FREQ_S:
|
||||
Serial.println("enter frequency in kHz (ffffff)");
|
||||
break;
|
||||
case UHF_S:
|
||||
Serial.println("enter 1 to turn on uhf, 0 to turn off uhf");
|
||||
break;
|
||||
case VHF_S:
|
||||
Serial.println("enter 1 to turn on vhf, 0 to turn off vhf");
|
||||
break;
|
||||
case PWR_S:
|
||||
Serial.println("enter power (raw) (ppp)");
|
||||
break;
|
||||
case GPIO_S:
|
||||
Serial.println("enter GPIO pin and control (no spaces, eg pin 1 mode 3 is 13");
|
||||
Serial.println("modes 0 - HiZ, 1 - FCN, 2 - Low, 3 - Hi");
|
||||
break;
|
||||
default:
|
||||
state = MAIN_S;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/* Fox Hunt */
|
||||
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// transmit for 1 minute, every 10 minutes
|
||||
|
||||
#define TRANSMITLENGTH 1
|
||||
#define INTERVAL 10
|
||||
#define RANDOMCHANCE 3
|
||||
|
||||
HAMShield radio;
|
||||
|
||||
void setup() {
|
||||
Wire.begin();
|
||||
radio.initialize();
|
||||
radio.setFrequency(145510);
|
||||
radio.setModeReceive();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
waitMinute(INTERVAL + random(0,RANDOMCHANCE)); // wait before transmitting, randomly up to 3 minutes later
|
||||
if(radio.waitForChannel(30000,2000)) { // 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
|
||||
radio.morseOut("1ZZ9ZZ/B FOXHUNT"); // identify the fox hunt transmitter
|
||||
radio.setModeReceive(); // turn off the transmit mode
|
||||
}
|
||||
}
|
||||
|
||||
// a function so we can wait by minutes
|
||||
|
||||
void waitMinute(int period) {
|
||||
delay(period * 60 * 1000);
|
||||
}
|
||||
|
||||
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
|
||||
Gauges
|
||||
|
||||
Simple gauges for the radio receiver.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
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() {
|
||||
analogReference(DEFAULT);
|
||||
Serial.begin(115200);
|
||||
Wire.begin();
|
||||
Serial.print("Radio status: ");
|
||||
int result = radio.testConnection();
|
||||
Serial.println(result,DEC);
|
||||
radio.initialize();
|
||||
radio.setFrequency(446000);
|
||||
Serial.println("Entering gauges...");
|
||||
tone(9,1000);
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
int gauge;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int peak = 0;
|
||||
int a = 0;
|
||||
int mini = 0;
|
||||
int vpeak = 0;
|
||||
int txc = 0;
|
||||
int mode = 0;
|
||||
|
||||
void loop() {
|
||||
clr();
|
||||
int16_t rssi = radio.readRSSI();
|
||||
gauge = map(rssi,-123,-50,0,8);
|
||||
Serial.print("[");
|
||||
for(x = 0; x < gauge; x++) {
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.print("|");
|
||||
for(y = x; y < 8; y++) {
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.print("] ");
|
||||
Serial.print(rssi);
|
||||
Serial.println(" ");
|
||||
Serial.println("Signal \n");
|
||||
|
||||
// radio.setModeTransmit();
|
||||
int16_t vssi = radio.readVSSI();
|
||||
// radio.setModeReceive();
|
||||
if(vssi > vpeak) { vpeak = vssi; }
|
||||
gauge = map(vssi,-50,-150,0,8);
|
||||
Serial.print("[");
|
||||
for(x = 0; x < gauge; x++) {
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.print("|");
|
||||
for(y = x; y < 8; y++) {
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.print("] ");
|
||||
Serial.print(vpeak);
|
||||
Serial.println(" ");
|
||||
Serial.println("Audio In\n");
|
||||
|
||||
a = analogRead(0);
|
||||
if(a > peak) { peak = a; }
|
||||
if(a < mini) { mini = a; }
|
||||
gauge = map(a,400,1023,0,8);
|
||||
Serial.print("[");
|
||||
for(x = 0; x < gauge; x++) {
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.print("|");
|
||||
for(y = x; y < 8; y++) {
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.print("] ");
|
||||
Serial.print(a,DEC);
|
||||
Serial.print(" ("); Serial.print(peak,DEC); Serial.println(") ");
|
||||
Serial.println("Audio RX ADC Peak\n");
|
||||
}
|
||||
|
||||
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
/* Simple DTMF controlled HAM Radio Robot */
|
||||
|
||||
#include <ArduinoRobot.h> // include the robot library
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
|
||||
HAMShield radio;
|
||||
|
||||
void setup() {
|
||||
Robot.begin();
|
||||
Wire.begin();
|
||||
radio.initialize();
|
||||
radio.setFrequency(145510);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(radio.waitForDTMF()) { // wait for a received DTMF tone
|
||||
uint8_t command = radio.getLastDTMFDigit(); // get the last DTMF tone sent
|
||||
if(command == '4') { Robot.turn(-90); } // turn robot left
|
||||
if(command == '6') { Robot.turn(90); } // turn robot right
|
||||
if(command == '2') { Robot.motorsWrite(-255,-255); delay(500); Robot.motorsWrite(255, 255); } // move robot forward
|
||||
if(command == '5') { // tell robot to send morse code identity
|
||||
if(radio.waitForChannel()) { // wait for the user to release the transmit button
|
||||
radio.setModeTransmit(); // turn on transmit mode
|
||||
radio.morseOut("1ZZ9ZZ I AM HAMRADIO ROBOT"); // send morse code
|
||||
radio.setModeReceive(); // go back to receive mode on radio
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
|
||||
Indentifier
|
||||
|
||||
Arduino audio overlay example
|
||||
|
||||
*/
|
||||
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#define DOT 100
|
||||
|
||||
HAMShield radio;
|
||||
|
||||
const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@",
|
||||
*bitu[] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----.",".-.-.-","--..--","..--..",".----.","-.-.--","-..-.","-.--.","-.--.-",".-...","---...","-.-.-.","-...-",".-.-.","-....-","..--.-",".-..-.","...-..-",".--.-."
|
||||
};
|
||||
|
||||
const char *callsign = {"1ZZ9ZZ/B"} ;
|
||||
|
||||
char morsebuffer[8];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("starting up..");
|
||||
Wire.begin();
|
||||
Serial.print("Radio status: ");
|
||||
int result = radio.testConnection();
|
||||
Serial.println(result,DEC);
|
||||
radio.initialize();
|
||||
radio.setFrequency(446000);
|
||||
radio.setVolume1(0xF);
|
||||
radio.setVolume2(0xF);
|
||||
radio.setModeReceive();
|
||||
radio.setTxSourceMic();
|
||||
radio.setSQLoThresh(80);
|
||||
radio.setSQOn();
|
||||
Serial.println("Done with radio beacon setup. Press and hold a key to transmit.");
|
||||
}
|
||||
|
||||
int state = 0;
|
||||
long timer = 0;
|
||||
int morseletter = 0;
|
||||
int morsesymbol = 0;
|
||||
long keyer = 0;
|
||||
char symbol;
|
||||
|
||||
void loop() {
|
||||
if(Serial.available() > 0) {
|
||||
if(state == 0) {
|
||||
state = 10;
|
||||
radio.setModeTransmit();
|
||||
timer = millis();
|
||||
keyer = millis();
|
||||
}
|
||||
if(state == 10) {
|
||||
timer = millis();
|
||||
}
|
||||
}
|
||||
if(millis() > (timer + 500)) { radio.setModeReceive(); morseletter = 0; morsesymbol = 0; state = 0; }
|
||||
if(state == 10) {
|
||||
if(millis() > (keyer + (DOT * 3))) {
|
||||
keyer = millis();
|
||||
symbol = lookup(callsign[morseletter],morsesymbol);
|
||||
if(symbol == '-') { tone(9,1000,DOT*3); }
|
||||
if(symbol == '.') { tone(9,1000,DOT); }
|
||||
if(symbol == 0) { morsesymbol = 0; morseletter++; }
|
||||
if(callsign[morseletter] == 0) { morsesymbol = 0; morseletter = 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char lookup(char letter, int morsesymbol) {
|
||||
for(int x = 0; x < 54; x++) {
|
||||
if(letter == bascii[x]) {
|
||||
return bitu[x][morsesymbol];
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
|
||||
Record sound and then plays it back a few times.
|
||||
Very low sound quality @ 2KHz 0.75 seconds
|
||||
A bit robotic and weird
|
||||
|
||||
*/
|
||||
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#define RATE 500
|
||||
#define SIZE 1500
|
||||
|
||||
HAMShield radio;
|
||||
|
||||
char sound[SIZE];
|
||||
unsigned int sample1;
|
||||
int x = -1;
|
||||
int16_t rssi;
|
||||
byte mode = 8;
|
||||
|
||||
void setup() {
|
||||
Wire.begin();
|
||||
// int result = radio.testConnection();
|
||||
radio.initialize();
|
||||
radio.setFrequency(446000);
|
||||
setPwmFrequency(9, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
rssi = radio.readRSSI();
|
||||
if(rssi > -100) {
|
||||
if(x == -1) {
|
||||
for(x = 0; x < SIZE; x++) {
|
||||
if(mode == 4) {
|
||||
sample1 = analogRead(0);
|
||||
sound[x] = sample1 >> 4;
|
||||
delayMicroseconds(RATE); x++;
|
||||
sample1 = analogRead(0);
|
||||
sound[x] = (sample1 & 0xF0) | sound[x];
|
||||
delayMicroseconds(RATE);
|
||||
} else {
|
||||
sound[x] = analogRead(0);
|
||||
delayMicroseconds(RATE); x++;
|
||||
sound[x] = analogRead(0);
|
||||
delayMicroseconds(RATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rssi < -100) {
|
||||
if(x == 1500) {
|
||||
radio.setModeTransmit();
|
||||
delay(500);
|
||||
tone(9,1000,500); delay(750);
|
||||
for(int r = 0; r < 10; r++) {
|
||||
for(x = 0; x < SIZE; x++) {
|
||||
if(mode == 4) {
|
||||
|
||||
analogWrite(9,sound[x] << 4);
|
||||
delayMicroseconds(RATE); x++;
|
||||
analogWrite(9,sound[x] & 0xF);
|
||||
delayMicroseconds(RATE); } else {
|
||||
|
||||
analogWrite(9,sound[x]);
|
||||
delayMicroseconds(RATE); x++;
|
||||
analogWrite(9,sound[x]);
|
||||
delayMicroseconds(RATE);
|
||||
}
|
||||
} }
|
||||
tone(9,1000,500); delay(750);
|
||||
radio.setModeReceive();
|
||||
x = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setPwmFrequency(int pin, int divisor) {
|
||||
byte mode;
|
||||
if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {
|
||||
switch(divisor) {
|
||||
case 1: mode = 0x01; break;
|
||||
case 8: mode = 0x02; break;
|
||||
case 64: mode = 0x03; break;
|
||||
case 256: mode = 0x04; break;
|
||||
case 1024: mode = 0x05; break;
|
||||
default: return;
|
||||
}
|
||||
if(pin == 5 || pin == 6) {
|
||||
TCCR0B = TCCR0B & 0b11111000 | mode;
|
||||
} else {
|
||||
TCCR1B = TCCR1B & 0b11111000 | mode;
|
||||
}
|
||||
} else if(pin == 3 || pin == 11) {
|
||||
switch(divisor) {
|
||||
case 1: mode = 0x01; break;
|
||||
case 8: mode = 0x02; break;
|
||||
case 32: mode = 0x03; break;
|
||||
case 64: mode = 0x04; break;
|
||||
case 128: mode = 0x05; break;
|
||||
case 256: mode = 0x06; break;
|
||||
case 1024: mode = 0x7; break;
|
||||
default: return;
|
||||
}
|
||||
TCCR2B = TCCR2B & 0b11111000 | mode;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
|
||||
Sends an SSTV test pattern
|
||||
|
||||
*/
|
||||
|
||||
#define DOT 100
|
||||
#define CALLSIGN "1ZZ9ZZ/B"
|
||||
|
||||
/* Standard libraries and variable init */
|
||||
|
||||
#include <HAMShield.h>
|
||||
#include <Wire.h>
|
||||
|
||||
HAMShield radio;
|
||||
int16_t rssi;
|
||||
|
||||
/* get our radio ready */
|
||||
|
||||
void setup() {
|
||||
Wire.begin();
|
||||
Serial.begin(9600);
|
||||
Serial.print("Radio status: ");
|
||||
int result = radio.testConnection();
|
||||
Serial.println(result);
|
||||
radio.initialize();
|
||||
radio.setFrequency(446000);
|
||||
radio.setModeReceive();
|
||||
}
|
||||
|
||||
/* main program loop */
|
||||
|
||||
|
||||
void loop() {
|
||||
if(radio.waitForChannel(1000,2000)) { // Wait forever for calling frequency to open, then wait 2 seconds for breakers
|
||||
radio.setModeTransmit(); // Turn on the transmitter
|
||||
delay(250); // Wait a moment
|
||||
radio.SSTVTestPattern(MARTIN1); // send a MARTIN1 test pattern
|
||||
delay(250);
|
||||
radio.setModeReceive(); // Turn off the transmitter
|
||||
} else { delay(30000); } // someone broke in fast after prior transmission, was it an emergency? wait 30 secs.
|
||||
|
||||
delay(60000); // Wait a minute
|
||||
}
|
||||
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
|
||||
SerialTransceiver is TTL Serial port "glue" to allow desktop or laptop control of the HAMShield
|
||||
|
||||
Commands:
|
||||
|
||||
Mode ASCII Description Implemented
|
||||
-------------- ----------- -------------------------------------------------------------------------------------------------------------------------------------------- -----------------
|
||||
Transmit space Space must be received at least every 500 mS Yes
|
||||
Receive not space If space is not received and/or 500 mS timeout of space occurs, unit will go into receive mode Yes
|
||||
CTCSS In A<tone>; <tone> must be a numerical ascii value with decimal point indicating CTCSS receive tone required to unsquelch No
|
||||
CTCSS Out B<tone>; <tone> must be a numerical ascii value with decimal point indicating CTCSS transmit tone No
|
||||
CTCSS Enable C<state>; Turns on CTCSS mode (analog tone) with 1, off with 0. No
|
||||
CDCSS Enable D<state>; Turns on CDCSS mode (digital tone) with 1, off with 0. No
|
||||
Bandwidth E<mode>; for 12.5KHz mode is 0, for 25KHz, mode is 1 No
|
||||
Frequency F<freq>; Set the receive frequency in KHz, if offset is disabled, this is the transmit frequency No
|
||||
CDCSS In G<code>; <code> must be a valid CDCSS code No
|
||||
CDCSS Out H<code>; <code> must be a valid CDCSS code No
|
||||
Print tones I Prints out all configured tones and codes, coma delimited in format: CTCSS In, CTCSS Out, CDCSS In, CDCSS Out No
|
||||
Power level P<level>; Set the power amp level, 0 = lowest, 255 = highest No
|
||||
Enable Offset R<state>; 1 turns on repeater offset mode, 0 turns off repeater offset mode No
|
||||
Squelch S<level>; Set the squelch level No
|
||||
TX Offset T<freq>; The absolute frequency of the repeater offset to transmit on in KHz No
|
||||
Volume V<level>; Set the volume level of the receiver No
|
||||
Reset X Reset all settings to default No
|
||||
Sleep Z Sleep radio No
|
||||
Filters @<state>; Set bit to enable, clear bit to disable: 0 = pre/de-emphasis, 1 = high pass filter, 2 = low pass filter (default: ascii 7, all enabled) No
|
||||
Vox mode $<state>; 0 = vox off, >= 1 audio sensitivity. lower value more sensitive No
|
||||
Mic Channel *<state>; Set the voice channel. 0 = signal from mic or arduino, 1 = internal tone generator No
|
||||
RSSI ? Respond with the current receive level in - dBm (no sign provided on numerical response) No
|
||||
Tone Gen % (notes) To send a tone, use the following format: Single tone: %1,<freq>,<length>; Dual tone: %2,<freq>,<freq>,<length>; DTMF: %3,<key>,<length>; No
|
||||
Voice Level ^ Respond with the current voice level (VSSI)
|
||||
|
||||
|
||||
Responses:
|
||||
|
||||
Condition ASCII Description
|
||||
------------ ---------- -----------------------------------------------------------------
|
||||
Startup *<code>; Startup and shield connection status
|
||||
Success !; Generic success message for command that returns no value
|
||||
Error X<code>; Indicates an error code. The numerical value is the type of error
|
||||
Value :<value>; In response to a query
|
||||
Status #<value>; Unsolicited status message
|
||||
Debug Msg @<text>; 32 character debug message
|
||||
|
||||
*/
|
||||
|
||||
#include "Wire.h"
|
||||
#include "HAMShield.h"
|
||||
|
||||
int state;
|
||||
int txcount = 0;
|
||||
long timer = 0;
|
||||
long freq = 144390;
|
||||
long tx = 0;
|
||||
char cmdbuff[32] = "";
|
||||
int temp = 0;
|
||||
int repeater = 0;
|
||||
float ctcssin = 0;
|
||||
float ctcssout = 0;
|
||||
int cdcssin = 0;
|
||||
int cdcssout = 0;
|
||||
|
||||
|
||||
HAMShield radio;
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;");
|
||||
Wire.begin();
|
||||
int result = radio.testConnection();
|
||||
Serial.print("*");
|
||||
Serial.print(result,DEC);
|
||||
Serial.print(";");
|
||||
radio.initialize(); // initializes automatically for UHF 12.5kHz channel
|
||||
Serial.print("*START;");
|
||||
radio.frequency(freq);
|
||||
radio.setVolume1(0xF);
|
||||
radio.setVolume2(0xF);
|
||||
radio.setModeReceive();
|
||||
radio.setTxSourceMic();
|
||||
radio.setRfPower(255); // 30 is 0.5V, which corresponds to 29 dBm out (see RF6886 datasheet)
|
||||
radio.setSQLoThresh(80);
|
||||
radio.setSQOn();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if(Serial.available()) {
|
||||
|
||||
int text = Serial.read();
|
||||
|
||||
switch (state) {
|
||||
|
||||
case 10:
|
||||
if(text == 32) { timer = millis();}
|
||||
break;
|
||||
|
||||
case 0:
|
||||
switch(text) {
|
||||
|
||||
case 32: // space - transmit
|
||||
if(repeater == 1) { radio.frequency(tx); }
|
||||
radio.setRX(0);
|
||||
radio.setTX(1);
|
||||
state = 10;
|
||||
Serial.print("#TX,ON;");
|
||||
timer = millis();
|
||||
break;
|
||||
|
||||
case 63: // ? - RSSI
|
||||
Serial.print(":");
|
||||
Serial.print(radio.readRSSI(),DEC);
|
||||
Serial.print(";");
|
||||
break;
|
||||
|
||||
case 65: // A - CTCSS In
|
||||
getValue();
|
||||
ctcssin = atof(cmdbuff);
|
||||
radio.setCtcss(ctcssin);
|
||||
break;
|
||||
|
||||
case 66: // B - CTCSS Out
|
||||
break;
|
||||
|
||||
case 67: // C - CTCSS Enable
|
||||
break;
|
||||
|
||||
case 68: // D - CDCSS Enable
|
||||
break;
|
||||
|
||||
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;"); }
|
||||
break;
|
||||
|
||||
case 80: // P - power level
|
||||
getValue();
|
||||
temp = atol(cmdbuff);
|
||||
radio.setRfPower(temp);
|
||||
break;
|
||||
|
||||
case 82: // R - repeater offset mode
|
||||
getValue();
|
||||
temp = atol(cmdbuff);
|
||||
if(temp == 0) { repeater = 0; }
|
||||
if(temp == 1) { repeater = 1; }
|
||||
break;
|
||||
|
||||
case 83: // S - squelch
|
||||
getValue();
|
||||
temp = atol(cmdbuff);
|
||||
radio.setSQLoThresh(temp);
|
||||
break;
|
||||
|
||||
case 84: // T - transmit offset
|
||||
getValue();
|
||||
tx = atol(cmdbuff);
|
||||
break;
|
||||
|
||||
|
||||
case 94: // ^ - VSSI (voice) level
|
||||
Serial.print(":");
|
||||
Serial.print(radio.readVSSI(),DEC);
|
||||
Serial.print(";");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if(state == 10) {
|
||||
if(millis() > (timer + 500)) { Serial.print("#TX,OFF;");radio.setRX(1); radio.setTX(0); if(repeater == 1) { radio.frequency(freq); } state = 0; txcount = 0; }
|
||||
}
|
||||
}
|
||||
|
||||
void getValue() {
|
||||
int p = 0;
|
||||
char temp;
|
||||
for(;;) {
|
||||
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]); }
|
||||
return;
|
||||
}
|
||||
cmdbuff[p] = temp;
|
||||
p++;
|
||||
if(p == 32) {
|
||||
Serial.print("@");
|
||||
for(int x = 0; x < 32; x++) {
|
||||
Serial.print(cmdbuff[x]);
|
||||
}
|
||||
|
||||
cmdbuff[0] = 0;
|
||||
|
||||
Serial.print("X0;"); return; } // some sort of alignment issue? lets not feed junk into whatever takes this string in
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+140
File diff suppressed because one or more lines are too long
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user