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

Renamed the existing RC smoothing related functionality.

This commit is contained in:
mikeller 2020-02-23 12:12:58 +13:00
parent c29b125a59
commit 53318e5e4d
10 changed files with 26 additions and 26 deletions

View file

@ -167,7 +167,7 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs)
}
timeDelta_t rxFrameDeltaUs;
if (!rxGetFrameDelta(&rxFrameDeltaUs)) {
if (!rxTryGetFrameDelta(&rxFrameDeltaUs)) {
rxFrameDeltaUs = cmpTimeUs(currentTimeUs, lastRxTimeUs); // calculate a delta here if not supplied by the protocol
}
lastRxTimeUs = currentTimeUs;

View file

@ -369,7 +369,7 @@ void crsfRxSendTelemetryData(void)
}
}
static timeUs_t crsfFrameTimeUs(void)
static timeUs_t crsfFrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -387,7 +387,7 @@ bool crsfRxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = crsfReadRawRC;
rxRuntimeState->rcFrameStatusFn = crsfFrameStatus;
rxRuntimeState->rcFrameTimeUsFn = crsfFrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = crsfFrameTimeUsOrZeroFn;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
if (!portConfig) {

View file

@ -206,7 +206,7 @@ static uint16_t ibusReadRawRC(const rxRuntimeState_t *rxRuntimeState, uint8_t ch
return ibusChannelData[chan];
}
static timeUs_t ibusFrameTimeUs(void)
static timeUs_t ibusFrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -223,7 +223,7 @@ bool ibusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = ibusReadRawRC;
rxRuntimeState->rcFrameStatusFn = ibusFrameStatus;
rxRuntimeState->rcFrameTimeUsFn = ibusFrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = ibusFrameTimeUsOrZeroFn;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
if (!portConfig) {

View file

@ -247,7 +247,7 @@ static uint16_t jetiExBusReadRawRC(const rxRuntimeState_t *rxRuntimeState, uint8
return (jetiExBusChannelData[chan]);
}
static timeUs_t jetiExBusFrameTimeUs(void)
static timeUs_t jetiExBusFrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -263,7 +263,7 @@ bool jetiExBusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = jetiExBusReadRawRC;
rxRuntimeState->rcFrameStatusFn = jetiExBusFrameStatus;
rxRuntimeState->rcFrameTimeUsFn = jetiExBusFrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = jetiExBusFrameTimeUsOrZeroFn;
jetiExBusFrameReset();

View file

@ -873,20 +873,20 @@ bool isRssiConfigured(void)
return rssiSource != RSSI_SOURCE_NONE;
}
bool rxGetFrameDelta(timeDelta_t *deltaUs)
bool rxTryGetFrameDelta(timeDelta_t *deltaUs)
{
static timeUs_t previousFrameTimeUs = 0;
static timeUs_t previousFrameTimeUsOrZero = 0;
bool result = false;
*deltaUs = 0;
if (rxRuntimeState.rcFrameTimeUsFn) {
const timeUs_t frameTimeUs = rxRuntimeState.rcFrameTimeUsFn();
if (frameTimeUs) {
if (previousFrameTimeUs) {
*deltaUs = cmpTimeUs(frameTimeUs, previousFrameTimeUs);
if (rxRuntimeState.rcFrameTimeUsOrZeroFn) {
const timeUs_t frameTimeUsOrZero = rxRuntimeState.rcFrameTimeUsOrZeroFn();
if (frameTimeUsOrZero) {
if (previousFrameTimeUsOrZero) {
*deltaUs = cmpTimeUs(frameTimeUsOrZero, previousFrameTimeUsOrZero);
result = true;
}
previousFrameTimeUs = frameTimeUs;
previousFrameTimeUsOrZero = frameTimeUsOrZero;
}
}
return result; // No frame delta function available for protocol type or frames have stopped

View file

@ -125,7 +125,7 @@ struct rxRuntimeState_s;
typedef uint16_t (*rcReadRawDataFnPtr)(const struct rxRuntimeState_s *rxRuntimeState, uint8_t chan); // used by receiver driver to return channel data
typedef uint8_t (*rcFrameStatusFnPtr)(struct rxRuntimeState_s *rxRuntimeState);
typedef bool (*rcProcessFrameFnPtr)(const struct rxRuntimeState_s *rxRuntimeState);
typedef timeUs_t (*rcGetFrameTimeUsFnPtr)(void); // used to retrieve the timestamp in microseconds for the last channel data frame
typedef timeUs_t (*rcGetFrameTimeUsOrZeroFnPtr)(void); // used to retrieve the timestamp in microseconds for the last channel data frame, or 0, depending on suitablilty of the value for RC smoothing
typedef enum {
RX_PROVIDER_NONE = 0,
@ -144,7 +144,7 @@ typedef struct rxRuntimeState_s {
rcReadRawDataFnPtr rcReadRawFn;
rcFrameStatusFnPtr rcFrameStatusFn;
rcProcessFrameFnPtr rcProcessFrameFn;
rcGetFrameTimeUsFnPtr rcFrameTimeUsFn;
rcGetFrameTimeUsOrZeroFnPtr rcFrameTimeUsOrZeroFn;
uint16_t *channelData;
void *frameData;
} rxRuntimeState_t;
@ -210,4 +210,4 @@ void resumeRxPwmPpmSignal(void);
uint16_t rxGetRefreshRate(void);
bool rxGetFrameDelta(timeDelta_t *deltaUs);
bool rxTryGetFrameDelta(timeDelta_t *deltaUs);

View file

@ -160,7 +160,7 @@ static uint8_t sbusFrameStatus(rxRuntimeState_t *rxRuntimeState)
return frameStatus;
}
static timeUs_t sbusFrameTimeUs(void)
static timeUs_t sbusFrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -188,7 +188,7 @@ bool sbusInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
}
rxRuntimeState->rcFrameStatusFn = sbusFrameStatus;
rxRuntimeState->rcFrameTimeUsFn = sbusFrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = sbusFrameTimeUsOrZeroFn;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
if (!portConfig) {

View file

@ -343,7 +343,7 @@ void srxlRxWriteTelemetryData(const void *data, int len)
}
#endif
static timeUs_t spektrumFrameTimeUs(void)
static timeUs_t spektrumFrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -397,7 +397,7 @@ bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = spektrumReadRawRC;
rxRuntimeState->rcFrameStatusFn = spektrumFrameStatus;
rxRuntimeState->rcFrameTimeUsFn = spektrumFrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = spektrumFrameTimeUsOrZeroFn;
#if defined(USE_TELEMETRY_SRXL)
rxRuntimeState->rcProcessFrameFn = spektrumProcessFrame;
#endif

View file

@ -480,7 +480,7 @@ void srxl2RxWriteData(const void *data, int len)
writeBufferIdx = len;
}
static timeUs_t srxl2FrameTimeUs(void)
static timeUs_t srxl2FrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -503,7 +503,7 @@ bool srxl2RxInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = srxl2ReadRawRC;
rxRuntimeState->rcFrameStatusFn = srxl2FrameStatus;
rxRuntimeState->rcFrameTimeUsFn = srxl2FrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = srxl2FrameTimeUsOrZeroFn;
rxRuntimeState->rcProcessFrameFn = srxl2ProcessFrame;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);

View file

@ -167,7 +167,7 @@ static uint16_t sumdReadRawRC(const rxRuntimeState_t *rxRuntimeState, uint8_t ch
return sumdChannels[chan] / 8;
}
static timeUs_t sumdFrameTimeUs(void)
static timeUs_t sumdFrameTimeUsOrZeroFn(void)
{
const timeUs_t result = lastRcFrameTimeUs;
lastRcFrameTimeUs = 0;
@ -183,7 +183,7 @@ bool sumdInit(const rxConfig_t *rxConfig, rxRuntimeState_t *rxRuntimeState)
rxRuntimeState->rcReadRawFn = sumdReadRawRC;
rxRuntimeState->rcFrameStatusFn = sumdFrameStatus;
rxRuntimeState->rcFrameTimeUsFn = sumdFrameTimeUs;
rxRuntimeState->rcFrameTimeUsOrZeroFn = sumdFrameTimeUsOrZeroFn;
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_RX_SERIAL);
if (!portConfig) {