mirror of
https://github.com/okalachev/flix.git
synced 2026-01-12 05:57:52 +00:00
Use FlixPeriph library for SBUS
This commit is contained in:
10
flix/rc.ino
10
flix/rc.ino
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <SBUS.h>
|
||||
|
||||
// NOTE: use `cr` command and replace with the actual values
|
||||
// NOTE: use 'cr' command to calibrate the RC and put the values here
|
||||
int channelNeutral[] = {995, 883, 200, 972, 512, 512};
|
||||
int channelMax[] = {1651, 1540, 1713, 1630, 1472, 1472};
|
||||
|
||||
@@ -14,14 +14,12 @@ SBUS RC(Serial2);
|
||||
void setupRC() {
|
||||
Serial.println("Setup RC");
|
||||
RC.begin();
|
||||
Serial2.setRxInvert(true); // SBUS uses inverted signal
|
||||
}
|
||||
|
||||
void readRC() {
|
||||
bool failsafe, lostFrame;
|
||||
if (RC.read(channels, &failsafe, &lostFrame)) {
|
||||
if (failsafe) { return; } // TODO:
|
||||
if (lostFrame) { return; }
|
||||
if (RC.read()) {
|
||||
SBUSData data = RC.data();
|
||||
memcpy(channels, data.ch, sizeof(channels)); // copy channels data
|
||||
normalizeRC();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user