1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 01:05:21 +03:00

Distribute new bits

Distributing new bits now gives us some room to implement some new functions and overlays without needing to change the data format.

Add 4 bits to functions
Add 2 bits to Overlay (one is used by strobe, aonther one is free)
Add 2 bits to params
This commit is contained in:
Marcelo Bezerra 2022-11-09 20:20:43 +01:00
parent db941f7569
commit 233ee3fd38
2 changed files with 9 additions and 9 deletions

View file

@ -1053,15 +1053,15 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i]; const ledConfig_t *ledConfig = &ledStripConfig()->ledConfigs[i];
uint32_t legacyLedConfig = ledConfig->led_position; uint32_t legacyLedConfig = ledConfig->led_position;
int shiftCount = LED_POS_BITCNT; int shiftCount = 8;
legacyLedConfig |= ledConfig->led_function << shiftCount; legacyLedConfig |= ledConfig->led_function << shiftCount;
shiftCount += LED_FUNCTION_BITCNT; shiftCount += 4;
legacyLedConfig |= (ledConfig->led_overlay & 0x3F) << (shiftCount); legacyLedConfig |= (ledConfig->led_overlay & 0x3F) << (shiftCount);
shiftCount += LED_OVERLAY_BITCNT - 1; shiftCount += 6;
legacyLedConfig |= (ledConfig->led_color) << (shiftCount); legacyLedConfig |= (ledConfig->led_color) << (shiftCount);
shiftCount += LED_COLOR_BITCNT; shiftCount += 4;
legacyLedConfig |= (ledConfig->led_direction) << (shiftCount); legacyLedConfig |= (ledConfig->led_direction) << (shiftCount);
shiftCount += LED_DIRECTION_BITCNT; shiftCount += 6;
legacyLedConfig |= (ledConfig->led_params) << (shiftCount); legacyLedConfig |= (ledConfig->led_params) << (shiftCount);
sbufWriteU32(dst, legacyLedConfig); sbufWriteU32(dst, legacyLedConfig);

View file

@ -29,14 +29,14 @@
#define LED_SPECIAL_COLOR_COUNT 9 #define LED_SPECIAL_COLOR_COUNT 9
#define LED_FUNCTION_OFFSET 8 #define LED_FUNCTION_OFFSET 8
#define LED_OVERLAY_OFFSET 12 #define LED_OVERLAY_OFFSET 16
#define LED_POS_BITCNT 8 #define LED_POS_BITCNT 8
#define LED_FUNCTION_BITCNT 4 #define LED_FUNCTION_BITCNT 8
#define LED_OVERLAY_BITCNT 7 #define LED_OVERLAY_BITCNT 8
#define LED_COLOR_BITCNT 4 #define LED_COLOR_BITCNT 4
#define LED_DIRECTION_BITCNT 6 #define LED_DIRECTION_BITCNT 6
#define LED_PARAMS_BITCNT 4 #define LED_PARAMS_BITCNT 6
#define LED_FLAG_OVERLAY_MASK ((1 << LED_OVERLAY_BITCNT) - 1) #define LED_FLAG_OVERLAY_MASK ((1 << LED_OVERLAY_BITCNT) - 1)