-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeltec_Base_HellSchreiber_AFSK.ino
88 lines (71 loc) · 2.16 KB
/
Heltec_Base_HellSchreiber_AFSK.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
88
// Turns the 'PRG' button into the power button, long press is off
#define HELTEC_POWER_BUTTON // must be before "#include <heltec_unofficial.h>"
// creates 'radio', 'display' and 'button' instances
#include <heltec_unofficial.h>
// create AFSK client instance using the FSK module
// this requires connection to the module direct
// input pin, here connected to Arduino pin 5
// SX127x/RFM9x: DIO2
// RF69: DIO2
// SX1231: DIO2
// CC1101: GDO2
// Si443x/RFM2x: GPIO
// SX126x/LLCC68: DIO2
AFSKClient audio(&radio, 13);
// create Hellschreiber client instance using the AFSK instance
HellClient hell(&audio);
#define FREQUENCY 869.525
void setup() {
heltec_setup();
both.print("SX12xx Init ... ");
int state = radio.beginFSK(FREQUENCY); // 869.525
if (state == RADIOLIB_ERR_NONE) {
both.println(F("FSK ok!"));
} else {
both.print("failed, code ");
both.println(state);
while (true) { delay(10); }
}
// initialize HellSchreiber client
both.print("Hell Init ... ");
// tone frequency: 900 Hz
// speed: 25 words per minute = 122.5 baud
state = hell.begin(900, 122.5);
if (state == RADIOLIB_ERR_NONE) {
both.println(F("Hell ok!"));
} else {
both.print(F("Failed, code "));
both.println(state);
while (true) { delay(10); }
}
// Battery
float vbat = heltec_vbat();
both.printf("Vbat: %.2fV (%d%%)\n", vbat, heltec_battery_percent(vbat));
}
int tijd = 0;
void loop() {
heltec_loop();
both.println("Sending Hell AFSK data ... ");
int i, len;
char hellstring[] = "PA9MG TEST A QUICK BROWN FOX JUMPS OVER THE LAZY DOG K";
len = strlen(hellstring);
for (i = 0; i < len; i++) {
hell.write(hellstring[i]);
heltec_led(50);
delay(50);
heltec_led(0);
}
both.println("HellSchreiber AFSK done!");
tijd = tijd + 60000;
both.print("Seconds pause: ");
both.println(tijd / 1000);
// carrier did not stop!
int state = radio.beginFSK(FREQUENCY);
if (state == RADIOLIB_ERR_NONE) {
both.println("Carrier reset");
} else {
both.printf("Fail, code: %i\n", state);
}
// wait for few seconds before transmitting again
delay(tijd);
}