Use new custom switch framework.

This commit is contained in:
Richard Li
2025-01-24 19:00:12 +01:00
committed by Malte Langermann
parent f8e70c6a67
commit dfdbdf023c
3 changed files with 8 additions and 72 deletions
+4 -4
View File
@@ -56,12 +56,12 @@ __weak SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx)
return _switch_offsets[cat][idx].type;
}
__weak uint8_t boardGetMaxSwitches() { return n_switches; }
__weak uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
uint8_t boardGetMaxSwitches() { return n_switches; }
uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
__weak swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
__weak switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
{
// TODO: find a solution for FLEX switches so they can be displayed on main view
if (idx >= DIM(_switch_display)) return {0, 0};
+2 -4
View File
@@ -63,10 +63,8 @@
#define TRIMS_GPIO_PIN_T2R
// Switches
#define SWITCHES_GPIO_REG_A
#define SWITCHES_GPIO_PIN_A
#define SWITCHES_GPIO_REG_B
#define SWITCHES_GPIO_PIN_B
#define SWITCHES_A_2POS
#define SWITCHES_B_2POS
// Keys
#define KEYS_GPIO_PIN_ENTER
+2 -64
View File
@@ -30,51 +30,7 @@
#include <stdlib.h>
#define __weak __attribute__((weak))
static const stm32_switch_t _switch_defs[] = {
/* {
"SW1L",
nullptr, 0,
nullptr, 0,
SWITCH_HW_2POS, 0
},
{
"SW1R",
nullptr, 0,
nullptr, 0,
SWITCH_HW_2POS, 0
},*/
{
"SW2",
nullptr, 0,
nullptr, 0,
SWITCH_HW_2POS, 0
},
{
"SW3",
nullptr, 0,
nullptr, 0,
SWITCH_HW_2POS, 0
}
};
constexpr uint8_t n_switches = 2;
constexpr uint8_t n_fct_switches = 0;
constexpr swconfig_t _switch_default_config = (swconfig_t)0
| ((swconfig_t)SWITCH_2POS << (0 * SW_CFG_BITS))
| ((swconfig_t)SWITCH_2POS << (1 * SW_CFG_BITS))
/* | ((swconfig_t)SWITCH_2POS << (2 * SW_CFG_BITS))
| ((swconfig_t)SWITCH_2POS << (3 * SW_CFG_BITS))*/
;
const switch_display_pos_t _switch_display[] = {
{ 0, 0 },
{ 0, 0 },
/* { 0, 0 },
{ 0, 0 },*/
};
static const char _switch_names[][4] = {"SW2", "SW3"};
SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx)
{
@@ -101,23 +57,5 @@ SwitchHwPos boardSwitchGetPosition(uint8_t cat, uint8_t idx)
const char* boardSwitchGetName(uint8_t cat, uint8_t idx)
{
return _switch_defs[idx].name;
}
SwitchHwType boardSwitchGetType(uint8_t cat, uint8_t idx)
{
return _switch_defs[idx].type;
}
uint8_t boardGetMaxSwitches() { return n_switches; }
uint8_t boardGetMaxFctSwitches() { return n_fct_switches; }
swconfig_t boardSwitchGetDefaultConfig() { return _switch_default_config; }
switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
{
// TODO: find a solution for FLEX switches so they can be displayed on main view
if (idx >= DIM(_switch_display)) return {0, 0};
return _switch_display[idx];
return _switch_names[idx];
}