feat(radio): refactor of switch handling to better support customisable switches (#6095)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
3djc
elecpower
parent
28833f42e6
commit
0c8c39b134
@@ -40,13 +40,7 @@ static timer_handle_t _refresh_timer = TIMER_INITIALIZER;
|
||||
|
||||
void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
#if defined(SIXPOS_SWITCH_INDEX)
|
||||
ws2812_set_color(led + 6, r, g, b);
|
||||
#elif defined(RGB_LED_OFFSET)
|
||||
ws2812_set_color(led + RGB_LED_OFFSET, r, g, b);
|
||||
#else
|
||||
ws2812_set_color(led, r, g, b);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t rgbGetLedColor(uint8_t led)
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
*/
|
||||
|
||||
#include "hal/switch_driver.h"
|
||||
#include "bsp_io.h"
|
||||
#include "stm32_switch_driver.h"
|
||||
#include "stm32_gpio_driver.h"
|
||||
|
||||
#include "drivers/pca95xx.h"
|
||||
|
||||
#include "definitions.h"
|
||||
#include "myeeprom.h"
|
||||
|
||||
@@ -37,30 +38,33 @@ __weak void boardInitSwitches()
|
||||
_init_switches();
|
||||
}
|
||||
|
||||
__weak SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
__weak SwitchHwPos boardSwitchGetPosition(uint8_t idx)
|
||||
{
|
||||
const stm32_switch_t* sw = &_switch_offsets[cat][idx];
|
||||
if(sw->type != SWITCH_HW_ADC && sw->GPIOx_high == nullptr)
|
||||
return bsp_get_switch_position(sw, cat, idx);
|
||||
|
||||
const stm32_switch_t* sw = &_switch_defs[idx];
|
||||
return stm32_switch_get_position(sw);
|
||||
}
|
||||
|
||||
__weak const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx)
|
||||
__weak const char* boardSwitchGetName(uint8_t idx)
|
||||
{
|
||||
return _switch_offsets[cat][idx].name;
|
||||
return _switch_defs[idx].name;
|
||||
}
|
||||
|
||||
__weak SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx)
|
||||
__weak SwitchHwType boardSwitchGetType(uint8_t idx)
|
||||
{
|
||||
return _switch_offsets[cat][idx].type;
|
||||
return _switch_defs[idx].type;
|
||||
}
|
||||
|
||||
const stm32_switch_t* boardGetSwitchDef(uint8_t idx) { return &_switch_defs[idx]; }
|
||||
|
||||
uint8_t boardGetMaxSwitches() { return n_switches; }
|
||||
uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
bool boardIsCustomSwitch(uint8_t idx) { return _switch_defs[idx].isCustomSwitch; }
|
||||
uint8_t boardGetCustomSwitchIdx(uint8_t idx) { return _switch_defs[idx].customSwitchIdx; }
|
||||
#endif
|
||||
|
||||
swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
|
||||
SwitchConfig boardSwitchGetDefaultConfig(uint8_t idx) { return _switch_defs[idx].defaultType; }
|
||||
|
||||
#if !defined(COLORLCD)
|
||||
switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
|
||||
{
|
||||
// TODO: find a solution for FLEX switches so they can be displayed on main view
|
||||
@@ -68,3 +72,4 @@ switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
|
||||
|
||||
return _switch_display[idx];
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user