1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 00:05:33 +03:00

Rx should be processed at least once

This is to prevent an extreme edge case on slow boards to make sure rx
update still occurs
This commit is contained in:
borisbstyle 2015-10-01 15:11:04 +02:00
parent b523ff1557
commit 4dcd8354da

View file

@ -96,7 +96,7 @@ enum {
/* IBat monitoring interval (in microseconds) - 6 default looptimes */
#define IBATINTERVAL (6 * 3500)
#define GYRO_WATCHDOG_DELAY 100 // Watchdog for boards without interrupt for gyro
#define PREVENT_RX_PROCESS_PRE_LOOP_TRIGGER 90 // Prevent RX processing before expected loop trigger
#define PREVENT_RX_PROCESS_PRE_LOOP_TRIGGER 80 // Prevent RX processing before expected loop trigger
uint32_t currentTime = 0;
uint32_t previousTime = 0;
@ -730,6 +730,7 @@ void filterRc(void){
void loop(void)
{
static uint32_t loopTime;
static bool haveProcessedRxOnceBeforeLoop = false;
#if defined(BARO) || defined(SONAR)
static bool haveProcessedAnnexCodeOnce = false;
@ -737,9 +738,10 @@ void loop(void)
updateRx(currentTime);
if (shouldProcessRx(currentTime) && !((int32_t)(currentTime - (loopTime - PREVENT_RX_PROCESS_PRE_LOOP_TRIGGER)) >= 0)) {
if (shouldProcessRx(currentTime) && (!((int32_t)(currentTime - (loopTime - PREVENT_RX_PROCESS_PRE_LOOP_TRIGGER)) >= 0) || (haveProcessedRxOnceBeforeLoop))) {
processRx();
isRXDataNew = true;
haveProcessedRxOnceBeforeLoop = true;
#ifdef BARO
// the 'annexCode' initialses rcCommand, updateAltHoldState depends on valid rcCommand data.
@ -778,6 +780,8 @@ void loop(void)
loopTime = currentTime + targetLooptime;
haveProcessedRxOnceBeforeLoop = false;
// Determine current flight mode. When no acc needed in pid calculations we should only read gyro to reduce latency
if (!flightModeFlags) {
imuUpdate(&currentProfile->accelerometerTrims, ONLY_GYRO); // When no level modes active read only gyro