Add Ghost module config tool (#8090)

* Ghost menu handling
This commit is contained in:
3djc
2020-11-14 14:57:33 +01:00
committed by GitHub
parent 4de7630286
commit 4c96dbad4e
27 changed files with 374 additions and 2 deletions
+29 -1
View File
@@ -20,6 +20,31 @@
#include "opentx.h"
uint8_t createGhostMenuControlFrame(uint8_t * frame, int16_t * pulses)
{
moduleState[EXTERNAL_MODULE].counter = GHST_FRAME_CHANNEL;
uint8_t * buf = frame;
#if SPORT_MAX_BAUDRATE < 400000
*buf++ = g_eeGeneral.telemetryBaudrate == GHST_TELEMETRY_RATE_400K ? GHST_ADDR_MODULE_SYM : GHST_ADDR_MODULE_ASYM;
#else
*buf++ = GHST_ADDR_MODULE_SYM;
#endif
*buf++ = GHST_UL_RC_CHANS_SIZE;
uint8_t * crc_start = buf;
*buf++ = GHST_UL_MENU_CTRL;
*buf++ = reusableBuffer.ghostMenu.buttonAction; // Joystick states, Up, Down, Left, Right, Press
*buf++ = reusableBuffer.ghostMenu.menuAction; // menu control, open, close, etc.
for (uint8_t i = 0; i < 8; i++)
*buf++ = 0; // padding to make this the same size as the pulses packet
*buf++ = crc8(crc_start, GHST_UL_RC_CHANS_SIZE - 1);
return buf - frame;
}
// Range for pulses (channels output) is [-1024:+1024]
uint8_t createGhostChannelsFrame(uint8_t * frame, int16_t * pulses)
{
@@ -89,6 +114,9 @@ void setupPulsesGhost()
{
if (telemetryProtocol == PROTOCOL_TELEMETRY_GHOST) {
uint8_t * pulses = extmodulePulsesData.ghost.pulses;
extmodulePulsesData.ghost.length = createGhostChannelsFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]);
if (moduleState[EXTERNAL_MODULE].counter == GHST_MENU_CONTROL)
extmodulePulsesData.ghost.length = createGhostMenuControlFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]);
else
extmodulePulsesData.ghost.length = createGhostChannelsFrame(pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]);
}
}