-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumd.ino
More file actions
48 lines (38 loc) · 1 KB
/
Sumd.ino
File metadata and controls
48 lines (38 loc) · 1 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
#include <ESP8266WiFi.h>
#include "SumdRx.h"
//remote control status
bool failSafe=true;
SumdRx *sumdDecoder;
void setup() {
//Start communication to serial port
Serial.begin(115200);
delay(100);
//Attach SUMD decoder to the serial port
sumdDecoder= new SumdRx();
}
void loop()
{
uint8_t index;
//process sumd input
//due to lead time from previous decoding, buffer may overflow and being corrupted -> reset
sumdDecoder->reset();
while(Serial.available() > 0) sumdDecoder->add(Serial.read());
//display failsafe status on console
if (failSafe && !sumdDecoder->failSafe()) {
failSafe=false;
Serial.println("Reception OK");
}
else if (!failSafe && sumdDecoder->failSafe()) {
failSafe=true;
Serial.println("Reception Lost");
}
//display channel status
if (!sumdDecoder->failSafe()) {
for(index=0;index<sumdDecoder->channelRx;index++) {
Serial.print(sumdDecoder->channel[index]);
Serial.print(" ");
}
Serial.println();
}
delay(100);
}