feat: Radiomaster TX15 support (#6484)
Co-authored-by: Malte Langermann <54738901+gagarinlg@users.noreply.github.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Malte Langermann
3djc
raphaelcoeffic
philmoz
Peter Feerick
parent
3a00c0812b
commit
324b2c7761
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "hal/gpio.h"
|
||||
#include "hal/rgbleds.h"
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_ws2812.h"
|
||||
#include "boards/generic_stm32/rgb_leds.h"
|
||||
#include "board.h"
|
||||
|
||||
#define GET_RED(color) (((color) & 0xFF0000) >>16)
|
||||
#define GET_GREEN(color) (((color) & 0x00FF00) >> 8)
|
||||
#define GET_BLUE(color) ((color) & 0x0000FF)
|
||||
|
||||
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
static const uint32_t fsLeds[] = {FSLED_GPIO_PIN_1, FSLED_GPIO_PIN_2,
|
||||
FSLED_GPIO_PIN_3, FSLED_GPIO_PIN_4,
|
||||
FSLED_GPIO_PIN_5, FSLED_GPIO_PIN_6};
|
||||
#endif
|
||||
|
||||
void ledInit()
|
||||
{
|
||||
#if defined(LED_GREEN_GPIO)
|
||||
gpio_init(LED_GREEN_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
#endif
|
||||
|
||||
#if defined(LED_RED_GPIO)
|
||||
gpio_init(LED_RED_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
#endif
|
||||
|
||||
#if defined(LED_BLUE_GPIO)
|
||||
gpio_init(LED_BLUE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
#endif
|
||||
|
||||
#if defined(FUNCTION_SWITCHES) && !defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
for (size_t i = 0; i < DIM(fsLeds); i++) {
|
||||
gpio_init(fsLeds[i], GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES_RGB_LEDS)
|
||||
void fsLedRGB(uint8_t index, uint32_t 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(index + CFS_LED_STRIP_START);
|
||||
}
|
||||
|
||||
uint8_t getRGBColorIndex(uint32_t color)
|
||||
{
|
||||
for (uint8_t i = 0; i < DIM(colorTable); i++) {
|
||||
if (color == colorTable[i])
|
||||
return(i + 1);
|
||||
}
|
||||
return 0; // Custom value set with Companion
|
||||
}
|
||||
#elif defined(FUNCTION_SWITCHES)
|
||||
void fsLedOff(uint8_t index)
|
||||
{
|
||||
gpio_clear(fsLeds[index]);
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t index)
|
||||
{
|
||||
gpio_set(fsLeds[index]);
|
||||
}
|
||||
|
||||
bool fsLedState(uint8_t index)
|
||||
{
|
||||
return gpio_read(fsLeds[index]) ? true : false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ledOff()
|
||||
{
|
||||
#if defined(LED_RED_GPIO)
|
||||
GPIO_LED_GPIO_OFF(LED_RED_GPIO);
|
||||
#endif
|
||||
#if defined(LED_BLUE_GPIO)
|
||||
GPIO_LED_GPIO_OFF(LED_BLUE_GPIO);
|
||||
#endif
|
||||
#if defined(LED_GREEN_GPIO)
|
||||
GPIO_LED_GPIO_OFF(LED_GREEN_GPIO);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ledRed()
|
||||
{
|
||||
#if defined(LED_RED_GPIO)
|
||||
GPIO_LED_GPIO_ON(LED_RED_GPIO);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ledGreen()
|
||||
{
|
||||
#if defined(LED_GREEN_GPIO)
|
||||
GPIO_LED_GPIO_ON(LED_GREEN_GPIO);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ledBlue()
|
||||
{
|
||||
#if defined(LED_BLUE_GPIO)
|
||||
GPIO_LED_GPIO_ON(LED_BLUE_GPIO);
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user