Remove obsoleted code

This commit is contained in:
Raphael Coeffic
2021-05-24 16:23:06 +02:00
committed by Raphael Coeffic
parent cee24fe013
commit 6b9abe0670
14 changed files with 54 additions and 1083 deletions
+1 -7
View File
@@ -95,15 +95,9 @@ endif()
if(LUA STREQUAL YES)
set(SRC ${SRC} lua/widgets.cpp)
# TODO set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp)
endif()
set(SRC
${SRC}
stubs.cpp
storage/modelslist.cpp
)
set(SRC ${SRC} storage/modelslist.cpp)
option(WINDOWS_INSPECT_BORDERS "Draw bounding boxes around windows" OFF)
if(WINDOWS_INSPECT_BORDERS)
+33
View File
@@ -117,9 +117,42 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char
}
}
WDG_RESET();
lcdRefresh();
}
void drawFatalErrorScreen(const char * message)
{
lcd->clear();
lcd->drawText(LCD_W/2, LCD_H/2-20, message, FONT(XL)|CENTERED|ALARM_COLOR);
WDG_RESET();
lcdRefresh();
}
void runFatalErrorScreen(const char * message)
{
while (true) {
backlightEnable(100);
drawFatalErrorScreen(message);
uint8_t refresh = false;
while (true) {
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
boardOff();
return; // only happens in SIMU, required for proper shutdown
}
else if (pwr_check == e_power_press) {
refresh = true;
}
else if (pwr_check == e_power_on && refresh) {
break;
}
}
}
}
void drawCurveRef(BitmapBuffer * dc, coord_t x, coord_t y, const CurveRef & curve, LcdFlags flags)
{
if (curve.value != 0) {
-247
View File
@@ -23,32 +23,8 @@
#include "keys.h"
#define MIXES_2ND_COLUMN 140
extern int menuVerticalPosition;
extern int menuHorizontalPosition;
extern int menuVerticalOffset;
extern uint8_t menuCalibrationState;
// Temporary no highlight
typedef bool (*MenuHandlerFunc)(event_t event);
extern MenuHandlerFunc menuHandlers[5];
extern uint8_t menuVerticalPositions[4];
extern uint8_t menuLevel;
extern event_t menuEvent;
void chainMenu(MenuHandlerFunc newMenu);
void pushMenu(MenuHandlerFunc newMenu);
void popMenu();
void abortPopMenu();
inline bool isModelMenuDisplayed()
{
return menuVerticalPositions[0] == 0;
}
enum MenuIcons {
ICON_OPENTX,
#if defined(HARDWARE_TOUCH)
@@ -100,188 +76,6 @@ enum MenuIcons {
MENUS_ICONS_COUNT
};
enum EnumTabModel {
MENU_MODEL_SETUP,
CASE_HELI(MENU_MODEL_HELI)
CASE_FLIGHT_MODES(MENU_MODEL_FLIGHT_MODES)
MENU_MODEL_INPUTS,
MENU_MODEL_MIXES,
MENU_MODEL_OUTPUTS,
MENU_MODEL_CURVES,
CASE_GVARS(MENU_MODEL_GVARS)
MENU_MODEL_LOGICAL_SWITCHES,
MENU_MODEL_SPECIAL_FUNCTIONS,
#if defined(LUA_MODEL_SCRIPTS)
MENU_MODEL_CUSTOM_SCRIPTS,
#endif
MENU_MODEL_TELEMETRY,
MENU_MODEL_PAGES_COUNT
};
const uint8_t MODEL_ICONS[MENU_MODEL_PAGES_COUNT + 1] = {
ICON_MODEL,
ICON_MODEL_SETUP,
CASE_HELI(ICON_MODEL_HELI)
CASE_FLIGHT_MODES(ICON_MODEL_FLIGHT_MODES)
ICON_MODEL_INPUTS,
ICON_MODEL_MIXER,
ICON_MODEL_OUTPUTS,
ICON_MODEL_CURVES,
CASE_GVARS(ICON_MODEL_GVARS)
ICON_MODEL_LOGICAL_SWITCHES,
ICON_MODEL_SPECIAL_FUNCTIONS,
#if defined(LUA_MODEL_SCRIPTS)
ICON_MODEL_LUA_SCRIPTS,
#endif
ICON_MODEL_TELEMETRY
};
const uint8_t STATS_ICONS[] = {
ICON_STATS,
ICON_STATS_THROTTLE_GRAPH,
ICON_STATS_DEBUG,
ICON_STATS_ANALOGS,
#if defined(DEBUG_TRACE_BUFFER)
ICON_STATS_TIMERS
#endif
};
const uint8_t MONITOR_ICONS[] = {
ICON_MONITOR,
ICON_MONITOR_CHANNELS1,
ICON_MONITOR_CHANNELS2,
ICON_MONITOR_CHANNELS3,
ICON_MONITOR_CHANNELS4,
ICON_MONITOR_LOGICAL_SWITCHES
};
bool menuModelSetup(event_t event);
bool menuModelFailsafe(event_t event);
bool menuModelHeli(event_t event);
bool menuModelFlightModesAll(event_t event);
bool menuModelExposAll(event_t event);
bool menuModelMixAll(event_t event);
bool menuModelLimits(event_t event);
bool menuModelCurvesAll(event_t event);
bool menuModelCurveOne(event_t event);
bool menuModelGVars(event_t event);
bool menuModelLogicalSwitches(event_t event);
bool menuModelSpecialFunctions(event_t event);
bool menuModelCustomScripts(event_t event);
bool menuModelTelemetryFrsky(event_t event);
bool menuModelSensor(event_t event);
bool menuModelExpoOne(event_t event);
extern const MenuHandlerFunc menuTabModel[MENU_MODEL_PAGES_COUNT];
enum EnumTabRadio {
MENU_RADIO_SETUP,
MENU_RADIO_SD_MANAGER,
MENU_RADIO_TOOLS,
MENU_RADIO_SPECIAL_FUNCTIONS,
MENU_RADIO_TRAINER,
MENU_RADIO_HARDWARE,
MENU_RADIO_VERSION,
MENU_RADIO_PAGES_COUNT
};
const uint8_t RADIO_ICONS[MENU_RADIO_PAGES_COUNT + 1] = {
ICON_RADIO,
ICON_RADIO_SETUP,
ICON_RADIO_SD_MANAGER,
ICON_RADIO_TOOLS,
ICON_RADIO_GLOBAL_FUNCTIONS,
ICON_RADIO_TRAINER,
ICON_RADIO_HARDWARE,
ICON_RADIO_VERSION
};
bool menuRadioSetup(event_t event);
bool menuRadioSdManager(event_t event);
bool menuRadioTools(event_t event);
bool menuRadioSpecialFunctions(event_t event);
bool menuRadioTrainer(event_t event);
bool menuRadioVersion(event_t event);
bool menuRadioHardware(event_t event);
bool menuRadioCalibration(event_t event);
extern const MenuHandlerFunc menuTabGeneral[MENU_RADIO_PAGES_COUNT];
enum MenuRadioIndexes
{
e_StatsGraph,
e_StatsDebug,
e_StatsAnalogs,
#if defined(DEBUG_TRACE_BUFFER)
e_StatsTraces,
#endif
};
bool menuStatsGraph(event_t event);
bool menuStatsDebug(event_t event);
bool menuStatsAnalogs(event_t event);
bool menuStatsTraces(event_t event);
enum EnumTabMonitors
{
e_MonChannelsFirst,
e_MonChannels1 = e_MonChannelsFirst,
e_MonChannels2,
e_MonChannels3,
e_MonChannels4,
e_MonLogicalSwitches,
e_MonTabChannelsPagesCount
};
extern const MenuHandlerFunc menuTabMonitors[e_MonTabChannelsPagesCount];
extern uint8_t lastMonitorPage;
extern void drawSingleMixerBar(coord_t, coord_t, coord_t, coord_t, uint8_t);
extern void drawSingleOutputBar(coord_t, coord_t, coord_t, coord_t, uint8_t);
extern const MenuHandlerFunc menuTabScreensSetup[1+MAX_CUSTOM_SCREENS] ;
bool menuFirstCalib(event_t event);
bool menuMainView(event_t event);
bool menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
bool menuModelSelect(event_t event);
bool menuAboutView(event_t event);
bool menuMainViewChannelsMonitor(event_t event);
bool menuTextView(event_t event);
bool menuScreensTheme(event_t event);
bool menuRadioGhostModuleConfig(event_t event);
bool menuRadioPowerMeter(event_t event);
extern int8_t checkIncDec_Ret; // global helper vars
#define EDIT_SELECT_FIELD 0
#define EDIT_MODIFY_FIELD 1
#define EDIT_MODIFY_STRING 2
extern int8_t s_editMode; // global editmode
// checkIncDec flags
#define EE_GENERAL 0x01
#define EE_MODEL 0x02
#define NO_INCDEC_MARKS 0x04
#define INCDEC_SWITCH 0x08
#define INCDEC_SOURCE 0x10
#define INCDEC_REP10 0x40
#define NO_DBLKEYS 0x80
// mawrow special values
//#define READONLY_ROW ((uint8_t)-1)
//#define TITLE_ROW READONLY_ROW
//#define ORPHAN_ROW ((uint8_t)-2)
//#define HIDDEN_ROW ((uint8_t)-3)
//#define NAVIGATION_LINE_BY_LINE 0x40
//#define CURSOR_ON_LINE() (menuHorizontalPosition<0)
extern uint8_t s_currIdxSubMenu;
extern const char * warningText;
extern const char * warningInfoText;
extern uint8_t warningInfoLength;
extern uint8_t warningResult;
extern uint8_t warningType;
#define COPY_MODE 1
#define MOVE_MODE 2
@@ -302,48 +96,7 @@ void deleteMix(uint8_t idx);
void insertMix(uint8_t idx);
void copyMix(uint8_t source, uint8_t dest, int8_t ch);
#define MENU_X 80
#define MENU_W LCD_W-(2*MENU_X)
#define POPUP_X 120
#define POPUP_Y 70
#define WARNING_LINE_LEN 32
#define WARNING_LINE_X (POPUP_X+66)
#define WARNING_LINE_Y (POPUP_Y+9)
void copySelection(char * dst, const char * src, uint8_t size);
void showMessageBox(const char * title);
void runPopupWarning(event_t event);
extern void (* popupFunc)(event_t event);
extern uint8_t warningInfoFlags;
#define DISPLAY_WARNING(evt) (*popupFunc)(evt)
#define POPUP_INPUT(s, func) (warningText = s, popupFunc = func)
#define POPUP_MENU_MAX_LINES 12
#define MENU_MAX_DISPLAY_LINES 9
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
extern const char * popupMenuItems[POPUP_MENU_MAX_LINES];
extern uint16_t popupMenuItemsCount;
extern uint16_t popupMenuOffset;
enum {
MENU_OFFSET_INTERNAL,
MENU_OFFSET_EXTERNAL
};
extern uint8_t popupMenuOffsetType;
extern uint8_t popupMenuSelectedItem;
const char * runPopupMenu(event_t event);
extern void (*popupMenuHandler)(const char * result);
void pushMenuTextView(const char * filename);
void pushModelNotes();
void readModelNotes();
typedef int (*FnFuncP) (int x);
void drawFunction(FnFuncP fn, int x, int y, int width);
void onSourceLongEnterPress(const char *result);
uint8_t switchToMix(uint8_t source);
#endif // _MENUS_H_
@@ -1,174 +0,0 @@
/*
* 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 "opentx.h"
void onModelCustomScriptMenu(const char *result)
{
ScriptData &sd = g_model.scriptsData[s_currIdx];
if (result == STR_UPDATE_LIST) {
if (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), nullptr)) {
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
}
}
else {
// The user choosed a lua file in the list
copySelection(sd.file, result, sizeof(sd.file));
memset(sd.inputs, 0, sizeof(sd.inputs));
storageDirty(EE_MODEL);
LUA_LOAD_MODEL_SCRIPT(s_currIdx);
}
}
enum menuModelCustomScriptItems {
ITEM_MODEL_CUSTOMSCRIPT_FILE,
ITEM_MODEL_CUSTOMSCRIPT_NAME,
ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL,
};
#define SCRIPT_ONE_2ND_COLUMN_POS (120)
#define SCRIPT_ONE_3RD_COLUMN_POS (240)
bool menuModelCustomScriptOne(event_t event)
{
ScriptData &sd = g_model.scriptsData[s_currIdx];
// drawStringWithIndex(lcdLastRightPos+FW, 0, "LUA", s_currIdx+1, 0);
SUBMENU(STR_MENUCUSTOMSCRIPTS, ICON_MODEL_LUA_SCRIPTS, 3+scriptInputsOutputs[s_currIdx].inputsCount, { 0, 0, LABEL(inputs), 0/*repeated*/ });
int8_t sub = menuVerticalPosition;
for (int k=0; k<NUM_BODY_LINES; k++) {
coord_t y = MENU_CONTENT_TOP + k*FH;
int i = k + menuVerticalOffset;
LcdFlags attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
if (i == ITEM_MODEL_CUSTOMSCRIPT_FILE) {
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SCRIPT);
if (ZEXIST(sd.file))
lcdDrawSizedText(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr);
else
lcdDrawTextAtIndex(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr);
if (attr) s_editMode = 0;
if (attr && event==EVT_KEY_FIRST(KEY_ENTER) && !READ_ONLY()) {
killEvents(KEY_ENTER);
if (sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) {
POPUP_MENU_START(onModelCustomScriptMenu);
}
else {
POPUP_WARNING(STR_NO_SCRIPTS_ON_SD);
}
}
}
else if (i == ITEM_MODEL_CUSTOMSCRIPT_NAME) {
lcdDrawText(MENUS_MARGIN_LEFT, y, TR_NAME);
editName(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.name, sizeof(sd.name), event, attr);
}
else if (i == ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL) {
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_INPUTS);
}
else if (i <= ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL+scriptInputsOutputs[s_currIdx].inputsCount) {
int inputIdx = i-ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL-1;
lcdDrawSizedText(INDENT_WIDTH, y, scriptInputsOutputs[s_currIdx].inputs[inputIdx].name, 10, 0);
if (scriptInputsOutputs[s_currIdx].inputs[inputIdx].type == INPUT_TYPE_VALUE) {
lcdDrawNumber(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx].value+ \
scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr|LEFT);
if (attr) {
CHECK_INCDEC_MODELVAR(event, g_model.scriptsData[s_currIdx].inputs[inputIdx].value, \
scriptInputsOutputs[s_currIdx].inputs[inputIdx].min-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, \
scriptInputsOutputs[s_currIdx].inputs[inputIdx].max-scriptInputsOutputs[s_currIdx].inputs[inputIdx].def);
}
}
else {
drawSource(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx].source, attr);
if (attr) {
CHECK_INCDEC_MODELSOURCE(event, g_model.scriptsData[s_currIdx].inputs[inputIdx].source, 0, MIXSRC_LAST_TELEM);
}
}
}
}
if (scriptInputsOutputs[s_currIdx].outputsCount > 0) {
lcdDrawSolidVerticalLine(SCRIPT_ONE_3RD_COLUMN_POS-4, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H+5, DEFAULT_COLOR);
// lcdDrawText(SCRIPT_ONE_3RD_COLUMN_POS, FH+1, STR_OUTPUTS);
for (int i=0; i<scriptInputsOutputs[s_currIdx].outputsCount; i++) {
drawSource(SCRIPT_ONE_3RD_COLUMN_POS+INDENT_WIDTH, MENU_CONTENT_TOP+i*FH, MIXSRC_FIRST_LUA+(s_currIdx*MAX_SCRIPT_OUTPUTS)+i, 0);
lcdDrawNumber(SCRIPT_ONE_3RD_COLUMN_POS+130, MENU_CONTENT_TOP+i*FH, calcRESXto1000(scriptInputsOutputs[s_currIdx].outputs[i].value), PREC1);
}
}
return true;
}
#define SCRIPTS_COLUMN_FILE 70
#define SCRIPTS_COLUMN_NAME 160
#define SCRIPTS_COLUMN_STATE 300
bool menuModelCustomScripts(event_t event)
{
// lcdDrawNumber(19*FW, 0, luaGetMemUsed(lsScripts), 0);
// lcdDrawText(19*FW+1, 0, STR_BYTES);
MENU(STR_MENUCUSTOMSCRIPTS, MODEL_ICONS, menuTabModel, MENU_MODEL_CUSTOM_SCRIPTS, MAX_SCRIPTS, { NAVIGATION_LINE_BY_LINE|3/*repeated*/ });
int8_t sub = menuVerticalPosition;
if (event == EVT_KEY_FIRST(KEY_ENTER) && sub >= 0) {
s_currIdx = sub;
pushMenu(menuModelCustomScriptOne);
}
for (int i=0, scriptIndex=0; i<MAX_SCRIPTS; i++) {
coord_t y = MENU_CONTENT_TOP + i*FH;
ScriptData &sd = g_model.scriptsData[i];
// LUAx header
drawStringWithIndex(MENUS_MARGIN_LEFT, y, "LUA", i+1, sub==i ? INVERS : 0);
// LUA script
if (ZEXIST(sd.file)) {
lcdDrawSizedText(SCRIPTS_COLUMN_FILE, y, sd.file, sizeof(sd.file), 0);
switch (scriptInternalData[scriptIndex].state) {
case SCRIPT_SYNTAX_ERROR:
lcdDrawText(SCRIPTS_COLUMN_STATE, y, "(error)");
break;
case SCRIPT_KILLED:
lcdDrawText(SCRIPTS_COLUMN_STATE, y, "(killed)");
break;
default:
lcdDrawNumber(SCRIPTS_COLUMN_STATE, y, luaGetCpuUsed(scriptIndex), LEFT|DEFAULT_COLOR, 0, nullptr, "%");
break;
}
scriptIndex++;
}
else {
lcdDrawTextAtIndex(SCRIPTS_COLUMN_FILE, y, STR_VCSWFUNC, 0, 0);
}
// Script name
lcdDrawSizedText(SCRIPTS_COLUMN_NAME, y, sd.name, sizeof(sd.name), ZCHAR);
}
return true;
}
-528
View File
@@ -1,528 +0,0 @@
/*
* 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 "opentx.h"
#include "modelslist.h"
#define CATEGORIES_WIDTH 120
#define MODELS_LEFT 123
#define MODELS_COLUMN_WIDTH 174
enum ModelSelectMode {
MODE_SELECT_MODEL,
MODE_RENAME_CATEGORY,
MODE_MOVE_MODEL,
};
enum ModelDeleteMode {
MODE_DELETE_MODEL,
MODE_DELETE_CATEGORY,
};
uint8_t selectMode, deleteMode;
ModelsCategory * currentCategory;
int currentCategoryIndex;
ModelCell * currentModel;
void drawCategory(coord_t y, const char * name, bool selected)
{
if (selected) {
lcdDrawSolidFilledRect(1, y-INVERT_VERT_MARGIN, CATEGORIES_WIDTH-10, INVERT_LINE_HEIGHT+2, FOCUS_BGCOLOR);
lcdDrawText(6, y, name, DEFAULT_COLOR | INVERS);
}
else {
lcdDrawText(6, y, name, DEFAULT_COLOR);
}
}
void drawModel(coord_t x, coord_t y, ModelCell * model, bool current, bool selected)
{
lcd->drawBitmap(x+1, y+1, model->getBuffer());
if (current) {
lcd->drawBitmapPattern(x+66, y+43, LBM_ACTIVE_MODEL, TITLE_BGCOLOR);
}
if (selected) {
lcdDrawSolidRect(x, y, MODELCELL_WIDTH+2, MODELCELL_HEIGHT+2, 1, TITLE_BGCOLOR);
drawShadow(x, y, MODELCELL_WIDTH+2, MODELCELL_HEIGHT+2);
if (selectMode == MODE_MOVE_MODEL && modelselModelMoveBackground) {
lcd->drawMask(x+MODELCELL_WIDTH+2-modelselModelMoveBackground->width(), y, modelselModelMoveBackground, TITLE_BGCOLOR);
lcd->drawMask(x+MODELCELL_WIDTH+2-modelselModelMoveBackground->width()+12, y+5, modelselModelMoveIcon, DEFAULT_BGCOLOR);
}
}
}
uint16_t categoriesVerticalOffset = 0;
uint16_t categoriesVerticalPosition = 0;
#define MODEL_INDEX() (menuVerticalPosition*2+menuHorizontalPosition)
void setCurrentModel(unsigned int index)
{
std::list<ModelCell *>::iterator it = currentCategory->begin();
std::advance(it, index);
currentModel = *it;
menuVerticalPosition = index / 2;
menuHorizontalPosition = index & 1;
menuVerticalOffset = limit<int>(menuVerticalPosition-2, menuVerticalOffset, min<int>(menuVerticalPosition, max<int>(0, (currentCategory->size()-7)/2)));
}
void setCurrentCategory(unsigned int index)
{
currentCategoryIndex = index;
const std::list<ModelsCategory *>& cats = modelslist.getCategories();
std::list<ModelsCategory *>::const_iterator it = cats.begin();
std::advance(it, index);
currentCategory = *it;
categoriesVerticalPosition = index;
categoriesVerticalOffset = limit<int>(categoriesVerticalPosition-4, categoriesVerticalOffset, min<int>(categoriesVerticalPosition, max<int>(0, cats.size()-5)));
if (currentCategory->size() > 0)
setCurrentModel(0);
else
currentModel = nullptr;
}
#if defined(LUA)
#define MAX_WIZARD_NAME_LEN (sizeof(WIZARD_PATH)+20)
#define WIZARD_SPACING 40
#define WIZARD_LEFT_SPACING 30
#define WIZARD_ICON_X 80
#define WIZARD_ICON_Y 110
#define WIZARD_TEXT_Y 195
uint8_t getWizardCount()
{
uint8_t wizCnt=0;
DIR dir;
static FILINFO fno;
FRESULT res = f_opendir(&dir, WIZARD_PATH);
if (res == FR_OK) {
for (;;) {
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0) {
break;
}
if (fno.fattrib & AM_DIR) {
wizCnt++;
}
}
}
f_closedir(&dir);
return wizCnt;
}
bool menuModelWizard(event_t event)
{
static uint8_t wizardSelected = 0;
static uint8_t wizardCnt = getWizardCount();
bool executeMe = false;
uint8_t first = 0;
DIR dir;
static FILINFO fno;
char wizpath[MAX_WIZARD_NAME_LEN];
if (wizardCnt == 0) {
chainMenu(menuModelSelect);
return false;
}
switch(event) {
case 0:
// no need to refresh the screen
return false;
case EVT_KEY_FIRST(KEY_EXIT):
chainMenu(menuModelSelect);
return false;
case EVT_KEY_BREAK(KEY_ENTER):
executeMe = true;
break;
case EVT_ROTARY_RIGHT:
if (wizardSelected < wizardCnt-1) {
wizardSelected++;
}
if (wizardSelected > 3) {
first = wizardSelected - 3;
}
break;
case EVT_ROTARY_LEFT:
if (wizardSelected != 0) {
wizardSelected--;
}
if(wizardSelected < first)
{
first = wizardSelected;
}
break;
}
strcpy(wizpath, WIZARD_PATH);
strcpy(&wizpath[sizeof(WIZARD_PATH)-1], "/");
lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, DEFAULT_BGCOLOR);
lcd->drawBitmap(0, 0, modelselWizardBackground);
FRESULT res = f_opendir(&dir, WIZARD_PATH);
if (res == FR_OK) {
for (uint8_t wizidx=0;;wizidx++) {
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0) {
break;
}
if (fno.fattrib & AM_DIR) {
if((wizidx >= first) && (wizidx < (first+4))) {
uint16_t x = WIZARD_LEFT_SPACING + (wizidx - first) * (WIZARD_SPACING + WIZARD_ICON_X);
strcpy(&wizpath[sizeof(WIZARD_PATH)], fno.fname);
strcpy(&wizpath[sizeof(WIZARD_PATH) + strlen(fno.fname)], "/icon.png");
BitmapBuffer * background = BitmapBuffer::load(wizpath);
lcd->drawBitmap(x, WIZARD_ICON_Y, background);
if(wizidx == wizardSelected ) {
if (wizardSelected < 5) {
lcdDrawRect(x, WIZARD_ICON_Y, 85, 130, 2, SOLID, MAINVIEW_GRAPHICS_COLOR_INDEX);
lcdDrawRect(x+5, WIZARD_TEXT_Y, 75, 4, 2, SOLID, MAINVIEW_GRAPHICS_COLOR_INDEX);
}
if (executeMe) {
strcpy(&wizpath[sizeof(WIZARD_PATH)+strlen(fno.fname)], "/wizard.lua");
if (isFileAvailable(wizpath)) {
wizpath[sizeof(WIZARD_PATH) + strlen(fno.fname)] = 0;
f_chdir(wizpath);
luaExec(WIZARD_NAME);
}
}
}
delete background;
}
}
}
f_closedir(&dir);
}
return true;
}
#endif
void onDeleteModelConfirm(const char * result)
{
if (result == STR_OK) {
if (deleteMode == MODE_DELETE_CATEGORY) {
modelslist.removeCategory(currentCategory);
modelslist.save();
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
}
else if (deleteMode == MODE_DELETE_MODEL){
int modelIndex = MODEL_INDEX();
modelslist.removeModel(currentCategory, currentModel);
s_copyMode = 0;
pushEvent(EVT_REFRESH);
if (modelIndex > 0) {
modelIndex--;
}
setCurrentModel(modelIndex);
}
}
}
void onModelSelectMenu(const char * result)
{
if (result == STR_SELECT_MODEL) {
if (!g_eeGeneral.disableRssiPoweroffAlarm) {
if (!confirmModelChange())
return;
}
// we store the latest changes if any
storageFlushCurrentModel();
storageCheck(true);
memcpy(g_eeGeneral.currModelFilename, currentModel->modelFilename, LEN_MODEL_FILENAME);
modelslist.setCurrentModel(currentModel);
modelslist.setCurrentCategory(currentCategory);
loadModel(g_eeGeneral.currModelFilename, true);
storageDirty(EE_GENERAL);
storageCheck(true);
chainMenu(menuMainView);
}
else if (result == STR_DELETE_MODEL) {
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(currentModel->modelName, LEN_MODEL_NAME, 0);
deleteMode = MODE_DELETE_MODEL;
}
else if (result == STR_CREATE_MODEL) {
if (!g_eeGeneral.disableRssiPoweroffAlarm) {
if (!confirmModelChange())
return;
}
storageCheck(true);
modelslist.addModel(currentCategory, createModel());
selectMode = MODE_SELECT_MODEL;
setCurrentModel(currentCategory->size() - 1);
modelslist.setCurrentModel(currentModel);
modelslist.setCurrentCategory(currentCategory);
modelslist.onNewModelCreated(currentModel, &g_model);
#if defined(LUA)
chainMenu(menuModelWizard);
#endif
}
else if (result == STR_DUPLICATE_MODEL) {
char duplicatedFilename[LEN_MODEL_FILENAME+1];
memcpy(duplicatedFilename, currentModel->modelFilename, sizeof(duplicatedFilename));
if (findNextFileIndex(duplicatedFilename, LEN_MODEL_FILENAME, MODELS_PATH)) {
sdCopyFile(currentModel->modelFilename, MODELS_PATH, duplicatedFilename, MODELS_PATH);
ModelCell * dup_model = modelslist.addModel(currentCategory, duplicatedFilename);
dup_model->fetchRfData();
setCurrentModel(currentCategory->size() - 1);
}
else {
POPUP_WARNING(STR_INVALID_FILE);
}
}
else if (result == STR_MOVE_MODEL) {
selectMode = MODE_MOVE_MODEL;
}
else if (result == STR_CREATE_CATEGORY) {
currentCategory = modelslist.createCategory();
setCurrentCategory(modelslist.getCategories().size() - 1);
}
else if (result == STR_RENAME_CATEGORY) {
selectMode = MODE_RENAME_CATEGORY;
s_editMode = EDIT_MODIFY_STRING;
editNameCursorPos = 0;
}
else if (result == STR_DELETE_CATEGORY) {
if (currentCategory->size() > 0){
POPUP_WARNING(STR_DELETE_ERROR);
SET_WARNING_INFO(STR_CAT_NOT_EMPTY, sizeof(TR_CAT_NOT_EMPTY), 0);
}
else {
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(currentCategory->name, LEN_MODEL_FILENAME, 0);
deleteMode = MODE_DELETE_CATEGORY;
}
}
}
void initModelsList()
{
modelslist.load();
categoriesVerticalOffset = 0;
bool found = false;
int index = 0;
const std::list<ModelsCategory *>& cats = modelslist.getCategories();
for (std::list<ModelsCategory *>::const_iterator it = cats.begin(); it != cats.end(); ++it, ++index) {
if (*it == modelslist.getCurrentCategory()) {
setCurrentCategory(index);
found = true;
break;
}
}
if (!found) {
setCurrentCategory(0);
}
menuVerticalOffset = 0;
found = false;
index = 0;
for (ModelsCategory::iterator it = currentCategory->begin(); it != currentCategory->end(); ++it, ++index) {
if (*it == modelslist.getCurrentModel()) {
setCurrentModel(index);
found = true;
break;
}
}
if (!found) {
setCurrentModel(0);
}
}
bool menuModelSelect(event_t event)
{
const std::list<ModelsCategory*>& cats = modelslist.getCategories();
switch (event) {
case 0:
// no need to refresh the screen
return false;
case EVT_ENTRY:
selectMode = MODE_SELECT_MODEL;
initModelsList();
break;
case EVT_KEY_BREAK(KEY_ENTER):
if (selectMode == MODE_MOVE_MODEL)
selectMode = MODE_SELECT_MODEL;
break;
case EVT_KEY_FIRST(KEY_EXIT):
switch (selectMode) {
case MODE_MOVE_MODEL:
selectMode = MODE_SELECT_MODEL;
break;
case MODE_SELECT_MODEL:
chainMenu(menuMainView);
return false;
}
break;
case EVT_KEY_FIRST(KEY_PGUP):
#if defined(PCBX10)
case EVT_KEY_LONG(KEY_PGDN):
#endif
if (selectMode == MODE_SELECT_MODEL) {
if (categoriesVerticalPosition == 0)
categoriesVerticalPosition = cats.size() - 1;
else
categoriesVerticalPosition -= 1;
setCurrentCategory(categoriesVerticalPosition);
}
else if (selectMode == MODE_MOVE_MODEL && categoriesVerticalPosition > 0) {
ModelsCategory * previous_category = currentCategory;
ModelCell * model = currentModel;
categoriesVerticalPosition -= 1;
setCurrentCategory(categoriesVerticalPosition);
modelslist.moveModel(model, previous_category, currentCategory);
setCurrentModel(currentCategory->size() - 1);
}
killEvents(event);
break;
#if defined(PCBX12S)
case EVT_KEY_FIRST(KEY_PGDN):
#elif defined(PCBX10)
case EVT_KEY_BREAK(KEY_PGDN):
#endif
if (selectMode == MODE_SELECT_MODEL) {
categoriesVerticalPosition += 1;
if (categoriesVerticalPosition >= cats.size())
categoriesVerticalPosition = 0;
setCurrentCategory(categoriesVerticalPosition);
}
else if (selectMode == MODE_MOVE_MODEL && categoriesVerticalPosition < cats.size()-1) {
ModelsCategory * previous_category = currentCategory;
ModelCell * model = currentModel;
categoriesVerticalPosition += 1;
setCurrentCategory(categoriesVerticalPosition);
modelslist.moveModel(model, previous_category, currentCategory);
setCurrentModel(currentCategory->size()-1);
}
break;
case EVT_KEY_LONG(KEY_ENTER):
if (selectMode == MODE_SELECT_MODEL) {
killEvents(event);
if (currentModel && currentModel != modelslist.getCurrentModel()) {
POPUP_MENU_ADD_ITEM(STR_SELECT_MODEL);
}
POPUP_MENU_ADD_ITEM(STR_CREATE_MODEL);
if (currentModel) {
POPUP_MENU_ADD_ITEM(STR_DUPLICATE_MODEL);
POPUP_MENU_ADD_ITEM(STR_MOVE_MODEL);
}
// POPUP_MENU_ADD_SD_ITEM(STR_BACKUP_MODEL);
if (currentModel && currentModel != modelslist.getCurrentModel()) {
POPUP_MENU_ADD_ITEM(STR_DELETE_MODEL);
}
// POPUP_MENU_ADD_ITEM(STR_RESTORE_MODEL);
POPUP_MENU_ADD_ITEM(STR_CREATE_CATEGORY);
POPUP_MENU_ADD_ITEM(STR_RENAME_CATEGORY);
if (cats.size() > 1) {
POPUP_MENU_ADD_ITEM(STR_DELETE_CATEGORY);
}
POPUP_MENU_START(onModelSelectMenu);
}
break;
}
lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, DEFAULT_BGCOLOR);
lcd->drawBitmap(0, 0, modelselIconBitmap);
// Categories
int index = 0;
coord_t y = 97;
drawVerticalScrollbar(CATEGORIES_WIDTH-1, y-1, 5*(FH+7)-5, categoriesVerticalOffset, cats.size(), 5);
for (std::list<ModelsCategory *>::const_iterator it = cats.begin(); it != cats.end(); ++it, ++index) {
if (index >= categoriesVerticalOffset && index < categoriesVerticalOffset+5) {
if (index != categoriesVerticalOffset) {
lcdDrawSolidHorizontalLine(1, y-4, CATEGORIES_WIDTH-10, LINE_COLOR);
}
if (selectMode == MODE_RENAME_CATEGORY && currentCategory == *it) {
lcdDrawSolidFilledRect(0, y-INVERT_VERT_MARGIN+1, CATEGORIES_WIDTH-2, INVERT_LINE_HEIGHT, DEFAULT_BGCOLOR);
editName(MENUS_MARGIN_LEFT, y, currentCategory->name, LEN_MODEL_FILENAME, event, 1, 0);
if (s_editMode == 0 || event == EVT_KEY_BREAK(KEY_EXIT)) {
modelslist.save();
selectMode = MODE_SELECT_MODEL;
pushEvent(EVT_REFRESH);
}
}
else {
drawCategory(y, (*it)->name, currentCategory==*it);
}
y += FH+7;
}
}
// Models
index = 0;
y = 5;
for (ModelsCategory::iterator it = currentCategory->begin(); it != currentCategory->end(); ++it, ++index) {
if (index >= menuVerticalOffset*2 && index < (menuVerticalOffset+4)*2) {
bool selected = ((selectMode==MODE_SELECT_MODEL || selectMode==MODE_MOVE_MODEL) && index==menuVerticalPosition*2+menuHorizontalPosition);
bool current = !strncmp((*it)->modelFilename, g_eeGeneral.currModelFilename, LEN_MODEL_FILENAME);
if (index & 1) {
drawModel(MODELS_LEFT + MODELS_COLUMN_WIDTH, y, *it, current, selected);
y += 66;
}
else {
drawModel(MODELS_LEFT, y, *it, current, selected);
}
if (selected) {
lcd->drawBitmap(5, LCD_H-FH, modelselModelNameBitmap);
lcdDrawText(22, LCD_H-FH-1, (*it)->modelFilename, FONT(XS)|DEFAULT_COLOR);
}
}
}
// Navigation
if (currentModel) {
if (selectMode == MODE_SELECT_MODEL) {
if (navigate(event, index, 4, 2) != 0) {
setCurrentModel(MODEL_INDEX());
pushEvent(EVT_REFRESH);
}
}
else if (selectMode == MODE_MOVE_MODEL) {
int8_t direction = navigate(event, index, 4, 2, false);
if (direction) {
modelslist.moveModel(currentCategory, currentModel, direction);
setCurrentModel(MODEL_INDEX());
pushEvent(EVT_REFRESH);
}
}
}
drawVerticalScrollbar(DEFAULT_SCROLLBAR_X + 4, 7, LCD_H - 15, menuVerticalOffset, (index + 1) / 2, 4);
// Footer
lcd->drawBitmap(5, LCD_H-FH-20, modelselSdFreeBitmap);
uint32_t size = sdGetSize() / 100;
lcdDrawNumber(22, LCD_H-FH-21, size, PREC1|FONT(XS), 0, nullptr, "GB");
lcd->drawBitmap(70, LCD_H-FH-20, modelselModelQtyBitmap);
lcdDrawNumber(92, LCD_H-FH-21, modelslist.getModelsCount(),FONT(XS));
return true;
}
@@ -128,7 +128,6 @@ void RadioGhostModuleConfig::onEvent(event_t event)
break;
case EVT_KEY_LONG(KEY_EXIT):
menuVerticalOffset = 0;
memclear(&reusableBuffer.ghostMenu, sizeof(reusableBuffer.ghostMenu));
reusableBuffer.ghostMenu.buttonAction = GHST_BTN_NONE;
reusableBuffer.ghostMenu.menuAction = GHST_MENU_CTRL_CLOSE;
-73
View File
@@ -1,73 +0,0 @@
/*
* 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 "opentx.h"
bool menuTextView(event_t event)
{
static int lines_count;
drawMenuTemplate(STR_TEXT_VIEWER, ICON_OPENTX, nullptr, OPTION_MENU_NO_SCROLLBAR);
switch (event) {
case EVT_ENTRY:
menuVerticalOffset = 0;
lines_count = 0;
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_ROTARY_LEFT:
if (menuVerticalOffset == 0)
break;
else
menuVerticalOffset--;
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_ROTARY_RIGHT:
if (menuVerticalOffset + TEXT_VIEWER_LINES >= lines_count)
break;
else
++menuVerticalOffset;
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_KEY_FIRST(KEY_EXIT):
menuVerticalOffset = 0;
popMenu();
break;
}
for (int i = 0; i < TEXT_VIEWER_LINES; i++) {
lcd->drawTextMaxWidth(MENUS_MARGIN_LEFT, MENU_HEADER_HEIGHT + i * FH, reusableBuffer.viewText.lines[i], 0, LCD_W - 2 * MENUS_MARGIN_LEFT);
}
drawVerticalScrollbar(LCD_W-5, 50, 195, menuVerticalOffset, lines_count, TEXT_VIEWER_LINES);
return true;
}
void pushMenuTextView(const char *filename)
{
if (strlen(filename) < TEXT_FILENAME_MAXLEN) {
strcpy(reusableBuffer.viewText.filename, filename);
pushMenu(menuTextView);
}
}
+6 -2
View File
@@ -1227,6 +1227,7 @@ Run function (key pressed)
@status current Introduced in 2.2.0
*/
#if 0
static int luaPopupWarning(lua_State * L)
{
event_t event = luaL_checkinteger(L, 2);
@@ -1242,6 +1243,7 @@ static int luaPopupWarning(lua_State * L)
}
return 1;
}
#endif
/*luadoc
@function popupConfirmation(title, event) deprecated, please replace by
@@ -1262,6 +1264,7 @@ Run function (key pressed)
@status current Introduced in 2.2.0, changed to (title, message, event) in 2.3.8
*/
#if 0
static int luaPopupConfirmation(lua_State * L)
{
warningType = WARNING_TYPE_CONFIRM;
@@ -1288,6 +1291,7 @@ static int luaPopupConfirmation(lua_State * L)
}
return 1;
}
#endif
/*luadoc
@function defaultStick(channel)
@@ -1768,8 +1772,8 @@ const luaL_Reg opentxLib[] = {
{ "playTone", luaPlayTone },
{ "playHaptic", luaPlayHaptic },
// { "popupInput", luaPopupInput },
{ "popupWarning", luaPopupWarning },
{ "popupConfirmation", luaPopupConfirmation },
// { "popupWarning", luaPopupWarning },
// { "popupConfirmation", luaPopupConfirmation },
{ "defaultStick", luaDefaultStick },
{ "defaultChannel", luaDefaultChannel },
{ "getRSSI", luaGetRSSI },
+4
View File
@@ -773,6 +773,7 @@ void displayLuaError(const char * title)
}
}
#if !defined(COLORLCD)
void displayAcknowledgeLuaError(event_t event)
{
warningResult = false;
@@ -781,6 +782,7 @@ void displayAcknowledgeLuaError(event_t event)
warningText = nullptr;
}
}
#endif
void luaError(lua_State * L, uint8_t error, bool acknowledge)
{
@@ -819,9 +821,11 @@ void luaError(lua_State * L, uint8_t error, bool acknowledge)
}
if (acknowledge) {
#if !defined(COLORLCD)
warningText = errorTitle;
warningType = WARNING_TYPE_INFO;
popupFunc = displayAcknowledgeLuaError;
#endif
}
else {
displayLuaError(errorTitle);
+1 -1
View File
@@ -84,7 +84,7 @@ void handleUsbConnection()
#if defined(STM32) && !defined(SIMU)
if (!usbStarted() && usbPlugged()) {
if (getSelectedUsbMode() == USB_UNSELECTED_MODE) {
if (g_eeGeneral.USBMode == USB_UNSELECTED_MODE && popupMenuItemsCount == 0) {
if (g_eeGeneral.USBMode == USB_UNSELECTED_MODE) {
openUsbMenu();
}
else {
+6
View File
@@ -780,6 +780,9 @@ void checkAll()
checkMultiLowPower();
#endif
#if defined(COLORLCD)
#warning "KEYSTUCK Message Not Yet Implemented"
#else
if (!waitKeysReleased()) {
showMessageBox(STR_KEYSTUCK);
tmr10ms_t tgtime = get_tmr10ms() + 500;
@@ -788,6 +791,7 @@ void checkAll()
WDG_RESET();
}
}
#endif
#if defined(EXTERNAL_ANTENNA) && defined(INTERNAL_MODULE_PXX1)
checkExternalAntenna();
@@ -2067,6 +2071,8 @@ uint32_t pwrCheck()
event_t evt = getEvent(false);
DISPLAY_WARNING(evt);
LED_ERROR_BEGIN();
WDG_RESET();
lcdRefresh();
if (warningResult) {
+1 -4
View File
@@ -1008,10 +1008,7 @@ union ReusableBuffer
#if defined(EEPROM_RLC) && LCD_W < 212
uint16_t eepromfree;
#endif
#if defined(SDCARD)
char menu_bss[POPUP_MENU_MAX_LINES][MENU_LINE_LENGTH];
char mainname[45]; // because reused for SD backup / restore, max backup filename 44 chars: "/MODELS/MODEL0134353-2014-06-19-04-51-27.bin"
#else
#if !defined(SDCARD)
char mainname[LEN_MODEL_NAME];
#endif
} modelsel;
+2
View File
@@ -210,6 +210,7 @@ const char * getBasename(const char * path)
return path;
}
#if !defined(LIBOPENUI)
bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen, const char * selection, uint8_t flags)
{
static uint16_t lastpopupMenuOffset = 0;
@@ -427,6 +428,7 @@ void sdReadTextFile(const char * filename, char lines[TEXT_VIEWER_LINES][LCD_COL
lines_count = current_line;
}
}
#endif // !LIBOPENUI
#if defined(SDCARD)
const char * sdCopyFile(const char * srcPath, const char * destPath)
-46
View File
@@ -1,46 +0,0 @@
#include "opentx.h"
const char *warningText = NULL;
const char *warningInfoText;
uint8_t warningInfoLength;
uint8_t warningType;
uint8_t warningResult = 0;
uint8_t warningInfoFlags;
void (*popupFunc)(uint16_t event) = NULL;
const char *popupMenuItems[POPUP_MENU_MAX_LINES];
uint16_t popupMenuItemsCount = 0;
uint16_t popupMenuOffset = 0;
uint8_t popupMenuOffsetType = 0;
void (*popupMenuHandler)(const char * result);
uint8_t noHighlightCounter;
void runPopupWarning(uint16_t event)
{
}
void drawFatalErrorScreen(const char * message)
{
}
void showMessageBox(const char * title)
{
}
bool menuFirstCalib(event_t event)
{
return false;
}
void drawAlertBox(const char * title, const char * text, const char * action)
{
}
uint8_t menuLevel;
int menuVerticalOffset;
void runFatalErrorScreen(char const*)
{
}