mirror of
https://github.com/okalachev/flix.git
synced 2025-08-17 17:16:10 +00:00
Use FlixPeriph library for SBUS
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
float t = NAN; // current step time, s
|
||||
float dt; // time delta from previous step, s
|
||||
float loopFreq; // loop frequency, Hz
|
||||
uint16_t channels[16]; // raw rc channels
|
||||
int16_t channels[16]; // raw rc channels
|
||||
float controls[RC_CHANNELS]; // normalized controls in range [-1..1] ([0..1] for throttle)
|
||||
Vector rates; // angular rates, rad/s
|
||||
Vector acc; // accelerometer data, m/s/s
|
||||
|
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