Updating examples
This commit is contained in:
		
							parent
							
								
									3457f11211
								
							
						
					
					
						commit
						88efafa0e2
					
				| 
						 | 
					@ -1,127 +0,0 @@
 | 
				
			||||||
/* Hamshield
 | 
					 | 
				
			||||||
 * Example: AFSK Packet Tester
 | 
					 | 
				
			||||||
 * This example sends AFSK test data. You will need a seperate 
 | 
					 | 
				
			||||||
 * AFSK receiver to test the output of 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 Arduino, 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
 | 
					 | 
				
			||||||
#define RESET_PIN A3
 | 
					 | 
				
			||||||
#define SWITCH_PIN 2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
HamShield radio;
 | 
					 | 
				
			||||||
DDS dds;
 | 
					 | 
				
			||||||
AFSK afsk;
 | 
					 | 
				
			||||||
String messagebuff = "";
 | 
					 | 
				
			||||||
String origin_call = "";
 | 
					 | 
				
			||||||
String destination_call = "";
 | 
					 | 
				
			||||||
String textmessage = "";
 | 
					 | 
				
			||||||
int msgptr = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
  // turn on pwr to the radio
 | 
					 | 
				
			||||||
  digitalWrite(RESET_PIN, HIGH);
 | 
					 | 
				
			||||||
  delay(5); // wait for device to come up
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Serial.begin(9600);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  radio.initialize();
 | 
					 | 
				
			||||||
  radio.frequency(144390);
 | 
					 | 
				
			||||||
  radio.setRfPower(0);
 | 
					 | 
				
			||||||
  // radio.bypassPreDeEmph();
 | 
					 | 
				
			||||||
  dds.start();
 | 
					 | 
				
			||||||
  afsk.start(&dds);
 | 
					 | 
				
			||||||
  delay(100);
 | 
					 | 
				
			||||||
  Serial.println("HELLO");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void loop() {
 | 
					 | 
				
			||||||
  prepMessage();
 | 
					 | 
				
			||||||
  delay(10000);
 | 
					 | 
				
			||||||
} 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void prepMessage() { 
 | 
					 | 
				
			||||||
  radio.setModeTransmit();
 | 
					 | 
				
			||||||
  delay(500);
 | 
					 | 
				
			||||||
  origin_call = "KC7IBT"; // get originating callsign
 | 
					 | 
				
			||||||
  destination_call = "KC7IBT"; // get the destination call
 | 
					 | 
				
			||||||
  textmessage = ":HAMSHIELD TEST";
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Serial.print("From: "); Serial.print(origin_call); Serial.print(" To: "); Serial.println(destination_call); Serial.println("Text: "); Serial.print(textmessage);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  packet->start();
 | 
					 | 
				
			||||||
  packet->appendCallsign(destination_call.c_str(),0);
 | 
					 | 
				
			||||||
  packet->appendCallsign(origin_call.c_str(),15,true);   
 | 
					 | 
				
			||||||
  packet->appendFCS(0x03);
 | 
					 | 
				
			||||||
  packet->appendFCS(0xf0);
 | 
					 | 
				
			||||||
  packet->print(textmessage);
 | 
					 | 
				
			||||||
  packet->finish();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  bool ret = afsk.putTXPacket(packet);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if(afsk.txReady()) {
 | 
					 | 
				
			||||||
    Serial.println(F("TX"));
 | 
					 | 
				
			||||||
    radio.setModeTransmit();
 | 
					 | 
				
			||||||
    //delay(100);
 | 
					 | 
				
			||||||
    if(afsk.txStart()) {
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      radio.setModeReceive();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  // Wait 2 seconds before we send our beacon again.
 | 
					 | 
				
			||||||
  // Wait up to 2.5 seconds to finish sending, and stop transmitter.
 | 
					 | 
				
			||||||
  // TODO: This is hackery.
 | 
					 | 
				
			||||||
  for(int i = 0; i < 500; i++) {
 | 
					 | 
				
			||||||
    if(afsk.encoder.isDone())
 | 
					 | 
				
			||||||
       break;
 | 
					 | 
				
			||||||
    delay(50);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  Serial.println("RX");
 | 
					 | 
				
			||||||
  radio.setModeReceive();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
ISR(TIMER2_OVF_vect) {
 | 
					 | 
				
			||||||
  TIFR2 = _BV(TOV2);
 | 
					 | 
				
			||||||
  static uint8_t tcnt = 0;
 | 
					 | 
				
			||||||
  if(++tcnt == 8) {
 | 
					 | 
				
			||||||
    dds.clockTick();
 | 
					 | 
				
			||||||
    tcnt = 0;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ISR(ADC_vect) {
 | 
					 | 
				
			||||||
  static uint8_t tcnt = 0;
 | 
					 | 
				
			||||||
  TIFR1 = _BV(ICF1); // Clear the timer flag
 | 
					 | 
				
			||||||
  dds.clockTick();
 | 
					 | 
				
			||||||
  if(++tcnt == 1) {
 | 
					 | 
				
			||||||
    if(afsk.encoder.isSending()) {
 | 
					 | 
				
			||||||
      afsk.timer();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    tcnt = 0;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,13 +0,0 @@
 | 
				
			||||||
chrome.app.runtime.onLaunched.addListener(function() {
 | 
					 | 
				
			||||||
  chrome.app.window.create("window.html", {
 | 
					 | 
				
			||||||
    "bounds": {
 | 
					 | 
				
			||||||
        "width": 685,
 | 
					 | 
				
			||||||
        "height": 800
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  $(function() {
 | 
					 | 
				
			||||||
    $( "#tabs" ).tabs();
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 11 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 11 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 11 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 11 KiB  | 
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -1,10 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  "name": "HamShield",
 | 
					 | 
				
			||||||
  "description": "HamShield",
 | 
					 | 
				
			||||||
  "version": "1.0.0",
 | 
					 | 
				
			||||||
  "app": {
 | 
					 | 
				
			||||||
    "background": {
 | 
					 | 
				
			||||||
        "scripts": ["background.js"]
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1 +0,0 @@
 | 
				
			||||||
chromeApp
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,48 +0,0 @@
 | 
				
			||||||
body{
 | 
					 | 
				
			||||||
  display: inline-block;  
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.btn {
 | 
					 | 
				
			||||||
  background: #adadad;
 | 
					 | 
				
			||||||
  background-image: -webkit-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: -moz-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: -ms-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: -o-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: linear-gradient(to bottom, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  -webkit-border-radius: 0;
 | 
					 | 
				
			||||||
  -moz-border-radius: 0;
 | 
					 | 
				
			||||||
  border-radius: 0px;
 | 
					 | 
				
			||||||
  font-family: Arial;
 | 
					 | 
				
			||||||
  color: #ffffff;
 | 
					 | 
				
			||||||
  font-size: 20px;
 | 
					 | 
				
			||||||
  padding: 10px 20px 10px 20px;
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
  float: left;
 | 
					 | 
				
			||||||
  text-align:center;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.btn:hover {
 | 
					 | 
				
			||||||
  background: #3d3d3d;
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.lcd {
 | 
					 | 
				
			||||||
  -webkit-border-radius: 0;
 | 
					 | 
				
			||||||
  -moz-border-radius: 0;
 | 
					 | 
				
			||||||
  border-radius: 0px;
 | 
					 | 
				
			||||||
  font-family: Courier New;
 | 
					 | 
				
			||||||
  color: #00ff00;
 | 
					 | 
				
			||||||
  font-size: 50px;
 | 
					 | 
				
			||||||
  background: #000000;
 | 
					 | 
				
			||||||
  padding: 10px 20px 10px 20px;
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
  width: 500px;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.lcd:hover {
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.bs1 { width: 50px; }
 | 
					 | 
				
			||||||
.bs2 { width: 100px; }
 | 
					 | 
				
			||||||
.bs3 { width: 200px; }
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,61 +0,0 @@
 | 
				
			||||||
<!DOCTYPE html>
 | 
					 | 
				
			||||||
<html lang="en">
 | 
					 | 
				
			||||||
  <head>
 | 
					 | 
				
			||||||
    <link rel="stylesheet" type="text/css" href="styles.css">
 | 
					 | 
				
			||||||
  <meta charset="utf-8">
 | 
					 | 
				
			||||||
  <title>APRSMessenger</title>
 | 
					 | 
				
			||||||
  <link rel="stylesheet" href="jquery-ui.css">
 | 
					 | 
				
			||||||
  <script src="jquery-1.10.2.js"></script>
 | 
					 | 
				
			||||||
  <script src="jquery-ui.js"></script>
 | 
					 | 
				
			||||||
</head>
 | 
					 | 
				
			||||||
  <body>
 | 
					 | 
				
			||||||
    <div class="lcd" style="width: 768px">
 | 
					 | 
				
			||||||
       144.390 MHz | APRS | <img src="bars-3.png" style="height: 32px; width: 32px;">
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="lcd" style="width: 768px; font-size: 15px;">
 | 
					 | 
				
			||||||
      2M | BW: 25KHz | TX CTCSS: OFF | RX CTCSS: OFF | Filter: OFF | Presence: Available 
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn" style="width: 75px">
 | 
					 | 
				
			||||||
       Tune
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
       Presence
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      GPS
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      SSTV
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      WX
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      MSG
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      SQ-
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      SQ+
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      VOL
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <br/><br/>
 | 
					 | 
				
			||||||
    <div id="tabs">
 | 
					 | 
				
			||||||
     <ul>
 | 
					 | 
				
			||||||
       <li><a href="#tabs-1">Console</a></li>
 | 
					 | 
				
			||||||
       <li><a href="#tabs-2">KG7OGM</a></li>
 | 
					 | 
				
			||||||
       <li><a href="#tabs-3">KC7IBT</a></li>
 | 
					 | 
				
			||||||
     </ul>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div id="tabs-1">
 | 
					 | 
				
			||||||
      Debug messages
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div id="tabs-2">
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div id="tabs-3">
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
  </body>
 | 
					 | 
				
			||||||
</html>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,94 +0,0 @@
 | 
				
			||||||
/* Hamshield
 | 
					 | 
				
			||||||
 * Example: AX25 Receive
 | 
					 | 
				
			||||||
 * This example receives AFSK test data. You will need seperate 
 | 
					 | 
				
			||||||
 * AFSK equipment to send data for 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. After uploading this program to your 
 | 
					 | 
				
			||||||
 * Arduino, open the Serial Monitor so you will see the AFSK 
 | 
					 | 
				
			||||||
 * packet. Send AFSK packet from AFSK equipment at 145.01MHz.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 *  Note: add message receive code
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <HamShield.h>
 | 
					 | 
				
			||||||
#include <DDS.h>
 | 
					 | 
				
			||||||
#include <packet.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define PWM_PIN 3
 | 
					 | 
				
			||||||
#define RESET_PIN A3
 | 
					 | 
				
			||||||
#define SWITCH_PIN 2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
HamShield radio;
 | 
					 | 
				
			||||||
DDS dds;
 | 
					 | 
				
			||||||
AFSK afsk;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
  // turn on radio
 | 
					 | 
				
			||||||
  digitalWrite(RESET_PIN, HIGH);
 | 
					 | 
				
			||||||
  delay(5); // wait for device to come up
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Serial.begin(9600);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Serial.println(F("Radio test connection"));
 | 
					 | 
				
			||||||
  Serial.println(radio.testConnection(), DEC);
 | 
					 | 
				
			||||||
  Serial.println(F("Initialize"));
 | 
					 | 
				
			||||||
  delay(100);
 | 
					 | 
				
			||||||
  radio.initialize();
 | 
					 | 
				
			||||||
  radio.frequency(145010);
 | 
					 | 
				
			||||||
  radio.setSQOff();
 | 
					 | 
				
			||||||
  Serial.println(F("Frequency"));
 | 
					 | 
				
			||||||
  Serial.println(radio.getFrequency());
 | 
					 | 
				
			||||||
  delay(100);
 | 
					 | 
				
			||||||
  Serial.print(F("Squelch(H/L): "));
 | 
					 | 
				
			||||||
  Serial.print(radio.getSQHiThresh());
 | 
					 | 
				
			||||||
  Serial.print(F(" / "));
 | 
					 | 
				
			||||||
  Serial.println(radio.getSQLoThresh());
 | 
					 | 
				
			||||||
  radio.setModeReceive();
 | 
					 | 
				
			||||||
  //radio.bypassPreDeEmph();
 | 
					 | 
				
			||||||
  Serial.println(F("DDS Start"));
 | 
					 | 
				
			||||||
  delay(100);
 | 
					 | 
				
			||||||
  dds.start();
 | 
					 | 
				
			||||||
  Serial.println(F("AFSK start"));
 | 
					 | 
				
			||||||
  delay(100);
 | 
					 | 
				
			||||||
  afsk.start(&dds);
 | 
					 | 
				
			||||||
  Serial.println(F("Starting..."));
 | 
					 | 
				
			||||||
  delay(100);
 | 
					 | 
				
			||||||
  dds.setAmplitude(255);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint32_t last = 0;
 | 
					 | 
				
			||||||
void loop() {
 | 
					 | 
				
			||||||
   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(afsk.rxPacketCount()) {
 | 
					 | 
				
			||||||
        AFSK::Packet *packet = afsk.getRXPacket();
 | 
					 | 
				
			||||||
        Serial.print(F("Packet: "));
 | 
					 | 
				
			||||||
        if(packet) {
 | 
					 | 
				
			||||||
          packet->printPacket(&Serial);
 | 
					 | 
				
			||||||
          AFSK::PacketBuffer::freePacket(packet);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//TODO: d2 is the switch input, so remove this
 | 
					 | 
				
			||||||
ISR(ADC_vect) {
 | 
					 | 
				
			||||||
  static uint8_t tcnt = 0;
 | 
					 | 
				
			||||||
  TIFR1 = _BV(ICF1); // Clear the timer flag
 | 
					 | 
				
			||||||
  //PORTD |= _BV(2); // Diagnostic pin (D2)
 | 
					 | 
				
			||||||
  //dds.clockTick();
 | 
					 | 
				
			||||||
  afsk.timer();
 | 
					 | 
				
			||||||
  //PORTD &= ~(_BV(2)); // Pin D2 off again
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,8 +0,0 @@
 | 
				
			||||||
chrome.app.runtime.onLaunched.addListener(function() {
 | 
					 | 
				
			||||||
  chrome.app.window.create("window.html", {
 | 
					 | 
				
			||||||
    "bounds": {
 | 
					 | 
				
			||||||
        "width": 685,
 | 
					 | 
				
			||||||
        "height": 263
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,10 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  "name": "HamShield",
 | 
					 | 
				
			||||||
  "description": "HamShield",
 | 
					 | 
				
			||||||
  "version": "1.0.0",
 | 
					 | 
				
			||||||
  "app": {
 | 
					 | 
				
			||||||
    "background": {
 | 
					 | 
				
			||||||
        "scripts": ["background.js"]
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1 +0,0 @@
 | 
				
			||||||
chromeApp
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,48 +0,0 @@
 | 
				
			||||||
body{
 | 
					 | 
				
			||||||
  display: inline-block;  
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.btn {
 | 
					 | 
				
			||||||
  background: #adadad;
 | 
					 | 
				
			||||||
  background-image: -webkit-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: -moz-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: -ms-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: -o-linear-gradient(top, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  background-image: linear-gradient(to bottom, #adadad, #3d3d3d);
 | 
					 | 
				
			||||||
  -webkit-border-radius: 0;
 | 
					 | 
				
			||||||
  -moz-border-radius: 0;
 | 
					 | 
				
			||||||
  border-radius: 0px;
 | 
					 | 
				
			||||||
  font-family: Arial;
 | 
					 | 
				
			||||||
  color: #ffffff;
 | 
					 | 
				
			||||||
  font-size: 20px;
 | 
					 | 
				
			||||||
  padding: 10px 20px 10px 20px;
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
  float: left;
 | 
					 | 
				
			||||||
  text-align:center;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.btn:hover {
 | 
					 | 
				
			||||||
  background: #3d3d3d;
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.lcd {
 | 
					 | 
				
			||||||
  -webkit-border-radius: 0;
 | 
					 | 
				
			||||||
  -moz-border-radius: 0;
 | 
					 | 
				
			||||||
  border-radius: 0px;
 | 
					 | 
				
			||||||
  font-family: Courier New;
 | 
					 | 
				
			||||||
  color: #00ff00;
 | 
					 | 
				
			||||||
  font-size: 50px;
 | 
					 | 
				
			||||||
  background: #000000;
 | 
					 | 
				
			||||||
  padding: 10px 20px 10px 20px;
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
  width: 500px;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.lcd:hover {
 | 
					 | 
				
			||||||
  text-decoration: none;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.bs1 { width: 50px; }
 | 
					 | 
				
			||||||
.bs2 { width: 100px; }
 | 
					 | 
				
			||||||
.bs3 { width: 200px; }
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,67 +0,0 @@
 | 
				
			||||||
<!DOCTYPE html>
 | 
					 | 
				
			||||||
<html>
 | 
					 | 
				
			||||||
  <head>
 | 
					 | 
				
			||||||
    <link rel="stylesheet" type="text/css" href="styles.css">
 | 
					 | 
				
			||||||
  </head>
 | 
					 | 
				
			||||||
  <body>
 | 
					 | 
				
			||||||
    <div class="lcd" style="width: 623px">
 | 
					 | 
				
			||||||
       220.000 MHz
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="lcd" style="width: 623px; font-size: 15px;">
 | 
					 | 
				
			||||||
      1.25M | BW 12.5KHz | TX CTCSS: 103.5 | RX CTCSS: 109.4 | Filter OFF  
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn" style="width: 75px">
 | 
					 | 
				
			||||||
       BW
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
       Band
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      +
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      -
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      <<
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      >>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      SQ-
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      SQ+
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
      VOL
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <br/>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    CTCSS
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    CDCSS
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    Vox
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    Filter
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    Offset
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    Directory
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div class="btn">
 | 
					 | 
				
			||||||
    WX
 | 
					 | 
				
			||||||
    </div> 
 | 
					 | 
				
			||||||
    <br/>
 | 
					 | 
				
			||||||
    <div class="btn" style="width: 622px">
 | 
					 | 
				
			||||||
      Transmit
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
  </body>
 | 
					 | 
				
			||||||
</html>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,285 +0,0 @@
 | 
				
			||||||
/* Hamshield
 | 
					 | 
				
			||||||
 * Example: Crystal Calibration
 | 
					 | 
				
			||||||
 * This example allows you to calibrate the crystal clock 
 | 
					 | 
				
			||||||
 * through the Arduino Serial Monitor.
 | 
					 | 
				
			||||||
 * 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 Arduino, open the Serial Monitor.
 | 
					 | 
				
			||||||
 * Make sure drop-down menu at the bottom of Serial Monitor
 | 
					 | 
				
			||||||
 * is set to "Newline". Type 'h' into the bar at the top of 
 | 
					 | 
				
			||||||
 * the Serial Monitor and click the  "Send" button for more 
 | 
					 | 
				
			||||||
 * instructions.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define DDS_REFCLK_DEFAULT 38400
 | 
					 | 
				
			||||||
#define DDS_REFCLK_OFFSET  0
 | 
					 | 
				
			||||||
#define DDS_DEBUG_SERIAL
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <HamShield.h>
 | 
					 | 
				
			||||||
#include <DDS.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define PWM_PIN 3
 | 
					 | 
				
			||||||
#define RESET_PIN A3
 | 
					 | 
				
			||||||
#define SWITCH_PIN 2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
HamShield radio;
 | 
					 | 
				
			||||||
DDS dds;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
  // turn on radio
 | 
					 | 
				
			||||||
  digitalWrite(RESET_PIN, HIGH);
 | 
					 | 
				
			||||||
  delay(5); // wait for device to come up
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Serial.begin(9600);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  radio.initialize();
 | 
					 | 
				
			||||||
  radio.setRfPower(0);
 | 
					 | 
				
			||||||
  radio.frequency(145050);
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  dds.start();
 | 
					 | 
				
			||||||
  dds.setFrequency(1200);
 | 
					 | 
				
			||||||
  dds.on();
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  radio.bypassPreDeEmph();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum Sets {
 | 
					 | 
				
			||||||
  SET_REF,
 | 
					 | 
				
			||||||
  SET_TONE,
 | 
					 | 
				
			||||||
  SET_AMPLITUDE,
 | 
					 | 
				
			||||||
  SET_ADC_HALF,
 | 
					 | 
				
			||||||
  SET_OFFSET
 | 
					 | 
				
			||||||
} setting = SET_TONE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char freqBuffer[8];
 | 
					 | 
				
			||||||
char *freqBufferPtr = freqBuffer;
 | 
					 | 
				
			||||||
uint16_t lastFreq = 1200;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
volatile uint16_t recordedPulseLength;
 | 
					 | 
				
			||||||
volatile bool recordedPulse = false;
 | 
					 | 
				
			||||||
volatile bool listening = false;
 | 
					 | 
				
			||||||
volatile uint8_t maxADC = 0, minADC = 255, adcHalf = 40;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void loop() {
 | 
					 | 
				
			||||||
  static uint16_t samples = 0;
 | 
					 | 
				
			||||||
  static uint16_t pulse;
 | 
					 | 
				
			||||||
  static uint32_t lastOutput = 0;
 | 
					 | 
				
			||||||
  static float pulseFloat = 0.0;
 | 
					 | 
				
			||||||
  if(recordedPulse) {
 | 
					 | 
				
			||||||
    uint32_t pulseAveraging;
 | 
					 | 
				
			||||||
    uint16_t tmpPulse;
 | 
					 | 
				
			||||||
    cli();
 | 
					 | 
				
			||||||
    recordedPulse = false;
 | 
					 | 
				
			||||||
    tmpPulse = recordedPulseLength;
 | 
					 | 
				
			||||||
    sei();
 | 
					 | 
				
			||||||
    if(samples++ == 0) {
 | 
					 | 
				
			||||||
      pulse = tmpPulse;
 | 
					 | 
				
			||||||
      //pulseFloat = tmpPulse;
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      pulseAveraging = (pulse + tmpPulse) >> 1;
 | 
					 | 
				
			||||||
      pulse = pulseAveraging;
 | 
					 | 
				
			||||||
      pulseFloat = pulseFloat + 0.01*((float)pulse-pulseFloat);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if((lastOutput + 1000) < millis()) {
 | 
					 | 
				
			||||||
      Serial.print(F("Pulse:   "));
 | 
					 | 
				
			||||||
      Serial.println(pulse);
 | 
					 | 
				
			||||||
      Serial.print(F("Last:    "));
 | 
					 | 
				
			||||||
      Serial.println(tmpPulse);
 | 
					 | 
				
			||||||
      Serial.print(F("Samples: "));
 | 
					 | 
				
			||||||
      Serial.println(samples);
 | 
					 | 
				
			||||||
      Serial.print(F("ADC M/M: "));
 | 
					 | 
				
			||||||
      Serial.print(minADC); minADC = 255;
 | 
					 | 
				
			||||||
      Serial.print(F(" / "));
 | 
					 | 
				
			||||||
      Serial.println(maxADC); maxADC = 0;
 | 
					 | 
				
			||||||
      Serial.print(F("Freq:    "));
 | 
					 | 
				
			||||||
      // F = 1/(pulse*(1/ref))
 | 
					 | 
				
			||||||
      // F = ref/pulse
 | 
					 | 
				
			||||||
      Serial.print((float)((float)dds.getReferenceClock()+(float)dds.getReferenceOffset())/(float)pulse);
 | 
					 | 
				
			||||||
      Serial.print(F(" / "));
 | 
					 | 
				
			||||||
      Serial.print((float)((float)dds.getReferenceClock()+(float)dds.getReferenceOffset())/pulseFloat);
 | 
					 | 
				
			||||||
      Serial.print(F(" / "));
 | 
					 | 
				
			||||||
      Serial.println(pulseFloat);
 | 
					 | 
				
			||||||
      Serial.print(F("Freq2:   "));
 | 
					 | 
				
			||||||
      // F = 1/(pulse*(1/ref))
 | 
					 | 
				
			||||||
      // F = ref/pulse
 | 
					 | 
				
			||||||
      Serial.print((float)dds.getReferenceClock()/(float)pulse);
 | 
					 | 
				
			||||||
      Serial.print(F(" / "));
 | 
					 | 
				
			||||||
      Serial.println((float)dds.getReferenceClock()/pulseFloat);
 | 
					 | 
				
			||||||
      samples = 0;
 | 
					 | 
				
			||||||
      lastOutput = millis();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  while(Serial.available()) {
 | 
					 | 
				
			||||||
    char c = Serial.read();
 | 
					 | 
				
			||||||
    Serial.println(c);
 | 
					 | 
				
			||||||
    switch(c) {
 | 
					 | 
				
			||||||
      case 'h':
 | 
					 | 
				
			||||||
        Serial.println(F("Commands:"));
 | 
					 | 
				
			||||||
        Serial.println(F("RefClk: u = +10, U = +100, r XXXX = XXXX"));
 | 
					 | 
				
			||||||
        Serial.println(F("        d = -10, D = -100"));
 | 
					 | 
				
			||||||
        Serial.println(F("Offset: s XXX = Set refclk offset"));
 | 
					 | 
				
			||||||
        Serial.println(F("Radio:  T = transmit, R = receive"));
 | 
					 | 
				
			||||||
        Serial.println(F("Tone:   t XXXX = XXXX Hz"));
 | 
					 | 
				
			||||||
        Serial.println(F("Amp.:   a XXX  = XXX out of 255"));
 | 
					 | 
				
			||||||
        Serial.println(F("DDS:    o = On, O = Off"));
 | 
					 | 
				
			||||||
        Serial.println(F("Input:  l = Determine received frequency, L = stop"));
 | 
					 | 
				
			||||||
        Serial.println(F("ADC:    m XXX = Set ADC midpoint (zero crossing level)"));
 | 
					 | 
				
			||||||
        Serial.println(F("ie. a 31 = 32/255 amplitude, r38400 sets 38400Hz refclk"));
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'u':
 | 
					 | 
				
			||||||
        dds.setReferenceClock(dds.getReferenceClock()+10);
 | 
					 | 
				
			||||||
        dds.setFrequency(lastFreq);
 | 
					 | 
				
			||||||
        dds.start();
 | 
					 | 
				
			||||||
        Serial.println(F("RefClk + 10 = "));
 | 
					 | 
				
			||||||
        Serial.println(dds.getReferenceClock());
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'U':
 | 
					 | 
				
			||||||
        dds.setReferenceClock(dds.getReferenceClock()+100);
 | 
					 | 
				
			||||||
        dds.setFrequency(lastFreq);
 | 
					 | 
				
			||||||
        dds.start();
 | 
					 | 
				
			||||||
        Serial.println(F("RefClk + 100 = "));
 | 
					 | 
				
			||||||
        Serial.println(dds.getReferenceClock());
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'd':
 | 
					 | 
				
			||||||
        dds.setReferenceClock(dds.getReferenceClock()-10);
 | 
					 | 
				
			||||||
        dds.setFrequency(lastFreq);
 | 
					 | 
				
			||||||
        dds.start();
 | 
					 | 
				
			||||||
        Serial.println(F("RefClk - 10 = "));
 | 
					 | 
				
			||||||
        Serial.println(dds.getReferenceClock());
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'D':
 | 
					 | 
				
			||||||
        dds.setReferenceClock(dds.getReferenceClock()-100);
 | 
					 | 
				
			||||||
        dds.setFrequency(lastFreq);
 | 
					 | 
				
			||||||
        dds.start();
 | 
					 | 
				
			||||||
        Serial.println(F("RefClk - 100 = "));
 | 
					 | 
				
			||||||
        Serial.println(dds.getReferenceClock());
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'l':
 | 
					 | 
				
			||||||
        Serial.println(F("Start frequency listening, DDS off"));
 | 
					 | 
				
			||||||
        dds.off();
 | 
					 | 
				
			||||||
        listening = true;
 | 
					 | 
				
			||||||
        lastOutput = millis();
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'L':
 | 
					 | 
				
			||||||
        Serial.println(F("Stop frequency listening, DDS on"));
 | 
					 | 
				
			||||||
        listening = false;
 | 
					 | 
				
			||||||
        samples = 0;
 | 
					 | 
				
			||||||
        dds.on();
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'T':
 | 
					 | 
				
			||||||
        Serial.println(F("Radio transmit"));
 | 
					 | 
				
			||||||
        radio.setModeTransmit();
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'R':
 | 
					 | 
				
			||||||
        Serial.println(F("Radio receive"));
 | 
					 | 
				
			||||||
        radio.setModeReceive();
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'r':
 | 
					 | 
				
			||||||
        setting = SET_REF;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 't':
 | 
					 | 
				
			||||||
        setting = SET_TONE;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'a':
 | 
					 | 
				
			||||||
        setting = SET_AMPLITUDE;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'm':
 | 
					 | 
				
			||||||
        setting = SET_ADC_HALF;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 's':
 | 
					 | 
				
			||||||
        setting = SET_OFFSET;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'o':
 | 
					 | 
				
			||||||
        dds.on();
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      case 'O':
 | 
					 | 
				
			||||||
        dds.off();
 | 
					 | 
				
			||||||
        Serial.println("> ");
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
      default:
 | 
					 | 
				
			||||||
        if(c == '-' || (c >= '0' && c <= '9')) {
 | 
					 | 
				
			||||||
          *freqBufferPtr = c;
 | 
					 | 
				
			||||||
          freqBufferPtr++;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if((c == '\n' || c == '\r') && freqBufferPtr != freqBuffer) {
 | 
					 | 
				
			||||||
          *freqBufferPtr = '\0';
 | 
					 | 
				
			||||||
          freqBufferPtr = freqBuffer;
 | 
					 | 
				
			||||||
          uint16_t freq = atoi(freqBuffer);
 | 
					 | 
				
			||||||
          if(setting == SET_REF) {
 | 
					 | 
				
			||||||
            dds.setReferenceClock(freq);
 | 
					 | 
				
			||||||
            dds.setFrequency(lastFreq);
 | 
					 | 
				
			||||||
            dds.start();
 | 
					 | 
				
			||||||
            Serial.print(F("New Reference Clock: "));
 | 
					 | 
				
			||||||
            Serial.println(dds.getReferenceClock());
 | 
					 | 
				
			||||||
          } else if(setting == SET_TONE) {
 | 
					 | 
				
			||||||
            dds.setFrequency(freq);
 | 
					 | 
				
			||||||
            lastFreq = freq;
 | 
					 | 
				
			||||||
            Serial.print(F("New Tone: "));
 | 
					 | 
				
			||||||
            Serial.println(freq);
 | 
					 | 
				
			||||||
          } else if(setting == SET_AMPLITUDE) {
 | 
					 | 
				
			||||||
            dds.setAmplitude((uint8_t)(freq&0xFF));
 | 
					 | 
				
			||||||
            Serial.print(F("New Amplitude: "));
 | 
					 | 
				
			||||||
            Serial.println((uint8_t)(freq&0xFF));
 | 
					 | 
				
			||||||
          } else if(setting == SET_ADC_HALF) {
 | 
					 | 
				
			||||||
            adcHalf = freq&0xFF;
 | 
					 | 
				
			||||||
            Serial.print(F("ADC midpoint set to "));
 | 
					 | 
				
			||||||
            Serial.println((uint8_t)(freq&0xFF));
 | 
					 | 
				
			||||||
          } else if(setting == SET_OFFSET) {
 | 
					 | 
				
			||||||
            dds.setReferenceOffset((int16_t)atoi(freqBuffer));
 | 
					 | 
				
			||||||
            dds.setFrequency(lastFreq);
 | 
					 | 
				
			||||||
            Serial.print(F("Refclk offset: "));
 | 
					 | 
				
			||||||
            Serial.println(dds.getReferenceOffset());
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          Serial.println("> ");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ISR(ADC_vect) {
 | 
					 | 
				
			||||||
  static uint16_t pulseLength = 0;
 | 
					 | 
				
			||||||
  static uint8_t lastADC = 127;
 | 
					 | 
				
			||||||
  cli();
 | 
					 | 
				
			||||||
  TIFR1 = _BV(ICF1);
 | 
					 | 
				
			||||||
  //PORTD |= _BV(2);
 | 
					 | 
				
			||||||
  dds.clockTick();
 | 
					 | 
				
			||||||
  sei();
 | 
					 | 
				
			||||||
  if(listening) {
 | 
					 | 
				
			||||||
    pulseLength++;
 | 
					 | 
				
			||||||
    if(ADCH >= adcHalf && lastADC < adcHalf) {
 | 
					 | 
				
			||||||
      // Zero crossing, upward
 | 
					 | 
				
			||||||
      recordedPulseLength = pulseLength;
 | 
					 | 
				
			||||||
      recordedPulse = true;
 | 
					 | 
				
			||||||
      pulseLength = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if(minADC > ADCH) {
 | 
					 | 
				
			||||||
      minADC = ADCH;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if(maxADC < ADCH) {
 | 
					 | 
				
			||||||
      maxADC = ADCH;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    lastADC = ADCH;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  //PORTD &= ~_BV(2);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,82 +0,0 @@
 | 
				
			||||||
/* Hamshield
 | 
					 | 
				
			||||||
 * Example: Functional Test
 | 
					 | 
				
			||||||
 * This is a simple example to demonstrate HamShield receive
 | 
					 | 
				
			||||||
 * and transmit functionality.
 | 
					 | 
				
			||||||
 * 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. After uploading this program to 
 | 
					 | 
				
			||||||
 * your Arduino, open the Serial Monitor. Serial Monitor will 
 | 
					 | 
				
			||||||
 * describe what you should be expecting to hear from your 
 | 
					 | 
				
			||||||
 * headphones. Tune a HandytTalkie to 446MHz to hear morse 
 | 
					 | 
				
			||||||
 * code example.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <HamShield.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#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);
 | 
					 | 
				
			||||||
  delay(5); // wait for device to come up
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  Serial.begin(9600);
 | 
					 | 
				
			||||||
  Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield");
 | 
					 | 
				
			||||||
  Serial.print("Radio status: ");
 | 
					 | 
				
			||||||
  int result = radio.testConnection();
 | 
					 | 
				
			||||||
  Serial.println(result,DEC);
 | 
					 | 
				
			||||||
  Serial.println("Setting radio to its defaults..");
 | 
					 | 
				
			||||||
  radio.initialize();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void loop() {
 | 
					 | 
				
			||||||
  radio.setModeReceive();
 | 
					 | 
				
			||||||
  radio.setSQLoThresh(0);
 | 
					 | 
				
			||||||
  radio.setSQOff();
 | 
					 | 
				
			||||||
  radio.setVolume1(0xF);
 | 
					 | 
				
			||||||
  radio.setVolume2(0xF);
 | 
					 | 
				
			||||||
  delay(1000);
 | 
					 | 
				
			||||||
  Serial.println("Changing frequency to 446.000 and waiting 10 seconds. You should hear static fading in.");
 | 
					 | 
				
			||||||
    radio.frequency(446000);
 | 
					 | 
				
			||||||
  for(int x = 0; x < 16; x++) { radio.setVolume1(x); delay(500); Serial.print(x); Serial.print(".."); } 
 | 
					 | 
				
			||||||
  for(int x = 0; x < 16; x++) { radio.setVolume2(x); delay(500); Serial.print(x); Serial.print(".."); }   
 | 
					 | 
				
			||||||
      radio.setVolume1(0xF);
 | 
					 | 
				
			||||||
    radio.setVolume2(0xF);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  delay(10000);
 | 
					 | 
				
			||||||
  Serial.println("Changing frequency to 450.000 and waiting 10 seconds. You should hear static.");
 | 
					 | 
				
			||||||
  radio.frequency(446000);
 | 
					 | 
				
			||||||
  delay(10000);
 | 
					 | 
				
			||||||
  Serial.println("Changing frequency to 220.000 and waiting 10 seconds. you should hear static.");
 | 
					 | 
				
			||||||
  radio.frequency(220000);
 | 
					 | 
				
			||||||
  delay(10000);
 | 
					 | 
				
			||||||
  Serial.println("Changing frequency to 144.520 and waiting 10 seconds. you should hear static.");
 | 
					 | 
				
			||||||
  radio.frequency(144520);
 | 
					 | 
				
			||||||
  delay(10000);
 | 
					 | 
				
			||||||
  Serial.println("Now lets scan for a weather radio station and listen for a while....");
 | 
					 | 
				
			||||||
  radio.setWXChannel(radio.scanWXChannel());
 | 
					 | 
				
			||||||
  Serial.println("If you hear weather radio, it means the scanWXChannel() and setWXChannel() and VHF works.");
 | 
					 | 
				
			||||||
  Serial.println("We will sit here for 30 seconds because weather is important.");
 | 
					 | 
				
			||||||
  delay(30000);
 | 
					 | 
				
			||||||
  Serial.println("We will now tune to 446.000 and send morse code");
 | 
					 | 
				
			||||||
  radio.frequency(446000);
 | 
					 | 
				
			||||||
  radio.setModeTransmit();
 | 
					 | 
				
			||||||
  radio.morseOut("HELLO PERSON");
 | 
					 | 
				
			||||||
  radio.setModeReceive();
 | 
					 | 
				
			||||||
  Serial.println("Now we are receiving on the call frequency. Starting over again.");
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,116 +0,0 @@
 | 
				
			||||||
/* Hamshield
 | 
					 | 
				
			||||||
 * Example: Gauges
 | 
					 | 
				
			||||||
 * This example prints Signal, Audio In, and Audio Rx ADC 
 | 
					 | 
				
			||||||
 * Peak strength to the Serial Monitor in a graphical manner.
 | 
					 | 
				
			||||||
 * 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. After uploading this program to 
 | 
					 | 
				
			||||||
 * your Arduino, open the Serial Monitor. You will see a 
 | 
					 | 
				
			||||||
 * repeating display of different signal strengths. Ex: 
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * [....|....] -73       
 | 
					 | 
				
			||||||
 * Signal 
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * Uncheck the "Autoscroll" box at the bottom of the Serial 
 | 
					 | 
				
			||||||
 * Monitor to manually control the view of the Serial Monitor.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <HamShield.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#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);
 | 
					 | 
				
			||||||
  delay(5); // wait for device to come up
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  analogReference(DEFAULT);
 | 
					 | 
				
			||||||
  Serial.begin(9600);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  Serial.print("Radio status: ");
 | 
					 | 
				
			||||||
  int result = radio.testConnection();
 | 
					 | 
				
			||||||
  Serial.println(result,DEC); 
 | 
					 | 
				
			||||||
  radio.initialize();
 | 
					 | 
				
			||||||
  radio.frequency(446000);
 | 
					 | 
				
			||||||
  radio.setModeReceive();
 | 
					 | 
				
			||||||
  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() {
 | 
					 | 
				
			||||||
   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");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
/* Hamshield
 | 
					/* Hamshield
 | 
				
			||||||
 * Example: Signal Test
 | 
					 * Example: Signal Test
 | 
				
			||||||
 * Plays back the current signal strength level and morses out 
 | 
					 * Transmits current signal strength level and Morses out 
 | 
				
			||||||
 * it's call sign at the end. You will need a HandyTalkie (HT)
 | 
					 * it's call sign at the end. You will need a HandyTalkie (HT)
 | 
				
			||||||
 * to test the output of this example. You will also need to 
 | 
					 * to test the output of this example. You will also need to 
 | 
				
			||||||
 * download the PCM library from 
 | 
					 * download the PCM library from 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue