Spektrum SRXL Telemetry tidying.
This commit is contained in:
parent
66657486e1
commit
064a196c06
|
@ -150,24 +150,15 @@ static uint8_t spektrumFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig)
|
|||
}
|
||||
|
||||
#if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SRXL)
|
||||
if (srxlEnabled) {
|
||||
if (telemetryBufLen) {
|
||||
if ((spekFrame[2] & 0x80) == 0) {
|
||||
if (srxlEnabled && (spekFrame[2] & 0x80) == 0) {
|
||||
telemetryFrameRequestedUs = currentTimeUs;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Trigger tm data collection if buffer is empty.
|
||||
srxlCollectTelemetryNow();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
result = RX_FRAME_COMPLETE;
|
||||
}
|
||||
|
||||
#if defined(USE_TELEMETRY) && defined(USE_TELEMETRY_SRXL)
|
||||
if (telemetryFrameRequestedUs && cmpTimeUs(currentTimeUs, telemetryFrameRequestedUs) >= SPEKTRUM_TELEMETRY_FRAME_DELAY_US) {
|
||||
if (telemetryBufLen && telemetryFrameRequestedUs && cmpTimeUs(currentTimeUs, telemetryFrameRequestedUs) >= SPEKTRUM_TELEMETRY_FRAME_DELAY_US) {
|
||||
telemetryFrameRequestedUs = 0;
|
||||
|
||||
result = (result & ~RX_FRAME_PENDING) | RX_FRAME_PROCESSING_REQUIRED;
|
||||
|
@ -324,13 +315,20 @@ static bool spektrumProcessFrame(const rxRuntimeConfig_t *rxRuntimeConfig)
|
|||
if (telemetryBufLen > 0) {
|
||||
serialWriteBuf(serialPort, telemetryBuf, telemetryBufLen);
|
||||
telemetryBufLen = 0; // reset telemetry buffer
|
||||
|
||||
srxlCollectTelemetryNow();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool srxlTelemetryBufferEmpty()
|
||||
{
|
||||
if (telemetryBufLen == 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void srxlRxWriteTelemetryData(const void *data, int len)
|
||||
{
|
||||
len = MIN(len, (int)sizeof(telemetryBuf));
|
||||
|
|
|
@ -51,5 +51,6 @@ extern uint8_t rssi_channel; // Stores the RX RSSI channel.
|
|||
void spektrumBind(rxConfig_t *rxConfig);
|
||||
bool spektrumInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig);
|
||||
|
||||
bool srxlTelemetryBufferEmpty();
|
||||
void srxlRxWriteTelemetryData(const void *data, int len);
|
||||
bool srxlRxIsActive(void);
|
||||
|
|
|
@ -76,13 +76,6 @@
|
|||
|
||||
static bool srxlTelemetryEnabled;
|
||||
static uint8_t srxlFrame[SRXL_FRAME_SIZE_MAX];
|
||||
static bool srxlTelemetryNow = false;
|
||||
|
||||
void srxlCollectTelemetryNow(void)
|
||||
{
|
||||
srxlTelemetryNow = true;
|
||||
}
|
||||
|
||||
|
||||
static void srxlInitializeFrame(sbuf_t *dst)
|
||||
{
|
||||
|
@ -517,11 +510,8 @@ bool checkSrxlTelemetryState(void)
|
|||
*/
|
||||
void handleSrxlTelemetry(timeUs_t currentTimeUs)
|
||||
{
|
||||
if (!srxlTelemetryNow) {
|
||||
return;
|
||||
}
|
||||
|
||||
srxlTelemetryNow = false;
|
||||
processSrxl(currentTimeUs);
|
||||
if (srxlTelemetryBufferEmpty()) {
|
||||
processSrxl(currentTimeUs);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue