imporved sbus input handling on TX module
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
* DEVICE_MODE_TX
|
||||
* DEVICE_MODE_RX
|
||||
*/
|
||||
// #define DEVICE_MODE_TX
|
||||
#define DEVICE_MODE_RX
|
||||
#define DEVICE_MODE_TX
|
||||
// #define DEVICE_MODE_RX
|
||||
|
||||
// #define FEATURE_TX_OLED
|
||||
// #define FORCE_TX_WITHOUT_INPUT
|
||||
|
||||
@@ -327,6 +327,19 @@ void loop(void)
|
||||
uint32_t currentMillis = millis();
|
||||
|
||||
/*
|
||||
* If we are not receiving SBUS frames from radio, try to restart serial
|
||||
*/
|
||||
#ifdef DEVICE_MODE_TX
|
||||
|
||||
static uint32_t serialRestartMillis = 0;
|
||||
|
||||
if (!txInput.isReceiving() && serialRestartMillis + 100 < currentMillis) {
|
||||
txInput.restart();
|
||||
serialRestartMillis = currentMillis;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This routine handles resync of TX/RX while hoppping frequencies
|
||||
*/
|
||||
#ifdef DEVICE_MODE_RX
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define SBUS_STATE_FAILSAFE 0x08
|
||||
#define SBUS_STATE_SIGNALLOSS 0x04
|
||||
|
||||
#define SBUS_IS_RECEIVING_THRESHOLD 250 //If there is no SBUS input for 250ms, assume connection is broken
|
||||
#define SBUS_IS_RECEIVING_THRESHOLD 125 //If there is no SBUS input for 125ms, assume connection is broken
|
||||
|
||||
/*
|
||||
Precomputed mapping from 990-2010 to 173:1811
|
||||
@@ -93,7 +93,13 @@ void SbusInput::loop(void)
|
||||
|
||||
void SbusInput::start(void)
|
||||
{
|
||||
_serial.begin(100000, SERIAL_8N2);
|
||||
_serial.begin(100000, SERIAL_8N2);
|
||||
}
|
||||
|
||||
void SbusInput::restart(void)
|
||||
{
|
||||
_serial.end();
|
||||
start();
|
||||
}
|
||||
|
||||
void SbusInput::sbusRead() {
|
||||
|
||||
@@ -11,6 +11,7 @@ class SbusInput : public TxInput
|
||||
public:
|
||||
SbusInput(HardwareSerial &serial);
|
||||
void start(void);
|
||||
void restart(void);
|
||||
void loop(void);
|
||||
bool isReceiving(void);
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user