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
@@ -24,7 +24,7 @@
|
||||
|
||||
SwitchHwPos stm32_switch_get_position(const stm32_switch_t* sw)
|
||||
{
|
||||
bool inv = sw->flags & SWITCH_HW_INVERTED;
|
||||
bool inv = sw->inverted;
|
||||
SwitchHwPos ret = SWITCH_HW_UP;
|
||||
|
||||
switch (sw->type) {
|
||||
|
||||
@@ -21,20 +21,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal.h"
|
||||
#include "stm32_hal_ll.h"
|
||||
#include "hal/switch_driver.h"
|
||||
#include "edgetx_constants.h"
|
||||
|
||||
struct stm32_switch_t
|
||||
{
|
||||
const char* name;
|
||||
|
||||
GPIO_TypeDef* GPIOx_high;
|
||||
uint32_t Pin_high;
|
||||
|
||||
GPIO_TypeDef* GPIOx_low;
|
||||
uint32_t Pin_low;
|
||||
|
||||
SwitchHwType type;
|
||||
uint8_t flags;
|
||||
SwitchHwType type;
|
||||
bool inverted;
|
||||
SwitchConfig defaultType;
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
bool isCustomSwitch;
|
||||
uint8_t customSwitchIdx;
|
||||
#endif
|
||||
};
|
||||
|
||||
SwitchHwPos stm32_switch_get_position(const stm32_switch_t* sw);
|
||||
|
||||
@@ -302,19 +302,6 @@ void bluetoothDisable();
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
#define NUM_FUNCTIONS_SWITCHES 6
|
||||
#define NUM_FUNCTIONS_GROUPS 3
|
||||
#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
|
||||
#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;}
|
||||
@@ -156,36 +156,42 @@
|
||||
#define HARDWARE_SWITCH_G
|
||||
#define SWITCHES_GPIO_REG_G GPIOB
|
||||
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_14 // PB.14
|
||||
#define SWITCHES_G_CFS_IDX 0
|
||||
//SW2
|
||||
#define FUNCTION_SWITCH_2 SH
|
||||
#define STORAGE_SWITCH_H
|
||||
#define HARDWARE_SWITCH_H
|
||||
#define SWITCHES_GPIO_REG_H GPIOD
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_13 // PD.13
|
||||
#define SWITCHES_H_CFS_IDX 1
|
||||
//SW3
|
||||
#define FUNCTION_SWITCH_3 SI
|
||||
#define STORAGE_SWITCH_I
|
||||
#define HARDWARE_SWITCH_I
|
||||
#define SWITCHES_GPIO_REG_I GPIOJ
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_7 // PJ.07
|
||||
#define SWITCHES_I_CFS_IDX 2
|
||||
//SW4
|
||||
#define FUNCTION_SWITCH_4 SJ
|
||||
#define STORAGE_SWITCH_J
|
||||
#define HARDWARE_SWITCH_J
|
||||
#define SWITCHES_GPIO_REG_J GPIOG
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_13 // PG.13
|
||||
#define SWITCHES_J_CFS_IDX 3
|
||||
//SW5
|
||||
#define FUNCTION_SWITCH_5 SK
|
||||
#define STORAGE_SWITCH_K
|
||||
#define HARDWARE_SWITCH_K
|
||||
#define SWITCHES_GPIO_REG_K GPIOJ
|
||||
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_8 // PJ.08
|
||||
#define SWITCHES_K_CFS_IDX 4
|
||||
//SW6
|
||||
#define FUNCTION_SWITCH_6 SL
|
||||
#define STORAGE_SWITCH_L
|
||||
#define HARDWARE_SWITCH_L
|
||||
#define SWITCHES_GPIO_REG_L GPIOB
|
||||
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_13 // PB.13
|
||||
#define SWITCHES_L_CFS_IDX 5
|
||||
#else
|
||||
#define STORAGE_SWITCH_A
|
||||
#define HARDWARE_SWITCH_A
|
||||
@@ -1044,6 +1050,8 @@
|
||||
#if defined(RADIO_V16)
|
||||
// LED Strip
|
||||
#define LED_STRIP_LENGTH 40
|
||||
#define BLING_LED_STRIP_START 6
|
||||
#define BLING_LED_STRIP_LENGTH 34
|
||||
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 10) // PA.10 / TIM1_CH3
|
||||
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1/2
|
||||
#define LED_STRIP_TIMER TIM1
|
||||
|
||||
@@ -50,23 +50,7 @@ void ledInit()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
// used to map switch number to led number in the rgbled chain
|
||||
uint8_t ledMapping[] = {1, 2, 3, 4, 5, 6};
|
||||
|
||||
void fsLedOff(uint8_t index, uint32_t color)
|
||||
{
|
||||
rgbSetLedColor(ledMapping[index], GET_RED(color), GET_GREEN(color),
|
||||
GET_BLUE(color));
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t index, uint32_t color)
|
||||
{
|
||||
rgbSetLedColor(ledMapping[index], GET_RED(color), GET_GREEN(color),
|
||||
GET_BLUE(color));
|
||||
}
|
||||
|
||||
#elif defined(FUNCTION_SWITCHES)
|
||||
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
gpio_t fsLeds[] = {FSLED_GPIO_1, FSLED_GPIO_2, FSLED_GPIO_3,
|
||||
FSLED_GPIO_4, FSLED_GPIO_5, FSLED_GPIO_6};
|
||||
|
||||
|
||||
@@ -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;}
|
||||
@@ -17,5 +17,3 @@
|
||||
|
||||
#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;}
|
||||
|
||||
@@ -830,6 +830,8 @@
|
||||
// LED Strip
|
||||
#if !defined(RADIO_NV14_FAMILY)
|
||||
#define LED_STRIP_LENGTH 4
|
||||
#define BLING_LED_STRIP_START 0
|
||||
#define BLING_LED_STRIP_LENGTH 4
|
||||
#define LED_STRIP_GPIO GPIO_PIN(GPIOH, 12) // PH.12 / TIM5_CH3
|
||||
#define LED_STRIP_GPIO_AF LL_GPIO_AF_2 // TIM3/4/5
|
||||
#define LED_STRIP_TIMER TIM5
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
static const char _switch_names[][4] = {"SW2", "SW3"};
|
||||
|
||||
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
|
||||
{
|
||||
if (idx <= 1) {
|
||||
// uint16_t swVal = getAnalogValue(4);
|
||||
@@ -55,7 +55,7 @@ SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
return SWITCH_HW_UP;
|
||||
}
|
||||
|
||||
const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx)
|
||||
const char* boardSwitchGetName(uint8_t idx)
|
||||
{
|
||||
return _switch_names[idx];
|
||||
}
|
||||
|
||||
@@ -19,21 +19,26 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "edgetx.h"
|
||||
#include "hal/rgbleds.h"
|
||||
#include "definitions.h"
|
||||
|
||||
#include "board.h"
|
||||
|
||||
bool usbChargerLed() { return true; }
|
||||
void ledRed() {}
|
||||
void ledGreen() {}
|
||||
void ledBlue() {}
|
||||
void ledOff() {}
|
||||
|
||||
void rgbSetLedColor(uint8_t, uint8_t, uint8_t, uint8_t) {}
|
||||
void rgbLedColorApply() {}
|
||||
|
||||
bool fsLedState(uint8_t i)
|
||||
{
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
return g_model.customSwitches[i].state;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t getRGBColorIndex(uint32_t color)
|
||||
{
|
||||
for (uint8_t i = 0; i < DIM(colorTable); i++) {
|
||||
@@ -43,39 +48,37 @@ uint8_t getRGBColorIndex(uint32_t color)
|
||||
return 0; // Custom value set with Companion
|
||||
}
|
||||
|
||||
#if NUM_FUNCTIONS_SWITCHES > 0
|
||||
static uint32_t _fs_switch_colors[NUM_FUNCTIONS_SWITCHES] = {0};
|
||||
static uint32_t _fs_switch_color_mask = 0;
|
||||
static uint32_t _fs_switch_mask = 0;
|
||||
// RGB
|
||||
#define WS2812_BYTES_PER_LED 3
|
||||
|
||||
void fsLedRGB(uint8_t index, uint32_t col)
|
||||
// Maximum number of supported LEDs
|
||||
#if !defined(WS2812_MAX_LEDS)
|
||||
# define WS2812_MAX_LEDS 48
|
||||
#endif
|
||||
|
||||
// Pixel values
|
||||
static uint8_t _led_colors[WS2812_BYTES_PER_LED * WS2812_MAX_LEDS];
|
||||
|
||||
void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
_fs_switch_color_mask |= (1 << index);
|
||||
_fs_switch_colors[index] = col;
|
||||
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
|
||||
pixel[0] = g;
|
||||
pixel[1] = r;
|
||||
pixel[2] = b;
|
||||
}
|
||||
|
||||
uint32_t rgbGetLedColor(uint8_t led)
|
||||
{
|
||||
uint8_t* pixel = &_led_colors[led * WS2812_BYTES_PER_LED];
|
||||
return (pixel[1] << 16) + (pixel[0] << 8) + pixel[2];
|
||||
}
|
||||
|
||||
void fsLedRGB(uint8_t idx, uint32_t color)
|
||||
{
|
||||
rgbSetLedColor(idx, (color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF);
|
||||
}
|
||||
|
||||
uint32_t fsGetLedRGB(uint8_t index)
|
||||
{
|
||||
return _fs_switch_colors[index];
|
||||
return rgbGetLedColor(index);
|
||||
}
|
||||
|
||||
bool fsLedIsColorSet(uint8_t index)
|
||||
{
|
||||
return _fs_switch_color_mask & (1 << index);
|
||||
}
|
||||
|
||||
bool fsLedState(uint8_t index)
|
||||
{
|
||||
return _fs_switch_mask & (1 << index);
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t index)
|
||||
{
|
||||
_fs_switch_mask |= (1 << index);
|
||||
}
|
||||
|
||||
void fsLedOff(uint8_t index)
|
||||
{
|
||||
_fs_switch_mask &= ~(1 << index);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "hal/adc_driver.h"
|
||||
#include "hal/rotary_encoder.h"
|
||||
#include "os/time.h"
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
@@ -90,6 +91,16 @@ void firmwareTraceCb(const char * text)
|
||||
}
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t idx)
|
||||
{
|
||||
rgbSetLedColor(idx, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
|
||||
void fsLedOff(uint8_t idx)
|
||||
{
|
||||
rgbSetLedColor(idx, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Serial port handling needs to know about OpenTxSimulator, so we we
|
||||
// need to update what's in simpgmspace.cpp when we have a simulator
|
||||
// to point at.
|
||||
@@ -751,6 +762,7 @@ void OpenTxSimulator::run()
|
||||
++loops;
|
||||
|
||||
checkLcdChanged();
|
||||
checkFuncSwitchChanged();
|
||||
|
||||
if (!(loops % 5)) {
|
||||
checkOutputsChanged();
|
||||
@@ -783,6 +795,19 @@ bool OpenTxSimulator::checkLcdChanged()
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenTxSimulator::checkFuncSwitchChanged()
|
||||
{
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
for (int i = 0; i < CPN_MAX_SWITCHES; i += 1) {
|
||||
if (switchIsCustomSwitch(i)) {
|
||||
uint8_t cfs = switchGetCustomSwitchIdx(i);
|
||||
uint32_t c = rgbGetLedColor(cfs);
|
||||
emit fsColorChange(i, c);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenTxSimulator::checkOutputsChanged()
|
||||
{
|
||||
static TxOutputs lastOutputs;
|
||||
|
||||
@@ -102,6 +102,7 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface
|
||||
void setStopRequested(bool stop);
|
||||
bool checkLcdChanged();
|
||||
void checkOutputsChanged();
|
||||
void checkFuncSwitchChanged();
|
||||
uint8_t getStickMode();
|
||||
const char * getPhaseName(unsigned int phase);
|
||||
const QString getCurrentPhaseName();
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "simpgmspace.h"
|
||||
|
||||
#include "hal/key_driver.h"
|
||||
#include "hal/switch_driver.h"
|
||||
#include "switches.h"
|
||||
|
||||
#include "audio.h"
|
||||
@@ -316,26 +317,28 @@ static void draw_switches()
|
||||
int sw_idx = 0;
|
||||
for (int i = 0; i < switchGetMaxSwitches(); i++) {
|
||||
if (sw_idx) ImGui::SameLine();
|
||||
if (++sw_idx >= MAX_SWITCHES / 2) sw_idx = 0;
|
||||
|
||||
if (!SWITCH_EXISTS(i)) {
|
||||
switches[i] = 0;
|
||||
ImGui::Dummy(sw_size);
|
||||
} else {
|
||||
ImGui::PushID(i);
|
||||
ImGui::VSliderInt("##sw", sw_size,
|
||||
&switches[i], IS_CONFIG_3POS(i) ? 2 : 1,
|
||||
0, "", ImGuiSliderFlags_NoInput);
|
||||
if (ImGui::IsItemActive() || ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("%s", switchGetCanonicalName(i));
|
||||
if (!switchIsCustomSwitch(i)) {
|
||||
if (++sw_idx >= MAX_SWITCHES / 2) sw_idx = 0;
|
||||
if (!SWITCH_EXISTS(i)) {
|
||||
switches[i] = 0;
|
||||
ImGui::Dummy(sw_size);
|
||||
} else {
|
||||
ImGui::PushID(i);
|
||||
ImGui::VSliderInt("##sw", sw_size,
|
||||
&switches[i], IS_CONFIG_3POS(i) ? 2 : 1,
|
||||
0, "", ImGuiSliderFlags_NoInput);
|
||||
if (ImGui::IsItemActive() || ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("%s", switchGetDefaultName(i));
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
if (IS_CONFIG_3POS(i)) {
|
||||
simuSetSwitch(i, switches[i] == 0 ? -1 : switches[i] == 1 ? 0 : 1);
|
||||
} else {
|
||||
simuSetSwitch(i, switches[i] == 0 ? -1 : 1);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
if (IS_CONFIG_3POS(i)) {
|
||||
simuSetSwitch(i, switches[i] == 0 ? -1 : switches[i] == 1 ? 0 : 1);
|
||||
} else {
|
||||
simuSetSwitch(i, switches[i] == 0 ? -1 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,8 +349,6 @@ static void draw_switches()
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
extern bool fsLedIsColorSet(uint8_t index);
|
||||
|
||||
static ImVec4 rgb2rgba(uint32_t col)
|
||||
{
|
||||
float r = (float)((col >> 16) & 0xff) / 255.0f;
|
||||
@@ -365,9 +366,10 @@ static inline ImVec4 blend(const ImVec4& a, const ImVec4& b)
|
||||
|
||||
static void push_custom_switch_styles(int index)
|
||||
{
|
||||
bool sw_on = getFSLogicalState(index);
|
||||
bool rgb_set = fsLedIsColorSet(index);
|
||||
ImVec4 rgb = rgb2rgba(fsGetLedRGB(index));
|
||||
int cfsIdx = switchGetCustomSwitchIdx(index);
|
||||
bool sw_on = fsLedState(cfsIdx);
|
||||
bool rgb_set = switchIsCustomSwitch(index);
|
||||
ImVec4 rgb = rgb2rgba(fsGetLedRGB(cfsIdx));
|
||||
|
||||
ImVec4 btn, border;
|
||||
if (sw_on) {
|
||||
@@ -408,24 +410,29 @@ static void draw_custom_switches()
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 4.0f);
|
||||
|
||||
int sw_idx = switchGetMaxSwitches();
|
||||
for (int i = 0; i < switchGetMaxFctSwitches(); i++, sw_idx++) {
|
||||
if (i) ImGui::SameLine();
|
||||
ImGui::PushID(i);
|
||||
for (int i = 0, n = 0; i < switchGetMaxSwitches(); i += 1) {
|
||||
if (switchIsCustomSwitch(i)) {
|
||||
int cfsIdx = switchGetCustomSwitchIdx(i);
|
||||
|
||||
push_custom_switch_styles(i);
|
||||
ImGui::Button("##csw", sw_size);
|
||||
pop_custom_switch_styles();
|
||||
if (n) ImGui::SameLine();
|
||||
ImGui::PushID(i);
|
||||
|
||||
bool active = ImGui::IsItemActive();
|
||||
if (active || ImGui::IsItemHovered()) {
|
||||
const char* name = switchGetCanonicalName(sw_idx);
|
||||
const char* on_off = getFSLogicalState(i) ? "on" : "off";
|
||||
ImGui::SetTooltip("%s (%s)", name, on_off);
|
||||
push_custom_switch_styles(i);
|
||||
ImGui::Button("##csw", sw_size);
|
||||
pop_custom_switch_styles();
|
||||
|
||||
bool active = ImGui::IsItemActive();
|
||||
if (active || ImGui::IsItemHovered()) {
|
||||
const char* name = switchGetDefaultName(i);
|
||||
const char* on_off = fsLedState(cfsIdx) ? "on" : "off";
|
||||
ImGui::SetTooltip("%s (%s)", name, on_off);
|
||||
}
|
||||
simuSetSwitch(i, active ? 1 : -1);
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
simuSetSwitch(sw_idx, active ? 1 : -1);
|
||||
|
||||
ImGui::PopID();
|
||||
n += 1;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
@@ -29,17 +29,22 @@
|
||||
#include <string.h>
|
||||
|
||||
struct hw_switch_def {
|
||||
const char* name;
|
||||
SwitchHwType type;
|
||||
const char* name;
|
||||
SwitchHwType type;
|
||||
SwitchConfig defaultType;
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
bool isCustomSwitch;
|
||||
uint8_t customSwitchIdx;
|
||||
#endif
|
||||
};
|
||||
|
||||
#include "simu_switches.inc"
|
||||
|
||||
int8_t switchesStates[MAX_SWITCHES] = { 0 };
|
||||
int8_t switchesStates[MAX_SWITCHES];
|
||||
|
||||
void simuSetSwitch(uint8_t swtch, int8_t state)
|
||||
{
|
||||
assert(swtch < switchGetMaxSwitches() + switchGetMaxFctSwitches());
|
||||
assert(swtch < switchGetMaxAllSwitches());
|
||||
switchesStates[swtch] = state;
|
||||
}
|
||||
|
||||
@@ -47,34 +52,8 @@ void boardInitSwitches() {
|
||||
memset(switchesStates, -1, sizeof(switchesStates));
|
||||
}
|
||||
|
||||
static uint8_t get_switch_index(uint8_t cat, uint8_t idx)
|
||||
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
|
||||
{
|
||||
switch(cat) {
|
||||
case SWITCH_PHYSICAL:
|
||||
assert(idx < n_switches);
|
||||
return idx;
|
||||
|
||||
case SWITCH_FUNCTION:
|
||||
assert(idx < n_fct_switches);
|
||||
return idx + n_switches;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
{
|
||||
idx = get_switch_index(cat, idx);
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
if (IS_SWITCH_FS(idx)) {
|
||||
if (bfSingleBitGet(functionSwitchFunctionState, idx - n_switches))
|
||||
return SWITCH_HW_DOWN;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (switchesStates[idx] < 0)
|
||||
return SWITCH_HW_UP;
|
||||
else if (switchesStates[idx] == 0)
|
||||
@@ -83,26 +62,30 @@ SwitchHwPos boardSwitchGetPosition(SwitchCategory cat, uint8_t idx)
|
||||
return SWITCH_HW_DOWN;
|
||||
}
|
||||
|
||||
const char* boardSwitchGetName(SwitchCategory cat, uint8_t idx)
|
||||
const char* boardSwitchGetName(uint8_t idx)
|
||||
{
|
||||
idx = get_switch_index(cat, idx);
|
||||
return _switch_defs[idx].name;
|
||||
}
|
||||
|
||||
SwitchHwType boardSwitchGetType(SwitchCategory cat, uint8_t idx)
|
||||
SwitchHwType boardSwitchGetType(uint8_t idx)
|
||||
{
|
||||
idx = get_switch_index(cat, 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; }
|
||||
SwitchConfig boardSwitchGetDefaultConfig(uint8_t idx) { return _switch_defs[idx].defaultType; }
|
||||
|
||||
#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
|
||||
|
||||
#if !defined(COLORLCD)
|
||||
switch_display_pos_t switchGetDisplayPosition(uint8_t idx)
|
||||
{
|
||||
if (idx >= DIM(_switch_display)) return {0, 0};
|
||||
|
||||
return _switch_display[idx];
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -96,19 +96,6 @@ void EXTERNAL_MODULE_OFF(); /*gpio_clear(EXTMODULE_PWR_GPIO)*/
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
#define NUM_FUNCTIONS_SWITCHES 6
|
||||
#define NUM_FUNCTIONS_GROUPS 3
|
||||
#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
|
||||
#define NUM_FUNCTIONS_SWITCHES 0
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
|
||||
#include "bsp_io.h"
|
||||
|
||||
#include "drivers/pca95xx.h"
|
||||
#include "stm32_i2c_driver.h"
|
||||
#include "stm32_switch_driver.h"
|
||||
|
||||
extern const stm32_switch_t* boardGetSwitchDef(uint8_t idx);
|
||||
|
||||
#define BSP_IN_I2C_BUS I2C_Bus_2
|
||||
#define BSP_IN_I2C_ADDR 0x20
|
||||
|
||||
@@ -95,45 +96,19 @@ uint16_t bsp_input_get()
|
||||
return inputState;
|
||||
}
|
||||
|
||||
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw,
|
||||
SwitchCategory cat, uint8_t idx)
|
||||
SwitchHwPos boardSwitchGetPosition(uint8_t idx)
|
||||
{
|
||||
const stm32_switch_t* sw = boardGetSwitchDef(idx);
|
||||
|
||||
if (sw->type == SWITCH_HW_ADC || sw->GPIOx_high != nullptr)
|
||||
return stm32_switch_get_position(sw);
|
||||
|
||||
bool val = false;
|
||||
uint16_t pins = bsp_input_get();
|
||||
|
||||
if (cat == SWITCH_PHYSICAL) {
|
||||
switch (idx) {
|
||||
case 6:
|
||||
val = (pins & BSP_BACK_KEY1) != 0;
|
||||
break;
|
||||
case 7:
|
||||
val = (pins & BSP_BACK_KEY2) != 0;
|
||||
break;
|
||||
}
|
||||
} else if (cat == SWITCH_FUNCTION) {
|
||||
switch (idx) {
|
||||
case 0:
|
||||
val = (pins & BSP_EXT_KEY1) != 0;
|
||||
break;
|
||||
case 1:
|
||||
val = (pins & BSP_EXT_KEY2) != 0;
|
||||
break;
|
||||
case 2:
|
||||
val = (pins & BSP_EXT_KEY3) != 0;
|
||||
break;
|
||||
case 3:
|
||||
val = (pins & BSP_EXT_KEY4) != 0;
|
||||
break;
|
||||
case 4:
|
||||
val = (pins & BSP_EXT_KEY5) != 0;
|
||||
break;
|
||||
case 5:
|
||||
val = (pins & BSP_EXT_KEY6) != 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
val = (pins & sw->Pin_high) != 0;
|
||||
|
||||
if (sw->flags & SWITCH_HW_INVERTED) val = !val;
|
||||
if (sw->inverted) val = !val;
|
||||
|
||||
return val ? SWITCH_HW_UP : SWITCH_HW_DOWN;
|
||||
}
|
||||
|
||||
@@ -25,16 +25,6 @@
|
||||
#include "hal/switch_driver.h"
|
||||
|
||||
// Input port expander
|
||||
#define BSP_EXT_KEY1 PCA95XX_PIN_0
|
||||
#define BSP_EXT_KEY2 PCA95XX_PIN_1
|
||||
#define BSP_EXT_KEY3 PCA95XX_PIN_2
|
||||
#define BSP_EXT_KEY4 PCA95XX_PIN_3
|
||||
#define BSP_EXT_KEY5 PCA95XX_PIN_4
|
||||
#define BSP_EXT_KEY6 PCA95XX_PIN_5
|
||||
|
||||
#define BSP_BACK_KEY1 PCA95XX_PIN_6
|
||||
#define BSP_BACK_KEY2 PCA95XX_PIN_7
|
||||
|
||||
#define BSP_TR1U PCA95XX_PIN_8
|
||||
#define BSP_TR1D PCA95XX_PIN_9
|
||||
#define BSP_TR3L PCA95XX_PIN_10
|
||||
@@ -63,6 +53,3 @@ void bsp_output_set(uint16_t pin);
|
||||
void bsp_output_clear(uint16_t pin);
|
||||
|
||||
uint16_t bsp_input_get();
|
||||
struct stm32_switch_t;
|
||||
SwitchHwPos bsp_get_switch_position(const stm32_switch_t *sw, SwitchCategory cat, uint8_t idx);
|
||||
|
||||
|
||||
@@ -79,12 +79,30 @@
|
||||
|
||||
|
||||
// function switches
|
||||
#define FUNCTION_SWITCH_1 I2C
|
||||
#define FUNCTION_SWITCH_2 I2C
|
||||
#define FUNCTION_SWITCH_3 I2C
|
||||
#define FUNCTION_SWITCH_4 I2C
|
||||
#define FUNCTION_SWITCH_5 I2C
|
||||
#define FUNCTION_SWITCH_6 I2C
|
||||
#define FUNCTION_SWITCH_1 SK
|
||||
#define SWITCHES_GPIO_REG_K
|
||||
#define SWITCHES_GPIO_PIN_K PCA95XX_PIN_0
|
||||
#define SWITCHES_K_CFS_IDX 0
|
||||
#define FUNCTION_SWITCH_2 SL
|
||||
#define SWITCHES_GPIO_REG_L
|
||||
#define SWITCHES_GPIO_PIN_L PCA95XX_PIN_1
|
||||
#define SWITCHES_L_CFS_IDX 1
|
||||
#define FUNCTION_SWITCH_3 SM
|
||||
#define SWITCHES_GPIO_REG_M
|
||||
#define SWITCHES_GPIO_PIN_M PCA95XX_PIN_2
|
||||
#define SWITCHES_M_CFS_IDX 2
|
||||
#define FUNCTION_SWITCH_4 SN
|
||||
#define SWITCHES_GPIO_REG_N
|
||||
#define SWITCHES_GPIO_PIN_N PCA95XX_PIN_3
|
||||
#define SWITCHES_N_CFS_IDX 3
|
||||
#define FUNCTION_SWITCH_5 SO
|
||||
#define SWITCHES_GPIO_REG_O
|
||||
#define SWITCHES_GPIO_PIN_O PCA95XX_PIN_4
|
||||
#define SWITCHES_O_CFS_IDX 4
|
||||
#define FUNCTION_SWITCH_6 SP
|
||||
#define SWITCHES_GPIO_REG_P
|
||||
#define SWITCHES_GPIO_PIN_P PCA95XX_PIN_5
|
||||
#define SWITCHES_P_CFS_IDX 5
|
||||
|
||||
// Direct switches
|
||||
|
||||
@@ -92,15 +110,15 @@
|
||||
#define STORAGE_SWITCH_G
|
||||
#define HARDWARE_SWITCH_G
|
||||
#define SWITCHES_G_2POS
|
||||
//#define SWITCHES_GPIO_REG_G GPIOI
|
||||
//#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_3 // PI.03
|
||||
#define SWITCHES_GPIO_REG_G
|
||||
#define SWITCHES_GPIO_PIN_G PCA95XX_PIN_6
|
||||
|
||||
// Key 2
|
||||
#define STORAGE_SWITCH_H
|
||||
#define HARDWARE_SWITCH_H
|
||||
#define SWITCHES_H_2POS
|
||||
//#define SWITCHES_GPIO_REG_H GPIOI
|
||||
//#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_11 // PI.11
|
||||
#define SWITCHES_GPIO_REG_H
|
||||
#define SWITCHES_GPIO_PIN_H PCA95XX_PIN_7
|
||||
|
||||
|
||||
// Key 3
|
||||
@@ -402,7 +420,11 @@
|
||||
|
||||
// LED Strip
|
||||
#define LED_STRIP_LENGTH 24
|
||||
#define LED_STRIP_RESERVED_AT_END 12
|
||||
#define BLING_LED_STRIP_START 0
|
||||
#define BLING_LED_STRIP_LENGTH 12
|
||||
#define CFS_LED_STRIP_START 12
|
||||
#define CFS_LED_STRIP_LENGTH 12
|
||||
#define CFS_LEDS_PER_SWITCH 2
|
||||
#define LED_STRIP_GPIO GPIO_PIN(GPIOA, 15) // PA.15 / TIM2_CH1
|
||||
#define LED_STRIP_GPIO_AF LL_GPIO_AF_1 // TIM1/2/16/17
|
||||
#define LED_STRIP_TIMER TIM2
|
||||
|
||||
@@ -60,20 +60,16 @@ void ledInit()
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
// used to map switch number to led number in the rgbled chain
|
||||
uint8_t ledMapping[] = {12, 14, 16, 18, 20, 22};
|
||||
|
||||
void fsLedRGB(uint8_t index, uint32_t color)
|
||||
{
|
||||
rgbSetLedColor(ledMapping[index], GET_RED(color), \
|
||||
GET_GREEN(color),GET_BLUE(color));
|
||||
rgbSetLedColor(ledMapping[index]+1, GET_RED(color), \
|
||||
GET_GREEN(color),GET_BLUE(color));
|
||||
index = (index * 2) + CFS_LED_STRIP_START;
|
||||
rgbSetLedColor(index, GET_RED(color), GET_GREEN(color),GET_BLUE(color));
|
||||
rgbSetLedColor(index+1, GET_RED(color), GET_GREEN(color),GET_BLUE(color));
|
||||
}
|
||||
|
||||
uint32_t fsGetLedRGB(uint8_t index)
|
||||
{
|
||||
return rgbGetLedColor(ledMapping[index]);
|
||||
return rgbGetLedColor((index * 2) + CFS_LED_STRIP_START);
|
||||
}
|
||||
|
||||
uint8_t getRGBColorIndex(uint32_t color)
|
||||
|
||||
@@ -17,5 +17,3 @@
|
||||
|
||||
#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;}
|
||||
|
||||
@@ -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