-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathESP32-Initiator.ino
More file actions
50 lines (36 loc) · 1.05 KB
/
Copy pathESP32-Initiator.ino
File metadata and controls
50 lines (36 loc) · 1.05 KB
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
//-- For Predator EYE --
#include <AlfredoCRSF.h>
#include <HardwareSerial.h>
#define PIN_RX 35
#define PIN_TX -1
#define PIN_OUT_CH7 25
#define PIN_OUT_CH9 26
HardwareSerial crsfSerial(1);
AlfredoCRSF crsf;
unsigned long lastPrint = 0;
void setup() {
Serial.begin(115200);
crsfSerial.begin(CRSF_BAUDRATE, SERIAL_8N1, PIN_RX, PIN_TX);
delay(100);
crsf.begin(crsfSerial);
pinMode(PIN_OUT_CH7, OUTPUT);
pinMode(PIN_OUT_CH9, OUTPUT);
}
void loop() {
crsf.update();
if (millis() - lastPrint >= 100) {
lastPrint = millis();
const crsf_channels_t* ch = crsf.getChannelsPacked();
if (ch != nullptr) {
// ----- GPIO control -----
digitalWrite(PIN_OUT_CH7, (ch->ch7 > 1000) ? HIGH : LOW);
digitalWrite(PIN_OUT_CH9, (ch->ch9 > 1000) ? HIGH : LOW);
// ----- print channels -----
Serial.printf(
"\rCH0=%4d CH1=%4d CH2=%4d CH3=%4d CH4=%4d CH5=%4d CH6=%4d CH7=%4d CH8=%4d CH9=%4d\n",
ch->ch0, ch->ch1, ch->ch2, ch->ch3, ch->ch4,
ch->ch5, ch->ch6, ch->ch7, ch->ch8, ch->ch9
);
}
}
}