Add rx num handling to CRSF (#7881)

This commit is contained in:
3djc
2020-08-28 17:01:13 +02:00
committed by GitHub
parent 476e1e9d8d
commit 3dfb27f220
13 changed files with 125 additions and 20 deletions
+24 -1
View File
@@ -28,6 +28,23 @@
#define CROSSFIRE_CENTER_CH_OFFSET(ch) (0)
#endif
uint8_t createCrossfireModelIDFrame(uint8_t * frame)
{
uint8_t * buf = frame;
*buf++ = UART_SYNC; /* device address */
*buf++ = 8; /* frame length */
*buf++ = COMMAND_ID; /* cmd type */
*buf++ = MODULE_ADDRESS; /* Destination Address */
*buf++ = RADIO_ADDRESS; /* Origin Address */
*buf++ = SUBCOMMAND_CRSF; /* sub command */
*buf++ = COMMAND_MODEL_SELECT_ID; /* command of set model/receiver id */
*buf++ = g_model.header.modelId[EXTERNAL_MODULE]; /* model ID */
*buf++ = crc8_BA(frame + 2, 6);
*buf++ = crc8(frame + 2, 7);
return buf - frame;
}
// Range for pulses (channels output) is [-1024:+1024]
uint8_t createCrossfireChannelsFrame(uint8_t * frame, int16_t * pulses)
{
@@ -65,7 +82,13 @@ void setupPulsesCrossfire()
else
#endif
{
extmodulePulsesData.crossfire.length = createCrossfireChannelsFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]);
if (moduleState[EXTERNAL_MODULE].counter == CRSF_FRAME_MODELID) {
extmodulePulsesData.crossfire.length = createCrossfireModelIDFrame(pulses);
moduleState[EXTERNAL_MODULE].counter = CRSF_FRAME_MODELID_SENT;
}
else {
extmodulePulsesData.crossfire.length = createCrossfireChannelsFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]);
}
}
}
}