-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRadioCtrl.ino
87 lines (65 loc) · 1.65 KB
/
RadioCtrl.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* Radio Controller
*
* by Daniel Hjort, 2013.
*/
#include <Encoder.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include "RadioMMI.h"
#include "VFO.h"
// Change these pin numbers to the pins connected to your encoder.
// Best Performance: both pins have interrupt capability
// Good Performance: only the first pin has interrupt capability
// Low Performance: neither pin has interrupt capability
Encoder knob(3, 4);
#define I2C_ADDR 0x27 // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define DIT_PIN 6
#define DAH_PIN 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
RadioMMI mmi;
VFO vfo;
void setup() {
// Setup LCD
lcd.begin (16,2);
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home(); // go home
lcd.print("RadioCtrl v0.1");
lcd.setCursor(0, 1); // go to the 2nd line
lcd.print("by Daniel Hjort");
Serial.begin(9600);
Serial.println("RadioCtrl v1.0");
Serial.println("by Daniel Hjort");
mmi.begin(&lcd, &knob, DIT_PIN, DAH_PIN);
vfo.begin(mmi.getFreq());
}
void loop() {
mmi.readInput();
if (Serial.available()) {
// Read command
//Serial.read();
}
vfo.setFrequency(mmi.getFreq());
if (mmi.isPaddleConnected()) {
// Update keyer state
} else {
if (mmi.ditDown()) {
// key down
mmi.setIsInTx(true);
} else {
// key up
mmi.setIsInTx(false);
}
}
mmi.updateUi();
}