updating all examples for new library

This commit is contained in:
morgan 2016-04-13 19:12:06 -07:00
parent 3a209d8db4
commit 5f363f1537
22 changed files with 31 additions and 66 deletions

View File

@ -142,6 +142,11 @@ void HamShield::initialize() {
uint16_t tx_data; uint16_t tx_data;
pinMode(A1, OUTPUT);
digitalWrite(A1, HIGH);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
// reset all registers in A1846S // reset all registers in A1846S
softReset(); softReset();
@ -990,7 +995,7 @@ bool HamShield::getPreDeEmphEnabled(){
int16_t HamShield::readRSSI(){ int16_t HamShield::readRSSI(){
HSreadBitsW(devAddr, A1846S_RSSI_REG, A1846S_RSSI_BIT, A1846S_RSSI_LENGTH, radio_i2c_buf); HSreadBitsW(devAddr, A1846S_RSSI_REG, A1846S_RSSI_BIT, A1846S_RSSI_LENGTH, radio_i2c_buf);
int16_t rssi = (radio_i2c_buf[0] & 0x3FF) - 137; int16_t rssi = (radio_i2c_buf[0] & 0xFF); // - 137;
return rssi; return rssi;
} }
uint16_t HamShield::readVSSI(){ uint16_t HamShield::readVSSI(){

View File

@ -188,7 +188,7 @@
#define A1846S_VOX_FLAG_BIT 0 // vox out from dsp #define A1846S_VOX_FLAG_BIT 0 // vox out from dsp
// Bitfields for A1846S_RSSI_REG // Bitfields for A1846S_RSSI_REG
#define A1846S_RSSI_BIT 15 // RSSI readings <9:0> #define A1846S_RSSI_BIT 15 // RSSI readings <7:0>
#define A1846S_RSSI_LENGTH 8 #define A1846S_RSSI_LENGTH 8
// Bitfields for A1846S_VSSI_REG // Bitfields for A1846S_VSSI_REG

View File

@ -8,10 +8,8 @@
#define DDS_REFCLK_DEFAULT 9600 #define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#include <avr/wdt.h> #include <avr/wdt.h>
//TODO: move these into library
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
#define SWITCH_PIN 2 #define SWITCH_PIN 2
@ -39,8 +37,6 @@ void setup() {
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Serial.begin(115200); Serial.begin(115200);
Wire.begin();
radio.initialize(); radio.initialize();
radio.frequency(144390); radio.frequency(144390);

View File

@ -8,7 +8,6 @@
#define DDS_REFCLK_DEFAULT 9600 #define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#include <avr/wdt.h> #include <avr/wdt.h>
#define PWM_PIN 3 #define PWM_PIN 3
@ -37,7 +36,7 @@ void setup() {
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Serial.begin(115200); Serial.begin(115200);
Wire.begin();
radio.initialize(); radio.initialize();
radio.frequency(145570); radio.frequency(145570);
radio.setRfPower(0); radio.setRfPower(0);

View File

@ -1,5 +1,4 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
HamShield radio; HamShield radio;
DDS dds; DDS dds;
@ -13,7 +12,7 @@ DDS dds;
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
Wire.begin();
pinMode(4, OUTPUT); pinMode(4, OUTPUT);
pinMode(5, OUTPUT); pinMode(5, OUTPUT);
pinMode(6, OUTPUT); pinMode(6, OUTPUT);

View File

@ -1,5 +1,4 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -22,7 +21,7 @@ void setup() {
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Wire.begin();
Serial.println(F("Radio test connection")); Serial.println(F("Radio test connection"));
Serial.println(radio.testConnection(), DEC); Serial.println(radio.testConnection(), DEC);
Serial.println(F("Initialize")); Serial.println(F("Initialize"));

View File

@ -3,7 +3,6 @@
#define DDS_DEBUG_SERIAL #define DDS_DEBUG_SERIAL
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -26,7 +25,7 @@ void setup() {
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Wire.begin();
radio.initialize(); radio.initialize();
radio.setRfPower(0); radio.setRfPower(0);
radio.setFrequency(145050); radio.setFrequency(145050);

View File

@ -1,6 +1,5 @@
#define DDS_REFCLK_DEFAULT 9600 #define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
@ -23,7 +22,6 @@ void setup() {
// turn on radio // turn on radio
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
radio.initialize(); radio.initialize();
radio.setRfPower(0); radio.setRfPower(0);
radio.setFrequency(145060); radio.setFrequency(145060);

View File

@ -5,9 +5,8 @@ Test beacon will transmit and wait 30 seconds.
Beacon will check to see if the channel is clear before it will transmit. Beacon will check to see if the channel is clear before it will transmit.
*/ */
// Include the HamSheild and Wire (I2C) libraries // Include the HamSheild
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -35,9 +34,6 @@ void setup() {
// Send a quick serial string // Send a quick serial string
Serial.println("HamShield FM Beacon Example Sketch"); Serial.println("HamShield FM Beacon Example Sketch");
// Start the Wire (I2C) library
Wire.begin();
// Query the HamShield for status information // Query the HamShield for status information
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();

View File

@ -1,7 +1,6 @@
/* Fox Hunt */ /* Fox Hunt */
#include <HamShield.h> #include <HamShield.h>
//#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -27,7 +26,6 @@ void setup() {
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
//Wire.begin();
radio.initialize(); radio.initialize();
radio.frequency(145510); radio.frequency(145510);
radio.setModeReceive(); radio.setModeReceive();

View File

@ -1,7 +1,6 @@
/* HamShield Functional Test */ /* HamShield Functional Test */
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -21,7 +20,6 @@ void setup() {
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield"); Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield");
Serial.print("Radio status: "); Serial.print("Radio status: ");

View File

@ -7,14 +7,13 @@ Simple gauges for the radio receiver.
*/ */
#include <HAMShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
#define SWITCH_PIN 2 #define SWITCH_PIN 2
HAMShield radio; HamShield radio;
void clr() { void clr() {
/* Serial.write(27); /* Serial.write(27);
@ -37,7 +36,7 @@ void setup() {
analogReference(DEFAULT); analogReference(DEFAULT);
Serial.begin(115200); Serial.begin(115200);
Wire.begin();
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();
Serial.println(result,DEC); Serial.println(result,DEC);

View File

@ -1,15 +1,14 @@
/* Simple DTMF controlled HAM Radio Robot */ /* Simple DTMF controlled HAM Radio Robot */
#include <ArduinoRobot.h> // include the robot library #include <ArduinoRobot.h> // include the robot library
#include <HAMShield.h> #include <HamShield.h>
#include <Wire.h>
#include <SPI.h> #include <SPI.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
#define SWITCH_PIN 2 #define SWITCH_PIN 2
HAMShield radio; HamShield radio;
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
@ -24,7 +23,7 @@ void setup() {
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Robot.begin(); Robot.begin();
Wire.begin();
radio.initialize(); radio.initialize();
radio.frequency(145510); radio.frequency(145510);
} }

View File

@ -1,9 +1,5 @@
// Hamshield // Hamshield
// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"
#include <HamShield.h> #include <HamShield.h>
// create object for radio // create object for radio
@ -48,9 +44,6 @@ void setup() {
Serial.println("beginning radio setup"); Serial.println("beginning radio setup");
// join I2C bus (I2Cdev library doesn't do this automatically)
Wire.begin();
// verify connection // verify connection
Serial.println("Testing device connections..."); Serial.println("Testing device connections...");
Serial.println(radio.testConnection() ? "RDA radio connection successful" : "RDA radio connection failed"); Serial.println(radio.testConnection() ? "RDA radio connection successful" : "RDA radio connection failed");

View File

@ -7,8 +7,7 @@ Arduino audio overlay example
*/ */
#include <HAMShield.h> #include <HamShield.h>
#include <Wire.h>
#define DOT 100 #define DOT 100
@ -16,7 +15,7 @@ Arduino audio overlay example
#define RESET_PIN A3 #define RESET_PIN A3
#define SWITCH_PIN 2 #define SWITCH_PIN 2
HAMShield radio; HamShield radio;
const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@", const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@",
*bitu[] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----.",".-.-.-","--..--","..--..",".----.","-.-.--","-..-.","-.--.","-.--.-",".-...","---...","-.-.-.","-...-",".-.-.","-....-","..--.-",".-..-.","...-..-",".--.-." *bitu[] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----.",".-.-.-","--..--","..--..",".----.","-.-.--","-..-.","-.--.","-.--.-",".-...","---...","-.-.-.","-...-",".-.-.","-....-","..--.-",".-..-.","...-..-",".--.-."
@ -40,7 +39,7 @@ void setup() {
Serial.begin(9600); Serial.begin(9600);
Serial.println("starting up.."); Serial.println("starting up..");
Wire.begin();
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();
Serial.println(result,DEC); Serial.println(result,DEC);

View File

@ -1,7 +1,6 @@
/* Just Transmit */ /* Just Transmit */
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -21,7 +20,6 @@ void setup() {
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield"); Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield");
Serial.print("Radio status: "); Serial.print("Radio status: ");

View File

@ -1,5 +1,4 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#include <KISS.h> #include <KISS.h>
HamShield radio; HamShield radio;
@ -30,7 +29,6 @@ void setup() {
// let the AU ot of reset // let the AU ot of reset
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
radio.initialize(); radio.initialize();
radio.setSQOff(); radio.setSQOff();
radio.setFrequency(144390); radio.setFrequency(144390);

View File

@ -6,8 +6,7 @@ A bit robotic and weird
*/ */
#include <HAMShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -16,7 +15,7 @@ A bit robotic and weird
#define RATE 500 #define RATE 500
#define SIZE 1500 #define SIZE 1500
HAMShield radio; HamShield radio;
char sound[SIZE]; char sound[SIZE];
unsigned int sample1; unsigned int sample1;
@ -36,7 +35,6 @@ void setup() {
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
// int result = radio.testConnection(); // int result = radio.testConnection();
radio.initialize(); radio.initialize();
radio.setFrequency(446000); radio.setFrequency(446000);

View File

@ -13,10 +13,9 @@ Sends an SSTV test pattern
/* Standard libraries and variable init */ /* Standard libraries and variable init */
#include <HAMShield.h> #include <HamShield.h>
#include <Wire.h>
HAMShield radio; HamShield radio;
int16_t rssi; int16_t rssi;
/* get our radio ready */ /* get our radio ready */
@ -33,7 +32,6 @@ void setup() {
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();

View File

@ -2,7 +2,6 @@
#define DDS_REFCLK_DEFAULT (34965/2) #define DDS_REFCLK_DEFAULT (34965/2)
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@ -31,8 +30,8 @@ void setup() {
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Wire.begin();
// Query the HamShield for status information // Query the HamShield for status information
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = 0; int result = 0;
result = radio.testConnection(); result = radio.testConnection();

View File

@ -1,6 +1,6 @@
/* /*
SerialTransceiver is TTL Serial port "glue" to allow desktop or laptop control of the HAMShield SerialTransceiver is TTL Serial port "glue" to allow desktop or laptop control of the HamShield
Commands: Commands:
@ -46,7 +46,6 @@ Debug Msg @<text>; 32 character debug message
*/ */
#include "Wire.h"
#include "HamShield.h" #include "HamShield.h"
#define PWM_PIN 3 #define PWM_PIN 3
@ -85,7 +84,7 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;"); Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;");
Wire.begin();
int result = radio.testConnection(); int result = radio.testConnection();
Serial.print("*"); Serial.print("*");
Serial.print(result,DEC); Serial.print(result,DEC);

View File

@ -10,15 +10,14 @@ Plays back the current signal strength level and morses out it's call sign at th
/* Standard libraries and variable init */ /* Standard libraries and variable init */
#include <HAMShield.h> #include <HamShield.h>
#include <Wire.h>
#include <PCM.h> #include <PCM.h>
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
#define SWITCH_PIN 2 #define SWITCH_PIN 2
HAMShield radio; HamShield radio;
int16_t rssi; int16_t rssi;
int peak = -150; int peak = -150;
char sig[8]; char sig[8];
@ -89,7 +88,6 @@ void setup() {
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, HIGH); digitalWrite(RESET_PIN, HIGH);
Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();