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
@@ -96,24 +96,15 @@ enum {
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
|
||||
#if defined(RADIO_GX12)
|
||||
#define NUM_FUNCTIONS_SWITCHES 8
|
||||
#define NUM_FUNCTIONS_GROUPS 4
|
||||
#else
|
||||
#define NUM_FUNCTIONS_SWITCHES 6
|
||||
#define NUM_FUNCTIONS_GROUPS 3
|
||||
#endif
|
||||
|
||||
#define DEFAULT_FS_CONFIG \
|
||||
(SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_2POS << 6) + \
|
||||
(SWITCH_2POS << 4) + (SWITCH_2POS << 2) + (SWITCH_2POS << 0)
|
||||
|
||||
#define DEFAULT_FS_GROUPS \
|
||||
(1 << 10) + (1 << 8) + (1 << 6) + (1 << 4) + (1 << 2) + \
|
||||
(1 << 0) // Set all FS to group 1 to act like a 6pos
|
||||
|
||||
#define DEFAULT_FS_STARTUP_CONFIG \
|
||||
((FS_START_PREVIOUS << 10) + (FS_START_PREVIOUS << 8) + \
|
||||
(FS_START_PREVIOUS << 6) + (FS_START_PREVIOUS << 4) + \
|
||||
(FS_START_PREVIOUS << 2) + \
|
||||
(FS_START_PREVIOUS << 0)) // keep last state by default
|
||||
|
||||
#else
|
||||
#else //FUNCTION_SWITCHES
|
||||
|
||||
#define NUM_FUNCTIONS_SWITCHES 0
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/switch_driver.h"
|
||||
#include "stm32_switch_driver.h"
|
||||
|
||||
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx) {return SWITCH_HW_MID;}
|
||||
@@ -19,19 +19,24 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "bsp_io.h"
|
||||
#include "hal/switch_driver.h"
|
||||
#include "drivers/pca95xx.h"
|
||||
#include "stm32_i2c_driver.h"
|
||||
#include "timers_driver.h"
|
||||
#include "delays_driver.h"
|
||||
#include "stm32_ws2812.h"
|
||||
#include "stm32_switch_driver.h"
|
||||
|
||||
#include "os/async.h"
|
||||
#include "os/timer.h"
|
||||
|
||||
#include "myeeprom.h"
|
||||
|
||||
#define IO_INT_GPIO GPIO_PIN(GPIOE, 14)
|
||||
#define IO_RESET_GPIO GPIO_PIN(GPIOE, 15)
|
||||
|
||||
extern const stm32_switch_t* boardGetSwitchDef(uint8_t idx);
|
||||
|
||||
struct bsp_io_expander {
|
||||
pca95xx_t exp;
|
||||
uint32_t mask;
|
||||
@@ -79,8 +84,8 @@ static void _poll_switches(void *param1, uint32_t trigger_source)
|
||||
timer_reset(&_poll_timer);
|
||||
}
|
||||
|
||||
bsp_io_read_switches();
|
||||
bsp_io_read_fs_switches();
|
||||
_read_io_expander(&_io_switches);
|
||||
_read_io_expander(&_io_fs_switches);
|
||||
}
|
||||
|
||||
static void _io_int_handler()
|
||||
@@ -126,90 +131,41 @@ int bsp_io_init()
|
||||
gpio_init(IO_RESET_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_set(IO_RESET_GPIO);
|
||||
|
||||
bsp_io_read_switches();
|
||||
bsp_io_read_fs_switches();
|
||||
_read_io_expander(&_io_switches);
|
||||
_read_io_expander(&_io_fs_switches);
|
||||
|
||||
start_poll_timer();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t bsp_io_read_switches()
|
||||
{
|
||||
return _read_io_expander(&_io_switches);
|
||||
}
|
||||
|
||||
uint32_t bsp_io_read_fs_switches()
|
||||
{
|
||||
return _read_io_expander(&_io_fs_switches);
|
||||
}
|
||||
|
||||
void boardInitSwitches()
|
||||
{
|
||||
bsp_io_init();
|
||||
}
|
||||
|
||||
struct bsp_io_sw_def {
|
||||
uint32_t pin_high;
|
||||
uint32_t pin_low;
|
||||
};
|
||||
|
||||
static constexpr uint32_t RGB_OFFSET = (1 << 16); // first after bspio pins
|
||||
static uint16_t soft2POSLogicalState = 0xFFFF;
|
||||
|
||||
static const bsp_io_sw_def _switch_defs[] = {
|
||||
{ SWITCH_A, RGB_OFFSET + 7 },
|
||||
{ SWITCH_B_H, SWITCH_B_L },
|
||||
{ SWITCH_C_H, SWITCH_C_L },
|
||||
{ SWITCH_D, RGB_OFFSET + 6 },
|
||||
{ SWITCH_E_H, SWITCH_E_L },
|
||||
{ SWITCH_F_H, SWITCH_F_L },
|
||||
{ SWITCH_G, 0 },
|
||||
{ SWITCH_H, 0 },
|
||||
};
|
||||
|
||||
static SwitchHwPos _get_switch_pos(uint8_t idx)
|
||||
{
|
||||
static uint32_t oldState = 0;
|
||||
SwitchHwPos pos = SWITCH_HW_UP;
|
||||
const bsp_io_sw_def* def = &_switch_defs[idx];
|
||||
|
||||
const stm32_switch_t* def = boardGetSwitchDef(idx);
|
||||
uint32_t state = _io_switches.state;
|
||||
|
||||
if (def->pin_low > RGB_OFFSET) {
|
||||
// Potential soft 2pos
|
||||
if ((SWITCH_CONFIG(idx) == SWITCH_TOGGLE)) {
|
||||
if ((state & def->pin_high) == 0) {
|
||||
pos = SWITCH_HW_DOWN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((state & def->pin_high) == 0) && ((state & def->pin_high) != (oldState & def->pin_high))) {
|
||||
soft2POSLogicalState ^= def->pin_high;
|
||||
}
|
||||
if ((soft2POSLogicalState & def->pin_high) == 0) {
|
||||
pos = SWITCH_HW_DOWN;
|
||||
}
|
||||
else {
|
||||
pos = SWITCH_HW_UP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (pos == SWITCH_HW_UP) {
|
||||
ws2812_set_color(def->pin_low - RGB_OFFSET, 0x0, 0x0, 0x0);
|
||||
if (def->isCustomSwitch) {
|
||||
if ((state & def->Pin_high) == 0) {
|
||||
return SWITCH_HW_DOWN;
|
||||
} else {
|
||||
ws2812_set_color(def->pin_low - RGB_OFFSET, 0xFF, 0xFF, 0xFF);
|
||||
return SWITCH_HW_UP;
|
||||
}
|
||||
}
|
||||
else if (!def->pin_low) {
|
||||
else if (!def->Pin_low) {
|
||||
// 2POS switch
|
||||
if ((state & def->pin_high) == 0) {
|
||||
if ((state & def->Pin_high) == 0) {
|
||||
pos = SWITCH_HW_DOWN;
|
||||
}
|
||||
} else {
|
||||
bool hi = state & def->pin_high;
|
||||
bool lo = state & def->pin_low;
|
||||
bool hi = state & def->Pin_high;
|
||||
bool lo = state & def->Pin_low;
|
||||
|
||||
if (hi && lo) {
|
||||
pos = SWITCH_HW_MID;
|
||||
@@ -218,29 +174,23 @@ static SwitchHwPos _get_switch_pos(uint8_t idx)
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == switchGetMaxSwitches() - 1)
|
||||
oldState = state;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
static SwitchHwPos _get_fs_switch_pos(uint8_t idx)
|
||||
{
|
||||
const stm32_switch_t* def = boardGetSwitchDef(idx);
|
||||
uint32_t state = _io_fs_switches.state;
|
||||
if ((state & (1 << idx)) == 0) {
|
||||
if ((state & def->Pin_high) == 0) {
|
||||
return SWITCH_HW_DOWN;
|
||||
} else {
|
||||
return SWITCH_HW_UP;
|
||||
}
|
||||
}
|
||||
|
||||
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
|
||||
{
|
||||
if (cat == SWITCH_PHYSICAL) {
|
||||
if (idx < 8)
|
||||
return _get_switch_pos(idx);
|
||||
} else if (cat == SWITCH_FUNCTION){
|
||||
return _get_fs_switch_pos(idx);
|
||||
}
|
||||
|
||||
return SWITCH_HW_UP;
|
||||
return _get_fs_switch_pos(idx);
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "drivers/pca95xx.h"
|
||||
|
||||
// Port expander 1 (0x74)
|
||||
#define SWITCH_H PCA95XX_PIN_0
|
||||
#define SWITCH_D PCA95XX_PIN_1
|
||||
|
||||
#define SWITCH_F_H PCA95XX_PIN_3
|
||||
#define SWITCH_F_L PCA95XX_PIN_2
|
||||
|
||||
#define SWITCH_C_L PCA95XX_PIN_4
|
||||
#define SWITCH_C_H PCA95XX_PIN_5
|
||||
|
||||
#define SWITCH_B_H PCA95XX_PIN_10
|
||||
#define SWITCH_B_L PCA95XX_PIN_11
|
||||
|
||||
#define SWITCH_E_H PCA95XX_PIN_12
|
||||
#define SWITCH_E_L PCA95XX_PIN_13
|
||||
|
||||
#define SWITCH_A PCA95XX_PIN_14
|
||||
#define SWITCH_G PCA95XX_PIN_15
|
||||
|
||||
#define IO_INT_GPIO GPIO_PIN(GPIOE, 14)
|
||||
#define IO_RESET_GPIO GPIO_PIN(GPIOE, 15)
|
||||
|
||||
// Port expander 1 (0x75)
|
||||
#define FSSWITCH_1 PCA95XX_PIN_0
|
||||
#define FSSWITCH_2 PCA95XX_PIN_1
|
||||
#define FSSWITCH_3 PCA95XX_PIN_2
|
||||
#define FSSWITCH_4 PCA95XX_PIN_3
|
||||
#define FSSWITCH_5 PCA95XX_PIN_4
|
||||
#define FSSWITCH_6 PCA95XX_PIN_5
|
||||
|
||||
|
||||
int bsp_io_init();
|
||||
uint32_t bsp_io_read_switches();
|
||||
uint32_t bsp_io_read_fs_switches();
|
||||
@@ -645,6 +645,9 @@
|
||||
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_13 // PC.13
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_A_2POS
|
||||
#define SWITCHES_A_CFS_IDX 7
|
||||
#define SWITCHES_GPIO_REG_A
|
||||
#define SWITCHES_GPIO_PIN_A PCA95XX_PIN_14
|
||||
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
|
||||
#define SWITCHES_GPIO_REG_A GPIOC
|
||||
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_5 // PC.05
|
||||
@@ -747,6 +750,10 @@
|
||||
#define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_11 // PD.11
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_B_3POS
|
||||
#define SWITCHES_GPIO_REG_B_H
|
||||
#define SWITCHES_GPIO_PIN_B_H PCA95XX_PIN_10
|
||||
#define SWITCHES_GPIO_REG_B_L
|
||||
#define SWITCHES_GPIO_PIN_B_L PCA95XX_PIN_11
|
||||
#elif defined(RADIO_V14) || defined(RADIO_V12)
|
||||
// ADC based switch
|
||||
#elif defined(PCBX7)
|
||||
@@ -825,6 +832,10 @@
|
||||
#define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_13 // PC.13
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_C_3POS
|
||||
#define SWITCHES_GPIO_REG_C_H
|
||||
#define SWITCHES_GPIO_PIN_C_H PCA95XX_PIN_5
|
||||
#define SWITCHES_GPIO_REG_C_L
|
||||
#define SWITCHES_GPIO_PIN_C_L PCA95XX_PIN_4
|
||||
#elif defined(RADIO_V14) || defined(RADIO_V12)
|
||||
// ADC based switch
|
||||
#elif defined(PCBX7)
|
||||
@@ -892,6 +903,9 @@
|
||||
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_3 // PC.03
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_D_2POS
|
||||
#define SWITCHES_D_CFS_IDX 6
|
||||
#define SWITCHES_GPIO_REG_D
|
||||
#define SWITCHES_GPIO_PIN_D PCA95XX_PIN_1
|
||||
#elif defined(RADIO_V14) || defined(RADIO_V12)
|
||||
#define STORAGE_SWITCH_D
|
||||
#define HARDWARE_SWITCH_D
|
||||
@@ -968,6 +982,10 @@
|
||||
// ADC based switch/pot
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_E_3POS
|
||||
#define SWITCHES_GPIO_REG_E_H
|
||||
#define SWITCHES_GPIO_PIN_E_H PCA95XX_PIN_12
|
||||
#define SWITCHES_GPIO_REG_E_L
|
||||
#define SWITCHES_GPIO_PIN_E_L PCA95XX_PIN_13
|
||||
#elif defined(RADIO_V14) || defined(RADIO_V12)
|
||||
// ADC based switch
|
||||
#elif defined(PCBX7)
|
||||
@@ -1025,12 +1043,16 @@
|
||||
#define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_5 // PB.05
|
||||
#elif defined(RADIO_MT12)
|
||||
// ADC based switch/pot
|
||||
#elif defined(RADIO_T8) || defined(RADIO_TLITE) || defined(RADIO_TPROV2) || defined(RADIO_COMMANDO8) || defined(RADIO_LR3PRO) || defined(RADIO_POCKET)
|
||||
#elif defined(RADIO_T8) || defined(RADIO_TLITE) || defined(RADIO_COMMANDO8) || defined(RADIO_LR3PRO) || defined(RADIO_POCKET)
|
||||
// no SWF
|
||||
#elif defined(RADIO_T12)
|
||||
// no SWF
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_F_3POS
|
||||
#define SWITCHES_GPIO_REG_F_H
|
||||
#define SWITCHES_GPIO_PIN_F_H PCA95XX_PIN_3
|
||||
#define SWITCHES_GPIO_REG_F_L
|
||||
#define SWITCHES_GPIO_PIN_F_L PCA95XX_PIN_2
|
||||
#elif defined(RADIO_V14) || defined(RADIO_V12)
|
||||
// ADC based switch
|
||||
#elif defined(PCBX7)
|
||||
@@ -1061,6 +1083,7 @@
|
||||
#define FUNCTION_SWITCH_1 SG
|
||||
#define SWITCHES_GPIO_REG_G GPIOG
|
||||
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_7 // PG.07
|
||||
#define SWITCHES_G_CFS_IDX 0
|
||||
#elif defined(RADIO_BUMBLEBEE)
|
||||
#define SWITCHES_GPIO_REG_G GPIOD
|
||||
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_15// PD.15 - Left trim push
|
||||
@@ -1070,6 +1093,8 @@
|
||||
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_15 // PD.15
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_G_2POS
|
||||
#define SWITCHES_GPIO_REG_G
|
||||
#define SWITCHES_GPIO_PIN_G PCA95XX_PIN_15
|
||||
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_T8) || defined(RADIO_COMMANDO8) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS)
|
||||
// no SWG
|
||||
#else
|
||||
@@ -1099,6 +1124,7 @@
|
||||
#define FUNCTION_SWITCH_2 SH
|
||||
#define SWITCHES_GPIO_REG_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_6 // PG.06
|
||||
#define SWITCHES_H_CFS_IDX 1
|
||||
#elif defined(RADIO_BUMBLEBEE)
|
||||
#define SWITCHES_GPIO_REG_H GPIOF
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_0 // PF.00 - Right trim push
|
||||
@@ -1106,10 +1132,12 @@
|
||||
//TRIM right low
|
||||
#define SWITCHES_GPIO_REG_H GPIOF
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_0 // PF.00
|
||||
#elif defined(RADIO_TLITE) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_LR3PRO)
|
||||
#elif defined(RADIO_TLITE) || defined(RADIO_TPROS) || defined(RADIO_LR3PRO)
|
||||
// no SWH
|
||||
#elif defined(RADIO_GX12)
|
||||
#define SWITCHES_H_2POS
|
||||
#define SWITCHES_GPIO_REG_H
|
||||
#define SWITCHES_GPIO_PIN_H PCA95XX_PIN_0
|
||||
#elif defined(PCBX7)
|
||||
#define SWITCHES_GPIO_REG_H GPIOD
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_14 // PD.14
|
||||
@@ -1147,68 +1175,84 @@
|
||||
#define FUNCTION_SWITCH_1 SI
|
||||
#define SWITCHES_GPIO_REG_I GPIOG
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_7 // PG.07
|
||||
#define SWITCHES_I_CFS_IDX 0
|
||||
// SW2
|
||||
#define FUNCTION_SWITCH_2 SJ
|
||||
#define SWITCHES_GPIO_REG_J GPIOG
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_6 // PG.06
|
||||
#define SWITCHES_J_CFS_IDX 1
|
||||
// SW3
|
||||
#define FUNCTION_SWITCH_3 SK
|
||||
#define SWITCHES_GPIO_REG_K GPIOG
|
||||
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_5 // PG.05
|
||||
#define SWITCHES_K_CFS_IDX 2
|
||||
// SW4
|
||||
#define FUNCTION_SWITCH_4 SL
|
||||
#define SWITCHES_GPIO_REG_L GPIOG
|
||||
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_4 // PG.04
|
||||
#define SWITCHES_L_CFS_IDX 3
|
||||
// SW5
|
||||
#define FUNCTION_SWITCH_5 SM
|
||||
#define SWITCHES_GPIO_REG_M GPIOG
|
||||
#define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_3 // PG.03
|
||||
#define SWITCHES_M_CFS_IDX 4
|
||||
// SW6
|
||||
#define FUNCTION_SWITCH_6 SO
|
||||
#define SWITCHES_GPIO_REG_O GPIOG
|
||||
#define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_2 // PG.02
|
||||
#define FUNCTION_SWITCH_6 SN
|
||||
#define SWITCHES_GPIO_REG_N GPIOG
|
||||
#define SWITCHES_GPIO_PIN_N LL_GPIO_PIN_2 // PG.02
|
||||
#define SWITCHES_N_CFS_IDX 5
|
||||
#elif defined(RADIO_BUMBLEBEE)
|
||||
// SW1
|
||||
#define FUNCTION_SWITCH_1 SJ
|
||||
#define SWITCHES_GPIO_REG_J GPIOE
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_15 // PE.15
|
||||
#define SWITCHES_J_CFS_IDX 0
|
||||
// SW2
|
||||
#define FUNCTION_SWITCH_2 SK
|
||||
#define SWITCHES_GPIO_REG_K GPIOE
|
||||
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_14 // PE.14
|
||||
#define SWITCHES_K_CFS_IDX 1
|
||||
// SW3
|
||||
#define FUNCTION_SWITCH_3 SL
|
||||
#define SWITCHES_GPIO_REG_L GPIOE
|
||||
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_13 // PE.13
|
||||
#define SWITCHES_L_CFS_IDX 2
|
||||
// SW4
|
||||
#define FUNCTION_SWITCH_4 SM
|
||||
#define SWITCHES_GPIO_REG_M GPIOE
|
||||
#define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_10 // PE.10
|
||||
#define SWITCHES_M_CFS_IDX 3
|
||||
// SW5
|
||||
#define FUNCTION_SWITCH_5 SO
|
||||
#define SWITCHES_GPIO_REG_O GPIOE
|
||||
#define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_8 // PE.08
|
||||
#define SWITCHES_O_CFS_IDX 4
|
||||
// SW6
|
||||
#define FUNCTION_SWITCH_6 SP
|
||||
#define SWITCHES_GPIO_REG_P GPIOE
|
||||
#define SWITCHES_GPIO_PIN_P LL_GPIO_PIN_12 // PE.12
|
||||
#define SWITCHES_P_CFS_IDX 5
|
||||
#elif defined(RADIO_TPRO)
|
||||
// SW3
|
||||
#define FUNCTION_SWITCH_3 SI
|
||||
#define SWITCHES_GPIO_REG_I GPIOG
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_5 // PG.05
|
||||
#define SWITCHES_I_CFS_IDX 2
|
||||
// SW4
|
||||
#define FUNCTION_SWITCH_4 SJ
|
||||
#define SWITCHES_GPIO_REG_J GPIOG
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_4 // PG.04
|
||||
#define SWITCHES_J_CFS_IDX 3
|
||||
// SW5
|
||||
#define FUNCTION_SWITCH_5 SK
|
||||
#define SWITCHES_GPIO_REG_K GPIOG
|
||||
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_3 // PG.03
|
||||
#define SWITCHES_K_CFS_IDX 4
|
||||
// SW6
|
||||
#define FUNCTION_SWITCH_6 SL
|
||||
#define SWITCHES_GPIO_REG_L GPIOG
|
||||
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_2 // PG.02
|
||||
#define SWITCHES_L_CFS_IDX 5
|
||||
#elif defined(RADIO_FAMILY_T20)
|
||||
//TRIM left up
|
||||
#define SWITCHES_GPIO_REG_I GPIOG
|
||||
@@ -1230,41 +1274,65 @@
|
||||
#define FUNCTION_SWITCH_1 SK
|
||||
#define SWITCHES_GPIO_REG_K GPIOE
|
||||
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_10 // PE.10
|
||||
#define SWITCHES_K_CFS_IDX 0
|
||||
//SW2
|
||||
#define FUNCTION_SWITCH_2 SL
|
||||
#define SWITCHES_GPIO_REG_L GPIOE
|
||||
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_8 // PE.08
|
||||
#define SWITCHES_L_CFS_IDX 1
|
||||
//SW3
|
||||
#define FUNCTION_SWITCH_3 SM
|
||||
#define SWITCHES_GPIO_REG_M GPIOE
|
||||
#define SWITCHES_GPIO_PIN_M LL_GPIO_PIN_12 // PE.12
|
||||
#define SWITCHES_M_CFS_IDX 2
|
||||
//SW4
|
||||
#define FUNCTION_SWITCH_4 SN
|
||||
#define SWITCHES_GPIO_REG_N GPIOE
|
||||
#define SWITCHES_GPIO_PIN_N LL_GPIO_PIN_13 // PE.13
|
||||
#define SWITCHES_N_CFS_IDX 3
|
||||
//SW5
|
||||
#define FUNCTION_SWITCH_5 SO
|
||||
#define SWITCHES_GPIO_REG_O GPIOE
|
||||
#define SWITCHES_GPIO_PIN_O LL_GPIO_PIN_14 // PE.14
|
||||
#define SWITCHES_O_CFS_IDX 4
|
||||
//SW6
|
||||
#define FUNCTION_SWITCH_6 SP
|
||||
#define SWITCHES_GPIO_REG_P GPIOE
|
||||
#define SWITCHES_GPIO_PIN_P LL_GPIO_PIN_15 // PE.15
|
||||
#define SWITCHES_P_CFS_IDX 5
|
||||
#endif
|
||||
|
||||
#if defined(RADIO_GX12)
|
||||
//SW1
|
||||
#define FUNCTION_SWITCH_1
|
||||
#define SWITCHES_GPIO_REG_I
|
||||
#define SWITCHES_GPIO_PIN_I PCA95XX_PIN_0
|
||||
#define SWITCHES_I_CFS_IDX 0
|
||||
#define FUNCTION_SWITCH_1 SI
|
||||
//SW2
|
||||
#define FUNCTION_SWITCH_2
|
||||
#define SWITCHES_GPIO_REG_J
|
||||
#define SWITCHES_GPIO_PIN_J PCA95XX_PIN_1
|
||||
#define SWITCHES_J_CFS_IDX 1
|
||||
#define FUNCTION_SWITCH_2 SJ
|
||||
//SW3
|
||||
#define FUNCTION_SWITCH_3
|
||||
#define SWITCHES_GPIO_REG_K
|
||||
#define SWITCHES_GPIO_PIN_K PCA95XX_PIN_2
|
||||
#define SWITCHES_K_CFS_IDX 2
|
||||
#define FUNCTION_SWITCH_3 SK
|
||||
//SW4
|
||||
#define FUNCTION_SWITCH_4
|
||||
#define SWITCHES_GPIO_REG_L
|
||||
#define SWITCHES_GPIO_PIN_L PCA95XX_PIN_3
|
||||
#define SWITCHES_L_CFS_IDX 3
|
||||
#define FUNCTION_SWITCH_4 SL
|
||||
//SW5
|
||||
#define FUNCTION_SWITCH_5
|
||||
#define SWITCHES_GPIO_REG_M
|
||||
#define SWITCHES_GPIO_PIN_M PCA95XX_PIN_4
|
||||
#define SWITCHES_M_CFS_IDX 4
|
||||
#define FUNCTION_SWITCH_5 SM
|
||||
//SW6
|
||||
#define FUNCTION_SWITCH_6
|
||||
#define SWITCHES_GPIO_REG_N
|
||||
#define SWITCHES_GPIO_PIN_N PCA95XX_PIN_5
|
||||
#define SWITCHES_N_CFS_IDX 5
|
||||
#define FUNCTION_SWITCH_6 SN
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9E)
|
||||
@@ -1979,9 +2047,15 @@
|
||||
#if defined(RGBLEDS)
|
||||
#if defined(RADIO_GX12)
|
||||
#define LED_STRIP_LENGTH 8
|
||||
#define RGB_LED_OFFSET 8
|
||||
#define BLING_LED_STRIP_START 0
|
||||
#define BLING_LED_STRIP_LENGTH 0
|
||||
#define CFS_LED_STRIP_START 0
|
||||
#define CFS_LED_STRIP_LENGTH 8
|
||||
#define CFS_LEDS_PER_SWITCH 1
|
||||
#else
|
||||
#define LED_STRIP_LENGTH 7
|
||||
#define BLING_LED_STRIP_START 0
|
||||
#define BLING_LED_STRIP_LENGTH 7
|
||||
#endif
|
||||
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 8) // PA.08 / TIM1_CH1
|
||||
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1 / TIM2
|
||||
@@ -1997,10 +2071,14 @@
|
||||
#elif defined(RADIO_T14) || defined(RADIO_V14) || defined(RADIO_V12)
|
||||
#if defined(RADIO_V14)
|
||||
#define LED_STRIP_LENGTH 38
|
||||
#define BLING_LED_STRIP_START 6
|
||||
#define BLING_LED_STRIP_LENGTH 32
|
||||
#elif defined(RADIO_V12)
|
||||
#define LED_STRIP_LENGTH 6
|
||||
#define LED_STRIP_LENGTH 6 // 6POS switches only?
|
||||
#else
|
||||
#define LED_STRIP_LENGTH 1
|
||||
#define BLING_LED_STRIP_START 0
|
||||
#define BLING_LED_STRIP_LENGTH 1
|
||||
#endif
|
||||
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 10) // PA.10 / TIM1_CH3
|
||||
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1
|
||||
|
||||
@@ -60,18 +60,15 @@ void ledInit()
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
// used to map switch number to led number in the rgbled chain
|
||||
uint8_t ledMapping[] = {0, 1, 2, 3, 4, 5, 6};
|
||||
|
||||
void fsLedRGB(uint8_t index, uint32_t color)
|
||||
{
|
||||
ws2812_set_color(ledMapping[index], GET_RED(color), GET_GREEN(color),
|
||||
ws2812_set_color(index + CFS_LED_STRIP_START, GET_RED(color), GET_GREEN(color),
|
||||
GET_BLUE(color));
|
||||
}
|
||||
|
||||
uint32_t fsGetLedRGB(uint8_t index)
|
||||
{
|
||||
return rgbGetLedColor(ledMapping[index]);
|
||||
return rgbGetLedColor(index + CFS_LED_STRIP_START);
|
||||
}
|
||||
|
||||
uint8_t getRGBColorIndex(uint32_t color)
|
||||
|
||||
Reference in New Issue
Block a user