Skip to content

Commit

Permalink
Merge branch 'EdgeTX:main' into Russian-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
kobakirill authored Oct 14, 2023
2 parents c69e8ba + b22a1b5 commit 2bd6fd4
Show file tree
Hide file tree
Showing 76 changed files with 1,490 additions and 611 deletions.
4 changes: 4 additions & 0 deletions companion/src/firmwares/boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ int Boards::getCapability(Board::Type board, Board::Capability capability)
// TX12, TX12MK2, ZORRO, BOXER, T8, TLITE, TPRO, LR3PRO, COMMANDO8
return (IS_FAMILY_HORUS_OR_T16(board) && !IS_HORUS_X12S(board)) || IS_FAMILY_T12(board);

case HasLedStripGPIO:
// No current radio do support that feature
return false;

case SportMaxBaudRate:
if (IS_FAMILY_T16(board) || IS_FLYSKY_NV14(board) || IS_FLYSKY_EL18(board) || IS_TARANIS_X7_ACCESS(board) ||
(IS_TARANIS(board) && !IS_TARANIS_XLITE(board) && !IS_TARANIS_X7(board) && !IS_TARANIS_X9LITE(board)))
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace Board {
HasIntModuleHeartbeatGPIO,
HasTrainerModuleCPPM,
HasTrainerModuleSBUS,
HasLedStripGPIO
};

struct SwitchInfo
Expand Down
8 changes: 6 additions & 2 deletions companion/src/firmwares/customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ QString CustomFunctionData::funcToString(const AssignFunc func, const ModelData
return tr("Set Main Screen");
else if (func == FuncDisableAudioAmp)
return tr("Audio Amp Off");
else if (func == FuncRGBLed)
return tr("RGB leds");
else {
return QString(CPN_STR_UNKNOWN_ITEM);
}
Expand Down Expand Up @@ -260,7 +262,8 @@ bool CustomFunctionData::isFuncAvailable(const int index, const ModelData * mode
((index >= FuncAdjustGV1 && index <= FuncAdjustGVLast) && !fw->getCapability(Gvars)) ||
((index == FuncDisableTouch) && !IS_HORUS_OR_TARANIS(fw->getBoard())) ||
((index == FuncSetScreen && !Boards::getCapability(fw->getBoard(), Board::HasColorLcd)) ||
((index == FuncDisableAudioAmp && !Boards::getCapability(fw->getBoard(), Board::HasAudioMuteGPIO))))
((index == FuncDisableAudioAmp && !Boards::getCapability(fw->getBoard(), Board::HasAudioMuteGPIO))) ||
((index == FuncRGBLed && !Boards::getCapability(fw->getBoard(), Board::HasLedStripGPIO))))
);
return !ret;
}
Expand Down Expand Up @@ -475,7 +478,8 @@ bool CustomFunctionData::isParamAvailable() const
FuncBindExternalModule,
FuncRacingMode,
FuncDisableTouch,
FuncDisableAudioAmp
FuncDisableAudioAmp,
FuncRGBLed
};

return funcList.contains(func) ? false : true;
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/customfunctiondata.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum AssignFunc {
FuncDisableTouch,
FuncSetScreen,
FuncDisableAudioAmp,
FuncRGBLed,
FuncCount,
FuncReserve = -1
};
Expand Down
10 changes: 7 additions & 3 deletions companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ static bool fnHasRepeat(AssignFunc fn)
|| (fn == FuncPlayHaptic)
|| (fn == FuncPlaySound)
|| (fn == FuncSetScreen)
|| (fn == FuncPlayScript);
|| (fn == FuncPlayScript)
|| (fn == FuncRGBLed);
}

static const YamlLookupTable customFnLut = {
Expand Down Expand Up @@ -68,6 +69,7 @@ static const YamlLookupTable customFnLut = {
{ FuncDisableTouch, "DISABLE_TOUCH" },
{ FuncSetScreen, "SET_SCREEN"},
{ FuncDisableAudioAmp, "DISABLE_AUDIO_AMP" },
{ FuncRGBLed, "RGB_LED" },
};

static const YamlLookupTable trainerLut = {
Expand Down Expand Up @@ -172,6 +174,7 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
def += temp;
} break;
case FuncPlayScript:
case FuncRGBLed:
def += std::string(rhs.paramarm);
break;
case FuncReset:
Expand Down Expand Up @@ -232,7 +235,7 @@ Node convert<CustomFunctionData>::encode(const CustomFunctionData& rhs)
if (add_comma) {
def += ",";
}
if (rhs.func == FuncPlayScript) {
if (rhs.func == FuncPlayScript || rhs.func == FuncRGBLed) {
def += ((rhs.repeatParam == 0) ? "On" : "1x");
} else if (rhs.repeatParam == 0) {
def += "1x";
Expand Down Expand Up @@ -297,6 +300,7 @@ bool convert<CustomFunctionData>::decode(const Node& node,
file_str.resize(getCurrentFirmware()->getCapability(VoicesMaxLength));
strncpy(rhs.paramarm, file_str.c_str(), sizeof(rhs.paramarm) - 1);
} break;
case FuncRGBLed:
case FuncPlayScript: {
std::string file_str;
getline(def, file_str, ',');
Expand Down Expand Up @@ -388,7 +392,7 @@ bool convert<CustomFunctionData>::decode(const Node& node,
} else if(fnHasRepeat(rhs.func)) {
std::string repeat;
getline(def, repeat);
if (rhs.func == FuncPlayScript) {
if (rhs.func == FuncPlayScript || rhs.func == FuncRGBLed) {
rhs.repeatParam = (repeat == "1x") ? 1 : 0;
} else if (repeat == "1x") {
rhs.repeatParam = 0;
Expand Down
18 changes: 15 additions & 3 deletions companion/src/modeledit/customfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
}
}

if (IS_STM32(firmware->getBoard())) {
scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/RGBLED", QStringList() << "*.lua", firmware->getCapability(VoicesMaxLength));
for (int i = 0; i < fswCapability; i++) {
if (functions[i].func == FuncRGBLed) {
QString temp = functions[i].paramarm;
if (!temp.isEmpty()) {
scriptsSet.insert(temp);
}
}
}
}

CompanionIcon playIcon("play.png");
playIcon.addImage("stop.png", QIcon::Normal, QIcon::On);

Expand Down Expand Up @@ -194,7 +206,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model,
tableLayout->addLayout(i, 4, repeatLayout);
fswtchRepeat[i] = new QComboBox(this);
fswtchRepeat[i]->setProperty("index", i);
if (functions[i].func == FuncPlayScript)
if (functions[i].func == FuncPlayScript || functions[i].func == FuncRGBLed)
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatLuaId));
else
fswtchRepeat[i]->setModel(tabModelFactory->getItemModel(repeatId));
Expand Down Expand Up @@ -339,7 +351,7 @@ void CustomFunctionsPanel::functionEdited()
functions[index].clear();
functions[index].swtch = swtch;
functions[index].func = (AssignFunc)fswtchFunc[index]->currentData().toInt();
if (functions[index].func == FuncPlayScript)
if (functions[index].func == FuncPlayScript || functions[index].func == FuncRGBLed)
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatLuaId));
else
fswtchRepeat[index]->setModel(tabModelFactory->getItemModel(repeatId));
Expand Down Expand Up @@ -541,7 +553,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
}
}
else if (func == FuncPlayScript) {
else if (func == FuncPlayScript || func == FuncRGBLed) {
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM | CUSTOM_FUNCTION_REPEAT;
if (modified) {
Helpers::getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8);
Expand Down
5 changes: 3 additions & 2 deletions radio/src/boards/generic_stm32/module_ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "hal/module_port.h"
#include "stm32_serial_driver.h"
#include "stm32_softserial_driver.h"
#include "stm32_dma.h"

#include "module_ports.h"
#include "board.h"
Expand Down Expand Up @@ -86,7 +87,7 @@ static_assert(__STM32_PULSE_IS_TIMER_CHANNEL_SUPPORTED(INTMODULE_TIMER_Channel),
"Unsupported timer channel");

// Make sure the DMA channel is supported
static_assert(__STM32_PULSE_IS_DMA_STREAM_SUPPORTED(INTMODULE_TIMER_DMA_STREAM),
static_assert(__STM32_DMA_IS_STREAM_SUPPORTED(INTMODULE_TIMER_DMA_STREAM),
"Unsupported DMA stream");

#if !defined(INTMODULE_TIMER_DMA_IRQHandler)
Expand Down Expand Up @@ -198,7 +199,7 @@ static_assert(__STM32_PULSE_IS_TIMER_CHANNEL_SUPPORTED(EXTMODULE_TIMER_Channel),
"Unsupported timer channel");

// Make sure the DMA channel is supported
static_assert(__STM32_PULSE_IS_DMA_STREAM_SUPPORTED(EXTMODULE_TIMER_DMA_STREAM_LL),
static_assert(__STM32_DMA_IS_STREAM_SUPPORTED(EXTMODULE_TIMER_DMA_STREAM_LL),
"Unsupported DMA stream");

#if !defined(EXTMODULE_TIMER_DMA_IRQHandler)
Expand Down
115 changes: 115 additions & 0 deletions radio/src/boards/generic_stm32/rgb_leds.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* 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 "stm32_pulse_driver.h"
#include "rgb_leds.h"
#include "hal.h"
#include "opentx.h"

#if defined(LED_STRIP_GPIO)

#include "stm32_ws2812.h"
#include "stm32_dma.h"

#if !defined(SIMU)
#include <FreeRTOS/include/FreeRTOS.h>
#include <FreeRTOS/include/timers.h>
#endif

extern const stm32_pulse_timer_t _led_timer;

static TimerHandle_t rgbLedTimer = nullptr;
static StaticTimer_t rgbLedTimerBuffer;

void rgbSetLedColor(uint8_t led, uint8_t r, uint8_t g, uint8_t b)
{
ws2812_set_color(led, r, g, b);
}

void rgbLedColorApply()
{
ws2812_update(&_led_timer);;
}

static void rgbLedTimerCb(TimerHandle_t xTimer)
{
(void)xTimer;

ws2812_update(&_led_timer);
}

void rgbLedStart()
{
if (!rgbLedTimer) {
rgbLedTimer =
xTimerCreateStatic("rgbLed", LED_STRIP_REFRESH_PERIOD / RTOS_MS_PER_TICK, pdTRUE, (void*)0,
rgbLedTimerCb, &rgbLedTimerBuffer);
}

if (rgbLedTimer) {
if( xTimerStart( rgbLedTimer, 0 ) != pdPASS ) {
/* The timer could not be set into the Active state. */
}
}
}

void rgbLedStop()
{
if (rgbLedTimer) {
if( xTimerStop( rgbLedTimer, 5 / RTOS_MS_PER_TICK ) != pdPASS ) {
/* The timer could not be stopped. */
}
}
}

const stm32_pulse_timer_t _led_timer = {
.GPIOx = LED_STRIP_GPIO,
.GPIO_Pin = LED_STRIP_GPIO_PIN_DATA,
.GPIO_Alternate = LED_STRIP_GPIO_PIN_AF,
.TIMx = LED_STRIP_TIMER,
.TIM_Freq = LED_STRIP_TIMER_FREQ,
.TIM_Channel = LED_STRIP_TIMER_CHANNEL,
.TIM_IRQn = (IRQn_Type)-1,
.DMAx = LED_STRIP_TIMER_DMA,
.DMA_Stream = LED_STRIP_TIMER_DMA_STREAM,
.DMA_Channel = LED_STRIP_TIMER_DMA_CHANNEL,
.DMA_IRQn = LED_STRIP_TIMER_DMA_IRQn,
.DMA_TC_CallbackPtr = nullptr,
};

// Make sure the timer channel is supported
static_assert(__STM32_PULSE_IS_TIMER_CHANNEL_SUPPORTED(LED_STRIP_TIMER_CHANNEL),
"Unsupported timer channel");

// Make sure the DMA channel is supported
static_assert(__STM32_DMA_IS_STREAM_SUPPORTED(LED_STRIP_TIMER_DMA_STREAM),
"Unsupported DMA stream");

#if !defined(LED_STRIP_TIMER_DMA_IRQHandler)
#error "Missing LED_STRIP_TIMER_DMA_IRQHandler definition"
#endif

extern "C" void LED_STRIP_TIMER_DMA_IRQHandler()
{
ws2812_dma_isr(&_led_timer);
}

#endif
29 changes: 29 additions & 0 deletions radio/src/boards/generic_stm32/rgb_leds.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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

void rgbLedStart();
void rgbLedStop();
void rgbSetLedColor(unsigned char, unsigned char, unsigned char, unsigned char);
void rgbLedColorApply();

// void boardInitRGBLed();
1 change: 1 addition & 0 deletions radio/src/dataconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ enum Functions {
FUNC_SET_SCREEN,
#endif
FUNC_DISABLE_AUDIO_AMP,
FUNC_RGB_LED,
#if defined(DEBUG)
FUNC_TEST, // should remain the last before MAX as not added in Companion
#endif
Expand Down
3 changes: 3 additions & 0 deletions radio/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "opentx.h"
#include "switches.h"
#include "boards/generic_stm32/rgb_leds.h"

#if defined(COLORLCD)
void setRequestedMainView(uint8_t view);
Expand Down Expand Up @@ -542,6 +543,8 @@ const char* funcGetLabel(uint8_t func)
case FUNC_DISABLE_AUDIO_AMP:
return STR_SF_DISABLE_AUDIO_AMP;
#endif
case FUNC_RGB_LED:
return STR_SF_RGBLEDS;
#if defined(DEBUG)
case FUNC_TEST:
return STR_SF_TEST;
Expand Down
12 changes: 9 additions & 3 deletions radio/src/gui/128x64/model_special_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
if (func == FUNC_PLAY_SCRIPT) {
strcpy(directory, SCRIPTS_FUNCS_PATH);
}
else if (func == FUNC_RGB_LED) {
strcpy(directory, SCRIPTS_RGB_PATH);
}
else {
strcpy(directory, SOUNDS_PATH);
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
Expand Down Expand Up @@ -305,7 +308,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
#endif
#if defined(SDCARD)
else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT) {
else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT || func==FUNC_RGB_LED) {
if (ZEXIST(cfn->play.name))
lcdDrawSizedText(MODEL_SPECIAL_FUNC_3RD_COLUMN-6, y, cfn->play.name, sizeof(cfn->play.name), attr);
else
Expand All @@ -316,15 +319,18 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
if (func==FUNC_PLAY_SCRIPT) {
strcpy(directory, SCRIPTS_FUNCS_PATH);
}
else if (func==FUNC_RGB_LED) {
strcpy(directory, SCRIPTS_RGB_PATH);
}
else {
strcpy(directory, SOUNDS_PATH);
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
}
if (sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) {
if (sdListFiles(directory, func==FUNC_PLAY_SCRIPT || func==FUNC_RGB_LED ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) {
POPUP_MENU_START(onCustomFunctionsFileSelectionMenu);
}
else {
POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
POPUP_WARNING(func==FUNC_PLAY_SCRIPT || func==FUNC_RGB_LED ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD);
}
}
break;
Expand Down
Loading

0 comments on commit 2bd6fd4

Please sign in to comment.