From 6b775130d1eb42d4fdf637f54299bc87994306e9 Mon Sep 17 00:00:00 2001 From: nick6x Date: Fri, 26 Aug 2016 15:02:40 -0700 Subject: [PATCH] Remove unfinished examples --- examples/FixMe/DTMFDecoder/DTMFDecoder.ino | 283 ------------------ examples/FixMe/Identifier/Identifier.ino | 95 ------ examples/HAMBot/HAMBot.ino | 60 ---- examples/Parrot/Parrot.ino | 131 -------- .../SerialTransceiver/SerialTransceiver.ino | 14 - 5 files changed, 583 deletions(-) delete mode 100755 examples/FixMe/DTMFDecoder/DTMFDecoder.ino delete mode 100644 examples/FixMe/Identifier/Identifier.ino delete mode 100755 examples/HAMBot/HAMBot.ino delete mode 100755 examples/Parrot/Parrot.ino diff --git a/examples/FixMe/DTMFDecoder/DTMFDecoder.ino b/examples/FixMe/DTMFDecoder/DTMFDecoder.ino deleted file mode 100755 index adfa21c..0000000 --- a/examples/FixMe/DTMFDecoder/DTMFDecoder.ino +++ /dev/null @@ -1,283 +0,0 @@ - -// 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 - -//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; - } -} diff --git a/examples/FixMe/Identifier/Identifier.ino b/examples/FixMe/Identifier/Identifier.ino deleted file mode 100644 index 1f6f654..0000000 --- a/examples/FixMe/Identifier/Identifier.ino +++ /dev/null @@ -1,95 +0,0 @@ -/* - -Indentifier - -Arduino audio overlay example - -*/ - - -#include - -#define DOT 100 - -#define PWM_PIN 3 -#define RESET_PIN A3 -#define SWITCH_PIN 2 - -HamShield radio; - -const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@", - *bitu[] = { ".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".----","..---","...--","....-",".....","-....","--...","---..","----.",".-.-.-","--..--","..--..",".----.","-.-.--","-..-.","-.--.","-.--.-",".-...","---...","-.-.-.","-...-",".-.-.","-....-","..--.-",".-..-.","...-..-",".--.-." - }; - -const char *callsign = {"1ZZ9ZZ/B"} ; - -char morsebuffer[8]; - -void setup() { -// NOTE: if not using PWM out, it should be held low to avoid tx noise - pinMode(PWM_PIN, OUTPUT); - digitalWrite(PWM_PIN, LOW); - - // prep the switch - pinMode(SWITCH_PIN, INPUT_PULLUP); - - // set up the reset control pin - pinMode(RESET_PIN, OUTPUT); - digitalWrite(RESET_PIN, HIGH); - - Serial.begin(9600); - Serial.println("starting up.."); - - Serial.print("Radio status: "); - int result = radio.testConnection(); - Serial.println(result,DEC); - radio.initialize(); - radio.frequency(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]; - } - } -} diff --git a/examples/HAMBot/HAMBot.ino b/examples/HAMBot/HAMBot.ino deleted file mode 100755 index d66048a..0000000 --- a/examples/HAMBot/HAMBot.ino +++ /dev/null @@ -1,60 +0,0 @@ -/* Hamshield - * Example: HAMBot - * Simple DTMF controlled HAM Radio Robot. You will need - * seperate DTMF equipment as well as robot for this - * example. - * Connect the HamShield to your Arduino. Screw the antenna - * into the HamShield RF jack. Connect the Arduino to wall - * power and then to your computer via USB. After uploading - * this program to your adruino, you can send commands from - * your DTMF equipment using the following list: - * '4' => turn robot left - * '6' => turn robot right - * '2' => move robot forward - * '5' => tell robot to send morse code identity -*/ - -#include // include the robot library -#include -#include - -#define PWM_PIN 3 -#define RESET_PIN A3 -#define SWITCH_PIN 2 - -HamShield radio; - -void setup() { - // NOTE: if not using PWM out, it should be held low to avoid tx noise - pinMode(PWM_PIN, OUTPUT); - digitalWrite(PWM_PIN, LOW); - - // prep the switch - pinMode(SWITCH_PIN, INPUT_PULLUP); - - // set up the reset control pin - pinMode(RESET_PIN, OUTPUT); - digitalWrite(RESET_PIN, HIGH); - - Robot.begin(); - - radio.initialize(); - radio.frequency(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 - } - } - } -} - diff --git a/examples/Parrot/Parrot.ino b/examples/Parrot/Parrot.ino deleted file mode 100755 index ada4c8f..0000000 --- a/examples/Parrot/Parrot.ino +++ /dev/null @@ -1,131 +0,0 @@ -/* Hamshield - * Example: Parrot - * Record sound and then plays it back a few times. Very low - * sound quality @ 2KHz 0.75 seconds. A bit robotic and weird. - * You will need a HandyTalkie (HT) to test the output of this - * example. - * 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 to - * your computer via USB. To test the output, tune you HT to - * 446MHz. The HamShield should make a recording of the next - * broadcast on that frequncy. The recording should then be - * repeated ten times by the HamShield. -*/ - -#include - -#define PWM_PIN 3 -#define RESET_PIN A3 -#define SWITCH_PIN 2 - -#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() { - // NOTE: if not using PWM out, it should be held low to avoid tx noise - pinMode(PWM_PIN, OUTPUT); - digitalWrite(PWM_PIN, LOW); - - // prep the switch - pinMode(SWITCH_PIN, INPUT_PULLUP); - - // set up the reset control pin - pinMode(RESET_PIN, OUTPUT); - digitalWrite(RESET_PIN, HIGH); - - // int result = radio.testConnection(); - radio.initialize(); - radio.frequency(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(2); - sound[x] = sample1 >> 4; - delayMicroseconds(RATE); x++; - sample1 = analogRead(2); - sound[x] = (sample1 & 0xF0) | sound[x]; - delayMicroseconds(RATE); - } else { - sound[x] = analogRead(2); - delayMicroseconds(RATE); x++; - sound[x] = analogRead(2); - 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; - } -} - diff --git a/examples/SerialTransceiver/SerialTransceiver.ino b/examples/SerialTransceiver/SerialTransceiver.ino index e615149..5a0e843 100644 --- a/examples/SerialTransceiver/SerialTransceiver.ino +++ b/examples/SerialTransceiver/SerialTransceiver.ino @@ -21,28 +21,14 @@ Mode ASCII Description -------------- ----------- -------------------------------------------------------------------------------------------------------------------------------------------- ----------------- 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; must be a numerical ascii value with decimal point indicating CTCSS receive tone required to unsquelch No -CTCSS Out B; must be a numerical ascii value with decimal point indicating CTCSS transmit tone No -CTCSS Enable C; Turns on CTCSS mode (analog tone) with 1, off with 0. No -CDCSS Enable D; Turns on CDCSS mode (digital tone) with 1, off with 0. No Bandwidth E; for 12.5KHz mode is 0, for 25KHz, mode is 1 No Frequency F; Set the receive frequency in KHz, if offset is disabled, this is the transmit frequency No -CDCSS In G; must be a valid CDCSS code No -CDCSS Out H; 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 Morse Out M; A small buffer for morse code (32 chars) Power level P; Set the power amp level, 0 = lowest, 15 = highest No Enable Offset R; 1 turns on repeater offset mode, 0 turns off repeater offset mode No Squelch S; Set the squelch level No TX Offset T; The absolute frequency of the repeater offset to transmit on in KHz No -Volume V; Set the volume level of the receiver No -Reset X Reset all settings to default No -Sleep Z Sleep radio No -Filters @; 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 $; 0 = vox off, >= 1 audio sensitivity. lower value more sensitive No -Mic Channel *; 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,,; Dual tone: %2,,,; DTMF: %3,,; No Voice Level ^ Respond with the current voice level (VSSI)