imporved sbus input handling on TX module

This commit is contained in:
Pawel Spychalski (DzikuVx)
2018-04-19 16:24:17 +02:00
parent 4cae36715d
commit a651fcc05e
4 changed files with 24 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -96,6 +96,12 @@ void SbusInput::start(void)
_serial.begin(100000, SERIAL_8N2);
}
void SbusInput::restart(void)
{
_serial.end();
start();
}
void SbusInput::sbusRead() {
static byte buffer[25];
static byte buffer_index = 0;

View File

@@ -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: