mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 12:55:12 +03:00
[X10 Express] Radio / Tools started
This commit is contained in:
parent
4d520368f7
commit
353c59b0e0
10 changed files with 215 additions and 7 deletions
BIN
radio/sdcard/horus/THEMES/Default/mask_radio_tools.png
Executable file
BIN
radio/sdcard/horus/THEMES/Default/mask_radio_tools.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -23,7 +23,9 @@
|
|||
const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
|
||||
menuRadioSetup,
|
||||
menuRadioSdManager,
|
||||
#if defined(LUA) || defined(PXX2)
|
||||
menuRadioTools,
|
||||
#endif
|
||||
menuRadioSpecialFunctions,
|
||||
menuRadioTrainer,
|
||||
menuRadioHardware,
|
||||
|
|
|
@ -54,7 +54,9 @@ void menuTraceBuffer(event_t event);
|
|||
enum MenuRadioIndexes {
|
||||
MENU_RADIO_SETUP,
|
||||
MENU_RADIO_SD_MANAGER,
|
||||
#if defined(LUA) || defined(PXX2)
|
||||
MENU_RADIO_TOOLS,
|
||||
#endif
|
||||
MENU_RADIO_SPECIAL_FUNCTIONS,
|
||||
MENU_RADIO_TRAINER,
|
||||
MENU_RADIO_HARDWARE,
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
|
||||
menuRadioSetup,
|
||||
menuRadioSdManager,
|
||||
#if defined(LUA) || defined(PXX2)
|
||||
menuRadioTools,
|
||||
#endif
|
||||
menuRadioSpecialFunctions,
|
||||
menuRadioTrainer,
|
||||
menuRadioHardware,
|
||||
|
|
|
@ -67,7 +67,8 @@ enum MenuIcons {
|
|||
ICON_OPENTX,
|
||||
ICON_RADIO,
|
||||
ICON_RADIO_SETUP,
|
||||
ICON_RADIO_SD_BROWSER,
|
||||
ICON_RADIO_SD_MANAGER,
|
||||
ICON_RADIO_TOOLS,
|
||||
ICON_RADIO_GLOBAL_FUNCTIONS,
|
||||
ICON_RADIO_TRAINER,
|
||||
ICON_RADIO_HARDWARE,
|
||||
|
@ -187,6 +188,9 @@ extern const MenuHandlerFunc menuTabModel[MENU_MODEL_PAGES_COUNT];
|
|||
enum EnumTabRadio {
|
||||
MENU_RADIO_SETUP,
|
||||
MENU_RADIO_SD_MANAGER,
|
||||
#if defined(LUA) || defined(PXX2)
|
||||
MENU_RADIO_TOOLS,
|
||||
#endif
|
||||
MENU_RADIO_SPECIAL_FUNCTIONS,
|
||||
MENU_RADIO_TRAINER,
|
||||
MENU_RADIO_HARDWARE,
|
||||
|
@ -197,7 +201,10 @@ enum EnumTabRadio {
|
|||
const uint8_t RADIO_ICONS[MENU_RADIO_PAGES_COUNT + 1] = {
|
||||
ICON_RADIO,
|
||||
ICON_RADIO_SETUP,
|
||||
ICON_RADIO_SD_BROWSER,
|
||||
ICON_RADIO_SD_MANAGER,
|
||||
#if defined(LUA) || defined(PXX2)
|
||||
ICON_RADIO_TOOLS,
|
||||
#endif
|
||||
ICON_RADIO_GLOBAL_FUNCTIONS,
|
||||
ICON_RADIO_TRAINER,
|
||||
ICON_RADIO_HARDWARE,
|
||||
|
@ -212,6 +219,8 @@ bool menuRadioTrainer(event_t event);
|
|||
bool menuRadioVersion(event_t event);
|
||||
bool menuRadioHardware(event_t event);
|
||||
bool menuRadioCalibration(event_t event);
|
||||
bool menuRadioSpectrumAnalyser(event_t event);
|
||||
bool menuRadioPowerMeter(event_t event);
|
||||
|
||||
extern const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT];
|
||||
|
||||
|
@ -265,8 +274,6 @@ bool menuAboutView(event_t event);
|
|||
bool menuMainViewChannelsMonitor(event_t event);
|
||||
bool menuTextView(event_t event);
|
||||
bool menuScreensTheme(event_t event);
|
||||
bool menuRadioSpectrumAnalyser(event_t event);
|
||||
bool menuRadioPowerMeter(event_t event);
|
||||
|
||||
extern int8_t checkIncDec_Ret; // global helper vars
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ BitmapBuffer * currentBitmap = NULL;
|
|||
|
||||
bool menuRadioSdManagerInfo(event_t event)
|
||||
{
|
||||
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, ICON_RADIO_SD_BROWSER, 1);
|
||||
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, ICON_RADIO_SD_MANAGER, 1);
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, 2*FH, STR_SD_TYPE);
|
||||
lcdDrawText(100, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD);
|
||||
|
|
180
radio/src/gui/480x272/radio_tools.cpp
Normal file
180
radio/src/gui/480x272/radio_tools.cpp
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* 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 <algorithm>
|
||||
#include "opentx.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
bool addRadioTool(uint8_t index, const char * label)
|
||||
{
|
||||
int8_t sub = menuVerticalPosition - HEADER_LINE;
|
||||
LcdFlags attr = (sub == index ? INVERS : 0);
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + index * FH;
|
||||
lcdDrawNumber(3, y, index + 1, LEADING0|LEFT, 2);
|
||||
// BSS lcdDrawText(3*FW, y, label, (sub == index ? INVERS : 0));
|
||||
if (attr && s_editMode > 0) {
|
||||
s_editMode = 0;
|
||||
killAllEvents();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void addRadioModuleTool(uint8_t index, const char * label, bool (* tool)(event_t), uint8_t module)
|
||||
{
|
||||
if (addRadioTool(index, label)) {
|
||||
g_moduleIdx = module;
|
||||
pushMenu(tool);
|
||||
}
|
||||
}
|
||||
|
||||
#define TOOL_NAME_MAXLEN 16
|
||||
|
||||
#if defined(LUA)
|
||||
bool readToolName(const char * filename, char * name)
|
||||
{
|
||||
FIL file;
|
||||
char buffer[1024];
|
||||
UINT count;
|
||||
|
||||
if (f_open(&file, filename, FA_READ) != FR_OK) {
|
||||
return "Error opening file";
|
||||
}
|
||||
|
||||
if (f_read(&file, &buffer, sizeof(buffer), &count) != FR_OK) {
|
||||
f_close(&file);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * tns = "TNS|";
|
||||
auto * start = std::search(buffer, buffer + sizeof(buffer), tns, tns + 4);
|
||||
if (start >= buffer + sizeof(buffer))
|
||||
return false;
|
||||
|
||||
start += 4;
|
||||
|
||||
const char * tne = "|TNE";
|
||||
auto * end = std::search(buffer, buffer + sizeof(buffer), tne, tne + 4);
|
||||
if (end >= buffer + sizeof(buffer) || end <= start)
|
||||
return false;
|
||||
|
||||
uint8_t len = end - start;
|
||||
if (len > TOOL_NAME_MAXLEN)
|
||||
return false;
|
||||
|
||||
strncpy(name, start, len);
|
||||
memclear(name + len, TOOL_NAME_MAXLEN + 1 - len);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void addRadioScriptTool(uint8_t index, const char * path)
|
||||
{
|
||||
char toolName[TOOL_NAME_MAXLEN + 1];
|
||||
const char * label;
|
||||
char * ext = (char *)getFileExtension(path);
|
||||
if (readToolName(path, toolName)) {
|
||||
label = toolName;
|
||||
}
|
||||
else {
|
||||
*ext = '\0';
|
||||
label = getBasename(path);
|
||||
}
|
||||
|
||||
if (addRadioTool(index, label)) {
|
||||
f_chdir("/SCRIPTS/TOOLS/");
|
||||
*ext = '.';
|
||||
luaExec(path);
|
||||
}
|
||||
}
|
||||
|
||||
bool isRadioScriptTool(const char * filename)
|
||||
{
|
||||
const char * ext = getFileExtension(filename);
|
||||
return ext && !strcasecmp(ext, SCRIPT_EXT);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool menuRadioTools(event_t event)
|
||||
{
|
||||
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
|
||||
memclear(&reusableBuffer.radioTools, sizeof(reusableBuffer.radioTools));
|
||||
#if defined(PXX2)
|
||||
for (uint8_t module = 0; module < NUM_MODULES; module++) {
|
||||
if (isModulePXX2(module) && (module == INTERNAL_MODULE ? IS_INTERNAL_MODULE_ON() : IS_EXTERNAL_MODULE_ON())) {
|
||||
moduleState[module].readModuleInformation(&reusableBuffer.radioTools.modules[module], PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SIMPLE_MENU(STR_MENUTOOLS, RADIO_ICONS, menuTabGeneral, MENU_RADIO_TOOLS, HEADER_LINE + reusableBuffer.radioTools.linesCount);
|
||||
|
||||
uint8_t index = 0;
|
||||
|
||||
#if 0 // TODO BSS defined(PXX2)
|
||||
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
|
||||
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_INT, menuRadioSpectrumAnalyser, INTERNAL_MODULE);
|
||||
|
||||
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
|
||||
addRadioModuleTool(index++, STR_POWER_METER_INT, menuRadioPowerMeter, INTERNAL_MODULE);
|
||||
|
||||
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
|
||||
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_EXT, menuRadioSpectrumAnalyser, EXTERNAL_MODULE);
|
||||
|
||||
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
|
||||
addRadioModuleTool(index++, STR_POWER_METER_EXT, menuRadioPowerMeter, EXTERNAL_MODULE);
|
||||
#endif
|
||||
|
||||
#if defined(LUA)
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
|
||||
#if defined(CROSSFIRE)
|
||||
if(isFileAvailable(SCRIPTS_TOOLS_PATH "/CROSSFIRE/crossfire.lua"))
|
||||
addRadioScriptTool(index++, SCRIPTS_TOOLS_PATH "/CROSSFIRE/crossfire.lua");
|
||||
#endif
|
||||
|
||||
FRESULT res = f_opendir(&dir, SCRIPTS_TOOLS_PATH);
|
||||
if (res == FR_OK) {
|
||||
for (;;) {
|
||||
TCHAR path[_MAX_LFN+1] = SCRIPTS_TOOLS_PATH "/";
|
||||
res = f_readdir(&dir, &fno); /* Read a directory item */
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
||||
if (fno.fattrib & AM_DIR) continue; /* Skip subfolders */
|
||||
if (fno.fattrib & AM_HID) continue; /* Skip hidden files */
|
||||
if (fno.fattrib & AM_SYS) continue; /* Skip system files */
|
||||
|
||||
strcat(path, fno.fname);
|
||||
if (isRadioScriptTool(fno.fname))
|
||||
addRadioScriptTool(index++, path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (index == 0) {
|
||||
lcdDrawCenteredText(LCD_H/2, STR_NO_TOOLS);
|
||||
}
|
||||
|
||||
reusableBuffer.radioTools.linesCount = index;
|
||||
|
||||
return true;
|
||||
}
|
|
@ -83,7 +83,8 @@ class DarkblueTheme: public Theme
|
|||
loadMenuIcon(ICON_OPENTX, "mask_opentx.png");
|
||||
loadMenuIcon(ICON_RADIO, "mask_menu_radio.png");
|
||||
loadMenuIcon(ICON_RADIO_SETUP, "mask_radio_setup.png");
|
||||
loadMenuIcon(ICON_RADIO_SD_BROWSER, "mask_radio_sd_browser.png");
|
||||
loadMenuIcon(ICON_RADIO_SD_MANAGER, "mask_radio_sd_browser.png");
|
||||
loadMenuIcon(ICON_RADIO_TOOLS, "mask_radio_tools.png");
|
||||
loadMenuIcon(ICON_RADIO_GLOBAL_FUNCTIONS, "mask_radio_global_functions.png");
|
||||
loadMenuIcon(ICON_RADIO_TRAINER, "mask_radio_trainer.png");
|
||||
loadMenuIcon(ICON_RADIO_HARDWARE, "mask_radio_hardware.png");
|
||||
|
|
|
@ -98,7 +98,8 @@ class DefaultTheme: public Theme
|
|||
#endif
|
||||
loadMenuIcon(ICON_RADIO, "mask_menu_radio.png");
|
||||
loadMenuIcon(ICON_RADIO_SETUP, "mask_radio_setup.png");
|
||||
loadMenuIcon(ICON_RADIO_SD_BROWSER, "mask_radio_sd_browser.png");
|
||||
loadMenuIcon(ICON_RADIO_SD_MANAGER, "mask_radio_sd_browser.png");
|
||||
loadMenuIcon(ICON_RADIO_TOOLS, "mask_radio_tools.png");
|
||||
loadMenuIcon(ICON_RADIO_GLOBAL_FUNCTIONS, "mask_radio_global_functions.png");
|
||||
loadMenuIcon(ICON_RADIO_TRAINER, "mask_radio_trainer.png");
|
||||
loadMenuIcon(ICON_RADIO_HARDWARE, "mask_radio_hardware.png");
|
||||
|
|
|
@ -119,6 +119,18 @@ set(GUI_SRC
|
|||
rle.cpp
|
||||
)
|
||||
|
||||
if(PXX2 OR LUA)
|
||||
set(GUI_SRC ${GUI_SRC} radio_tools.cpp)
|
||||
endif()
|
||||
|
||||
#if(PXX2)
|
||||
# set(GUI_SRC
|
||||
# ${GUI_SRC}
|
||||
# ../common/stdlcd/radio_spectrum_analyser.cpp
|
||||
# ../common/stdlcd/radio_power_meter.cpp
|
||||
# )
|
||||
#endif()
|
||||
|
||||
if(DISK_CACHE)
|
||||
set(SRC ${SRC} disk_cache.cpp)
|
||||
add_definitions(-DDISK_CACHE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue