@@ -631,12 +631,13 @@ void menuModelSetup(event_t event)
|
||||
case ITEM_MODEL_SETUP_THROTTLE_TRACE:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_TTRACE);
|
||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.thrTraceSrc, NUM_POTS+NUM_SLIDERS+MAX_OUTPUT_CHANNELS);
|
||||
uint8_t idx = g_model.thrTraceSrc + MIXSRC_Thr;
|
||||
if (idx > MIXSRC_Thr)
|
||||
idx += 1;
|
||||
if (idx >= MIXSRC_FIRST_POT+NUM_POTS+NUM_SLIDERS)
|
||||
idx += MIXSRC_CH1 - MIXSRC_FIRST_POT - NUM_POTS - NUM_SLIDERS;
|
||||
if (attr)
|
||||
CHECK_INCDEC_MODELVAR_ZERO_CHECK(
|
||||
event, g_model.thrTraceSrc,
|
||||
NUM_POTS + NUM_SLIDERS + MAX_OUTPUT_CHANNELS,
|
||||
isThrottleSourceAvailable);
|
||||
|
||||
uint8_t idx = throttleSource2Source(g_model.thrTraceSrc);
|
||||
drawSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -606,12 +606,13 @@ void menuModelSetup(event_t event)
|
||||
case ITEM_MODEL_SETUP_THROTTLE_TRACE:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_TTRACE);
|
||||
if (attr) CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, g_model.thrTraceSrc, NUM_POTS+NUM_SLIDERS+MAX_OUTPUT_CHANNELS, isThrottleSourceAvailable);
|
||||
uint8_t idx = g_model.thrTraceSrc + MIXSRC_Thr;
|
||||
if (idx > MIXSRC_Thr)
|
||||
idx += 1;
|
||||
if (idx >= MIXSRC_FIRST_POT+NUM_POTS+NUM_SLIDERS)
|
||||
idx += MIXSRC_CH1 - MIXSRC_FIRST_POT - NUM_POTS - NUM_SLIDERS;
|
||||
if (attr)
|
||||
CHECK_INCDEC_MODELVAR_ZERO_CHECK(
|
||||
event, g_model.thrTraceSrc,
|
||||
NUM_POTS + NUM_SLIDERS + MAX_OUTPUT_CHANNELS,
|
||||
isThrottleSourceAvailable);
|
||||
|
||||
uint8_t idx = throttleSource2Source(g_model.thrTraceSrc);
|
||||
drawSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ endmacro(add_gui_src)
|
||||
|
||||
if(LUA)
|
||||
add_gui_src(standalone_lua.cpp)
|
||||
add_gui_src(model_mixer_scripts.cpp)
|
||||
endif()
|
||||
|
||||
if(HELI)
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
// TODO common code, not in target
|
||||
enum LcdColorIndex
|
||||
{
|
||||
// this one first for when colour is not set
|
||||
DEFAULT_COLOR_INDEX,
|
||||
|
||||
ALARM_COLOR_INDEX,
|
||||
BARGRAPH1_COLOR_INDEX,
|
||||
BARGRAPH2_COLOR_INDEX,
|
||||
@@ -38,7 +41,6 @@ enum LcdColorIndex
|
||||
CURVE_CURSOR_COLOR_INDEX,
|
||||
CUSTOM_COLOR_INDEX,
|
||||
DEFAULT_BGCOLOR_INDEX,
|
||||
DEFAULT_COLOR_INDEX,
|
||||
DISABLE_COLOR_INDEX,
|
||||
EDIT_MARKER_COLOR_INDEX,
|
||||
FIELD_BGCOLOR_INDEX,
|
||||
|
||||
@@ -416,6 +416,12 @@ void drawSensorCustomValue(BitmapBuffer * dc, coord_t x, coord_t y, uint8_t sens
|
||||
}
|
||||
}
|
||||
|
||||
// libopemui defines TIMOUR as zero
|
||||
#if !TIMHOUR
|
||||
#undef TIMEHOUR
|
||||
#define TIMEHOUR 0x2000
|
||||
#endif
|
||||
|
||||
void drawTimer(BitmapBuffer * dc, coord_t x, coord_t y, int32_t tme, LcdFlags flags)
|
||||
{
|
||||
char str[LEN_TIMER_STRING];
|
||||
@@ -437,7 +443,8 @@ void drawSourceCustomValue(BitmapBuffer * dc, coord_t x, coord_t y, source_t sou
|
||||
}
|
||||
else if (source >= MIXSRC_FIRST_TIMER || source == MIXSRC_TX_TIME) {
|
||||
// TODO if (value < 0) flags |= BLINK|INVERS;
|
||||
// TODO drawTimer(dc, x, y, value, flags);
|
||||
if (source == MIXSRC_TX_TIME) flags |= TIMEHOUR;
|
||||
drawTimer(dc, x, y, value, flags);
|
||||
}
|
||||
else if (source == MIXSRC_TX_VOLTAGE) {
|
||||
dc->drawNumber(x, y, value, flags|PREC1);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#define GET_SET_DEFAULT(value) GET_DEFAULT(value), SET_DEFAULT(value)
|
||||
#define GET_SET_INVERTED(value) GET_INVERTED(value), SET_INVERTED(value)
|
||||
#define GET_SET_VALUE_WITH_OFFSET(value, offset) GET_VALUE_WITH_OFFSET(value, offset), SET_VALUE_WITH_OFFSET(value, offset)
|
||||
#define GET_SET_WITH_OFFSET(value, offset) GET_VALUE_WITH_OFFSET(value, offset), SET_VALUE_WITH_OFFSET(value, offset)
|
||||
#define GET_SET_WITH_OFFSET(value, offset) GET_VALUE_WITH_OFFSET(value, offset), SET_VALUE_WITH_OFFSET(value, offset)
|
||||
#define GET_SET_BF(value, offset, bits) GET_VALUE_WITH_BF(value, offset, bits), SET_VALUE_WITH_BF(value, offset, bits)
|
||||
|
||||
#endif // _GETSET_HELPERS_H_
|
||||
|
||||
@@ -25,7 +25,7 @@ void MainViewTrim::checkEvents()
|
||||
{
|
||||
Window::checkEvents();
|
||||
int8_t stickIndex = CONVERT_MODE(idx);
|
||||
int8_t newValue = getTrimValue(mixerCurrentFlightMode, stickIndex);
|
||||
int newValue = getTrimValue(mixerCurrentFlightMode, stickIndex);
|
||||
if (value != newValue) {
|
||||
value = newValue;
|
||||
invalidate();
|
||||
@@ -43,6 +43,10 @@ void MainViewHorizontalTrim::paint(BitmapBuffer * dc)
|
||||
trimMin = TRIM_MIN;
|
||||
trimMax = TRIM_MAX;
|
||||
}
|
||||
|
||||
int16_t dispVal = value;
|
||||
if (dispVal < trimMin) dispVal = trimMin;
|
||||
if (dispVal > trimMax) dispVal = trimMax;
|
||||
|
||||
// Trim line
|
||||
dc->drawSolidFilledRect(
|
||||
@@ -50,7 +54,7 @@ void MainViewHorizontalTrim::paint(BitmapBuffer * dc)
|
||||
width() - TRIM_SQUARE_SIZE + 1, TRIM_LINE_WIDTH, DEFAULT_COLOR);
|
||||
|
||||
// Trim square
|
||||
coord_t x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (value - trimMin),
|
||||
coord_t x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (dispVal - trimMin),
|
||||
trimMax - trimMin);
|
||||
drawTrimSquare(dc, x, 0,
|
||||
(value < TRIM_MIN || value > TRIM_MAX)
|
||||
@@ -85,15 +89,20 @@ void MainViewVerticalTrim::paint(BitmapBuffer * dc)
|
||||
trimMax = TRIM_MAX;
|
||||
}
|
||||
|
||||
int16_t dispVal = value;
|
||||
if (dispVal < trimMin) dispVal = trimMin;
|
||||
if (dispVal > trimMax) dispVal = trimMax;
|
||||
|
||||
// Trim line
|
||||
dc->drawSolidFilledRect((width() - TRIM_LINE_WIDTH) / 2, TRIM_SQUARE_SIZE / 2,
|
||||
TRIM_LINE_WIDTH, height() - TRIM_SQUARE_SIZE + 1,
|
||||
DEFAULT_COLOR);
|
||||
|
||||
// Trim square
|
||||
coord_t y = height() - TRIM_SQUARE_SIZE -
|
||||
divRoundClosest((height() - TRIM_SQUARE_SIZE) * (value - trimMin),
|
||||
trimMax - trimMin);
|
||||
coord_t y =
|
||||
height() - TRIM_SQUARE_SIZE -
|
||||
divRoundClosest((height() - TRIM_SQUARE_SIZE) * (dispVal - trimMin),
|
||||
trimMax - trimMin);
|
||||
drawTrimSquare(dc, 0, y,
|
||||
(value < TRIM_MIN || value > TRIM_MAX)
|
||||
? HIGHLIGHT_COLOR /* TODO add a color */
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "model_gvars.h"
|
||||
#include "model_curves.h"
|
||||
#include "model_logical_switches.h"
|
||||
#include "model_mixer_scripts.h"
|
||||
#include "special_functions.h"
|
||||
#include "model_telemetry.h"
|
||||
|
||||
@@ -47,5 +48,8 @@ ModelMenu::ModelMenu():
|
||||
addTab(new ModelGVarsPage());
|
||||
addTab(new ModelLogicalSwitchesPage());
|
||||
addTab(new SpecialFunctionsPage(g_model.customFn));
|
||||
#if defined(LUA)
|
||||
addTab(new ModelMixerScriptsPage());
|
||||
#endif
|
||||
addTab(new ModelTelemetryPage());
|
||||
}
|
||||
|
||||
@@ -56,20 +56,19 @@ void copyExpo(uint8_t source, uint8_t dest, int8_t input)
|
||||
pauseMixerCalculations();
|
||||
ExpoData sourceExpo;
|
||||
memcpy(&sourceExpo, expoAddress(source), sizeof(ExpoData));
|
||||
ExpoData * expo = expoAddress(dest);
|
||||
|
||||
if(input == PASTE_AFTER) {
|
||||
memmove(expo+2, expo+1, (MAX_EXPOS-(source+1))*sizeof(ExpoData));
|
||||
memcpy(expo+1, &sourceExpo, sizeof(ExpoData));
|
||||
(expo+1)->chn = (expo)->chn;
|
||||
}
|
||||
else if(input == PASTE_BEFORE) {
|
||||
memmove(expo+1, expo, (MAX_EXPOS-(source+1))*sizeof(ExpoData));
|
||||
ExpoData *expo = expoAddress(dest);
|
||||
size_t trailingExpos = MAX_EXPOS - (dest + 1);
|
||||
if (input == PASTE_AFTER) {
|
||||
trailingExpos--;
|
||||
memmove(expo + 2, expo + 1, trailingExpos * sizeof(ExpoData));
|
||||
memcpy(expo + 1, &sourceExpo, sizeof(ExpoData));
|
||||
(expo + 1)->chn = (expo)->chn;
|
||||
} else if (input == PASTE_BEFORE) {
|
||||
memmove(expo + 1, expo, trailingExpos * sizeof(ExpoData));
|
||||
memcpy(expo, &sourceExpo, sizeof(ExpoData));
|
||||
expo->chn = (expo+1)->chn;
|
||||
}
|
||||
else {
|
||||
memmove(expo+1, expo, (MAX_EXPOS-(source+1))*sizeof(ExpoData));
|
||||
expo->chn = (expo + 1)->chn;
|
||||
} else {
|
||||
memmove(expo + 1, expo, trailingExpos * sizeof(ExpoData));
|
||||
memcpy(expo, &sourceExpo, sizeof(ExpoData));
|
||||
expo->chn = input;
|
||||
}
|
||||
|
||||
@@ -144,14 +144,14 @@ class LogicalSwitchEditPage: public Page
|
||||
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V1);
|
||||
auto timer = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), -128, 122, GET_SET_DEFAULT(cs->v1));
|
||||
timer->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, lswTimerValue(value), flags | PREC1);
|
||||
drawTimer(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, flags);
|
||||
});
|
||||
grid.nextLine();
|
||||
|
||||
new StaticText(logicalSwitchOneWindow, grid.getLabelSlot(), STR_V2);
|
||||
timer = new NumberEdit(logicalSwitchOneWindow, grid.getFieldSlot(), -128, 122, GET_SET_DEFAULT(cs->v2));
|
||||
timer->setDisplayHandler([](BitmapBuffer * dc, LcdFlags flags, int32_t value) {
|
||||
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, lswTimerValue(value), flags | PREC1);
|
||||
drawTimer(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, flags);
|
||||
});
|
||||
grid.nextLine();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* 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 "opentx.h"
|
||||
|
||||
#include "model_mixer_scripts.h"
|
||||
#include "dataconstants.h"
|
||||
#include "lua/lua_api.h"
|
||||
|
||||
#include "translations.h"
|
||||
#include "menus.h"
|
||||
#include "libopenui.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||
|
||||
class ScriptEditWindow : public Page {
|
||||
public:
|
||||
explicit ScriptEditWindow(uint8_t idx) :
|
||||
Page(ICON_MODEL_LUA_SCRIPTS),
|
||||
idx(idx)
|
||||
{
|
||||
buildBody(&body);
|
||||
buildHeader(&header);
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t idx;
|
||||
bool update = false;
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
if (update) {
|
||||
TRACE("rebuilding ScriptEditWindow...");
|
||||
rebuildBody(&body);
|
||||
update = false;
|
||||
}
|
||||
// note: 'update' is set from Page::checkEvents()
|
||||
Page::checkEvents();
|
||||
}
|
||||
|
||||
void buildHeader(Window * window)
|
||||
{
|
||||
new StaticText(window,
|
||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
|
||||
PAGE_LINE_HEIGHT},
|
||||
STR_MENUCUSTOMSCRIPTS, 0, FOCUS_COLOR);
|
||||
new StaticText(window,
|
||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
|
||||
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
|
||||
std::string("LUA") + std::to_string(idx + 1), 0, FOCUS_COLOR);
|
||||
}
|
||||
|
||||
void buildBody(FormWindow * window, bool focusScript = false)
|
||||
{
|
||||
FormGridLayout grid;
|
||||
grid.spacer(PAGE_PADDING);
|
||||
|
||||
ScriptData* sd = &(g_model.scriptsData[idx]);
|
||||
|
||||
// Filename
|
||||
new StaticText(window, grid.getLabelSlot(), STR_SCRIPT);
|
||||
auto fc = new FileChoice(
|
||||
window, grid.getFieldSlot(), SCRIPTS_MIXES_PATH, SCRIPTS_EXT,
|
||||
LEN_SCRIPT_FILENAME,
|
||||
[=]() { return std::string(sd->file, LEN_SCRIPT_FILENAME); },
|
||||
[=](std::string newValue) {
|
||||
strncpy(sd->file, newValue.c_str(), LEN_SCRIPT_FILENAME);
|
||||
if (newValue.empty()) { memset((void*)sd, 0, sizeof(ScriptData)); }
|
||||
storageDirty(EE_MODEL);
|
||||
LUA_LOAD_MODEL_SCRIPT(idx); // async reload...
|
||||
update = true;
|
||||
}, true);
|
||||
grid.nextLine();
|
||||
|
||||
// Custom name
|
||||
new StaticText(window, grid.getLabelSlot(), STR_NAME);
|
||||
new ModelTextEdit(window, grid.getFieldSlot(), sd->name, sizeof(sd->name));
|
||||
grid.nextLine();
|
||||
|
||||
// scriptInputsOutputs
|
||||
ScriptInputsOutputs& sio = scriptInputsOutputs[idx];
|
||||
|
||||
if (sio.inputsCount > 0) {
|
||||
new Subtitle(window, grid.getLineSlot(), STR_INPUTS);
|
||||
grid.nextLine();
|
||||
|
||||
auto gInputs =
|
||||
new FormGroup(window, grid.getFieldSlot(),
|
||||
FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST);
|
||||
GridLayout inputsGrid(gInputs);
|
||||
|
||||
for (int i = 0; i < sio.inputsCount; i++) {
|
||||
ScriptInput& si = sio.inputs[i];
|
||||
new StaticText(window, grid.getLabelSlot(true), si.name);
|
||||
grid.nextLine();
|
||||
if (si.type == INPUT_TYPE_VALUE) {
|
||||
new NumberEdit(gInputs, inputsGrid.getSlot(), si.min - si.def,
|
||||
si.max - si.def,
|
||||
GET_SET_WITH_OFFSET(sd->inputs[i].value, si.def));
|
||||
} else {
|
||||
new SourceChoice(gInputs, inputsGrid.getSlot(), 0,
|
||||
MIXSRC_LAST_TELEM,
|
||||
GET_SET_DEFAULT(sd->inputs[i].source));
|
||||
}
|
||||
inputsGrid.nextLine();
|
||||
}
|
||||
gInputs->setHeight(inputsGrid.getWindowHeight());
|
||||
}
|
||||
|
||||
if (sio.outputsCount > 0) {
|
||||
new Subtitle(window, grid.getLabelSlot(), STR_OUTPUTS);
|
||||
grid.nextLine();
|
||||
|
||||
auto gOutputs =
|
||||
new FormGroup(window, grid.getLineSlot(),
|
||||
FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST);
|
||||
FormGridLayout outputsGrid(gOutputs->width());
|
||||
|
||||
for (int i = 0; i < sio.outputsCount; i++) {
|
||||
ScriptOutput* so = &(sio.outputs[i]);
|
||||
new DynamicText(gOutputs, outputsGrid.getLabelSlot(), [=]() {
|
||||
char s[16];
|
||||
getSourceString(s,
|
||||
MIXSRC_FIRST_LUA + (idx * MAX_SCRIPT_OUTPUTS) + i);
|
||||
return std::string(s, sizeof(s) - 1);
|
||||
});
|
||||
new DynamicNumber<int>(gOutputs, outputsGrid.getFieldSlot(),
|
||||
[=]() { return calcRESXto1000(so->value); });
|
||||
|
||||
outputsGrid.nextLine();
|
||||
}
|
||||
gOutputs->setHeight(outputsGrid.getWindowHeight());
|
||||
grid.addWindow(gOutputs);
|
||||
}
|
||||
|
||||
window->setInnerHeight(grid.getWindowHeight());
|
||||
if (focusScript) { fc->setFocus(); }
|
||||
}
|
||||
|
||||
void rebuildBody(FormWindow * window)
|
||||
{
|
||||
coord_t scrollPosition = window->getScrollPositionY();
|
||||
window->clear();
|
||||
buildBody(window);
|
||||
window->setScrollPositionY(scrollPosition);
|
||||
}
|
||||
};
|
||||
|
||||
constexpr char SCRIPT_STATUS_ERROR[] = "(error)";
|
||||
constexpr char SCRIPT_STATUS_KILLED[] = "(killed)";
|
||||
|
||||
class ScriptLineButton : public Button
|
||||
{
|
||||
public:
|
||||
ScriptLineButton(FormGroup* parent, const rect_t& rect,
|
||||
const ScriptData& scriptData,
|
||||
const ScriptInternalData* runtimeData) :
|
||||
Button(parent, rect), scriptData(scriptData), runtimeData(runtimeData)
|
||||
{
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer* dc) override
|
||||
{
|
||||
LcdFlags textColor = DEFAULT_COLOR;
|
||||
LcdFlags bgColor = FIELD_BGCOLOR;
|
||||
|
||||
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
|
||||
|
||||
if (runtimeData) {
|
||||
coord_t x = 2*FIELD_PADDING_LEFT;
|
||||
coord_t y = FIELD_PADDING_TOP;
|
||||
|
||||
x = dc->drawSizedText(x, y, scriptData.name, sizeof(scriptData.name), textColor);
|
||||
x += 4*FIELD_PADDING_LEFT;
|
||||
|
||||
dc->drawSizedText(x, y, scriptData.file, sizeof(scriptData.file), textColor);
|
||||
|
||||
x = width() - 2*FIELD_PADDING_LEFT;
|
||||
y = FIELD_PADDING_TOP;
|
||||
textColor |= RIGHT;
|
||||
|
||||
switch (runtimeData->state) {
|
||||
case SCRIPT_SYNTAX_ERROR:
|
||||
dc->drawSizedText(x, y, SCRIPT_STATUS_ERROR,
|
||||
sizeof(SCRIPT_STATUS_ERROR), textColor);
|
||||
break;
|
||||
case SCRIPT_KILLED:
|
||||
dc->drawSizedText(x, y, SCRIPT_STATUS_KILLED,
|
||||
sizeof(SCRIPT_STATUS_KILLED), textColor);
|
||||
break;
|
||||
default:
|
||||
dc->drawNumber(x, y, runtimeData->instructions, textColor, 0, nullptr, "%");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// bounding rect
|
||||
if (hasFocus())
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||
else
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, FIELD_FRAME_COLOR);
|
||||
}
|
||||
|
||||
protected:
|
||||
const ScriptData& scriptData;
|
||||
const ScriptInternalData* runtimeData;
|
||||
};
|
||||
|
||||
ModelMixerScriptsPage::ModelMixerScriptsPage() :
|
||||
PageTab(STR_MENUCUSTOMSCRIPTS, ICON_MODEL_LUA_SCRIPTS)
|
||||
{
|
||||
}
|
||||
|
||||
void ModelMixerScriptsPage::rebuild(FormWindow * window, int8_t focusIdx)
|
||||
{
|
||||
coord_t scrollPosition = window->getScrollPositionY();
|
||||
window->clear();
|
||||
build(window, focusIdx);
|
||||
window->setScrollPositionY(scrollPosition);
|
||||
}
|
||||
|
||||
void ModelMixerScriptsPage::build(FormWindow * window, int8_t focusIdx)
|
||||
{
|
||||
FormGridLayout grid;
|
||||
grid.spacer(PAGE_PADDING);
|
||||
grid.setLabelWidth(66);
|
||||
|
||||
int8_t scriptIdx = 0;
|
||||
for (int8_t idx = 0; idx < MAX_SCRIPTS; idx++) {
|
||||
|
||||
ScriptInternalData* runtimeData = nullptr;
|
||||
ScriptData &sd = g_model.scriptsData[idx];
|
||||
|
||||
if (sd.file[0] != '\0') {
|
||||
runtimeData = &(scriptInternalData[scriptIdx++]);
|
||||
}
|
||||
|
||||
// LUAx label
|
||||
auto txt = new StaticText(window, grid.getLabelSlot(),
|
||||
std::string("LUA") + std::to_string(idx + 1),
|
||||
BUTTON_BACKGROUND, CENTERED);
|
||||
|
||||
Button* button = new ScriptLineButton(window, grid.getFieldSlot(), sd, runtimeData);
|
||||
|
||||
button->setPressHandler([=]() -> uint8_t {
|
||||
Menu* menu = new Menu(window);
|
||||
menu->addLine(STR_EDIT, [=]() { editLine(window, idx); });
|
||||
|
||||
if (runtimeData != nullptr) {
|
||||
menu->addLine(STR_RESET, [=]() {
|
||||
memset((void*)&sd, 0, sizeof(sd));
|
||||
// TODO: anything else? reload scripts???
|
||||
storageDirty(EE_MODEL);
|
||||
rebuild(window, idx);
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
button->setFocusHandler([=](bool focus) {
|
||||
if (focus) {
|
||||
txt->setBackgroundColor(FOCUS_BGCOLOR);
|
||||
txt->setTextFlags(FOCUS_COLOR | CENTERED);
|
||||
} else {
|
||||
txt->setBackgroundColor(FIELD_FRAME_COLOR);
|
||||
txt->setTextFlags(CENTERED);
|
||||
}
|
||||
txt->invalidate();
|
||||
});
|
||||
|
||||
if (focusIdx == idx) {
|
||||
button->setFocus(SET_FOCUS_DEFAULT);
|
||||
txt->setBackgroundColor(FOCUS_BGCOLOR);
|
||||
txt->setTextFlags(FOCUS_COLOR | CENTERED);
|
||||
txt->invalidate();
|
||||
}
|
||||
|
||||
txt->setHeight(button->height());
|
||||
grid.spacer(button->height() + 5);
|
||||
}
|
||||
|
||||
grid.nextLine();
|
||||
window->setInnerHeight(grid.getWindowHeight());
|
||||
}
|
||||
|
||||
void ModelMixerScriptsPage::editLine(FormWindow * window, uint8_t idx)
|
||||
{
|
||||
Window::clearFocus();
|
||||
Window * editWindow = new ScriptEditWindow(idx);
|
||||
editWindow->setCloseHandler([=]() {
|
||||
rebuild(window, idx);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 "tabsgroup.h"
|
||||
|
||||
class ModelMixerScriptsPage: public PageTab {
|
||||
public:
|
||||
ModelMixerScriptsPage();
|
||||
|
||||
virtual void build(FormWindow * window) override
|
||||
{
|
||||
build(window, 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
void build(FormWindow * window, int8_t focusIdx);
|
||||
void rebuild(FormWindow * window, int8_t focusIdx);
|
||||
void editLine(FormWindow * window, uint8_t idx);
|
||||
};
|
||||
@@ -89,7 +89,7 @@ class MixEditWindow : public Page
|
||||
|
||||
// Mix name
|
||||
new StaticText(window, grid.getLabelSlot(), STR_MIXNAME);
|
||||
new RadioTextEdit(window, grid.getFieldSlot(), mix->name,
|
||||
new ModelTextEdit(window, grid.getFieldSlot(), mix->name,
|
||||
sizeof(mix->name));
|
||||
grid.nextLine();
|
||||
|
||||
@@ -531,24 +531,22 @@ void copyMix(uint8_t source, uint8_t dest, int8_t ch)
|
||||
pauseMixerCalculations();
|
||||
MixData sourceMix;
|
||||
memcpy(&sourceMix, mixAddress(source), sizeof(MixData));
|
||||
MixData * mix = mixAddress(dest);
|
||||
if(ch == PASTE_AFTER) {
|
||||
memmove(mix+2, mix+1, (MAX_MIXERS-(source+1))*sizeof(MixData));
|
||||
memcpy(mix+1, &sourceMix, sizeof(MixData));
|
||||
(mix+1)->destCh = (mix)->destCh;
|
||||
}
|
||||
else if(ch == PASTE_BEFORE) {
|
||||
memmove(mix+1, mix, (MAX_MIXERS-(source+1))*sizeof(MixData));
|
||||
MixData *mix = mixAddress(dest);
|
||||
size_t trailingMixes = MAX_MIXERS - (dest + 1);
|
||||
if (ch == PASTE_AFTER) {
|
||||
trailingMixes--;
|
||||
memmove(mix + 2, mix + 1, trailingMixes * sizeof(MixData));
|
||||
memcpy(mix + 1, &sourceMix, sizeof(MixData));
|
||||
(mix + 1)->destCh = (mix)->destCh;
|
||||
} else if (ch == PASTE_BEFORE) {
|
||||
memmove(mix + 1, mix, trailingMixes * sizeof(MixData));
|
||||
memcpy(mix, &sourceMix, sizeof(MixData));
|
||||
mix->destCh = (mix+1)->destCh;
|
||||
}
|
||||
else {
|
||||
memmove(mix+1, mix, (MAX_MIXERS-(source+1))*sizeof(MixData));
|
||||
mix->destCh = (mix + 1)->destCh;
|
||||
} else {
|
||||
memmove(mix + 1, mix, trailingMixes * sizeof(MixData));
|
||||
memcpy(mix, &sourceMix, sizeof(MixData));
|
||||
mix->destCh = ch;
|
||||
mix->destCh = ch;
|
||||
}
|
||||
|
||||
//memmove(mix + 1, mix, (MAX_MIXERS - (dest + 1)) * sizeof(MixData));
|
||||
resumeMixerCalculations();
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class OutputEditWindow : public Page {
|
||||
|
||||
// Name
|
||||
new StaticText(window, grid.getLabelSlot(), STR_NAME);
|
||||
new RadioTextEdit(window, grid.getFieldSlot(), output->name, sizeof(output->name));
|
||||
new ModelTextEdit(window, grid.getFieldSlot(), output->name, sizeof(output->name));
|
||||
grid.nextLine();
|
||||
|
||||
// Offset
|
||||
@@ -130,7 +130,7 @@ class OutputLineButton : public Button {
|
||||
LcdFlags bgColor = FIELD_BGCOLOR;
|
||||
|
||||
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
|
||||
|
||||
|
||||
// first line
|
||||
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000,
|
||||
PREC1 | textColor);
|
||||
|
||||
@@ -245,7 +245,8 @@ class ModelCategoryPageBody : public FormWindow
|
||||
|
||||
modelslist.setCurrentModel(model);
|
||||
modelslist.setCurrentCategory(category);
|
||||
update();
|
||||
this->onEvent(EVT_KEY_FIRST(KEY_EXIT));
|
||||
checkAll();
|
||||
});
|
||||
}
|
||||
menu->addLine(STR_CREATE_MODEL, getCreateModelAction());
|
||||
|
||||
@@ -630,22 +630,42 @@ class ModuleWindow : public FormGroup {
|
||||
|
||||
// Multi type (CUSTOM, brand A, brand B,...)
|
||||
int multiRfProto = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
rfChoice = new Choice(this, grid.getFieldSlot(g_model.moduleData[moduleIdx].multi.customProto ? 3 : 2, 0), STR_MULTI_PROTOCOLS, MODULE_SUBTYPE_MULTI_FIRST, MODULE_SUBTYPE_MULTI_LAST,
|
||||
GET_DEFAULT(multiRfProto),
|
||||
[=](int32_t newValue) {
|
||||
g_model.moduleData[moduleIdx].setMultiProtocol(newValue);
|
||||
g_model.moduleData[moduleIdx].subType = 0;
|
||||
if (mmSubProtocol != nullptr) mmSubProtocol->invalidate();
|
||||
resetMultiProtocolsOptions(moduleIdx);
|
||||
SET_DIRTY();
|
||||
update();
|
||||
rfChoice->setFocus(SET_FOCUS_DEFAULT);
|
||||
});
|
||||
rfChoice = new Choice(
|
||||
this,
|
||||
grid.getFieldSlot(
|
||||
g_model.moduleData[moduleIdx].multi.customProto ? 3 : 2, 0),
|
||||
STR_MULTI_PROTOCOLS, MODULE_SUBTYPE_MULTI_FIRST,
|
||||
MODULE_SUBTYPE_MULTI_LAST, GET_DEFAULT(multiRfProto),
|
||||
[=](int32_t newValue) {
|
||||
g_model.moduleData[moduleIdx].setMultiProtocol(newValue);
|
||||
g_model.moduleData[moduleIdx].subType = 0;
|
||||
if (mmSubProtocol != nullptr) mmSubProtocol->invalidate(); // always null ???
|
||||
resetMultiProtocolsOptions(moduleIdx);
|
||||
SET_DIRTY();
|
||||
update();
|
||||
rfChoice->setFocus(SET_FOCUS_DEFAULT);// really valid ???
|
||||
});
|
||||
|
||||
// Subtype (D16, DSMX,...)
|
||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(g_model.moduleData[moduleIdx].getMultiProtocol());
|
||||
if (pdef->maxSubtype > 0)
|
||||
mmSubProtocol = new Choice(this, grid.getFieldSlot(2, 1), pdef->subTypeString, 0, pdef->maxSubtype,GET_SET_DEFAULT(g_model.moduleData[moduleIdx].subType));
|
||||
if (MULTIMODULE_HAS_SUBTYPE(moduleIdx)) {
|
||||
// Subtype (D16, DSMX,...)
|
||||
const mm_protocol_definition *pdef = getMultiProtocolDefinition(
|
||||
g_model.moduleData[moduleIdx].getMultiProtocol());
|
||||
if (pdef->maxSubtype > 0) {
|
||||
mmSubProtocol = new Choice(
|
||||
this, grid.getFieldSlot(2, 1), pdef->subTypeString, 0,
|
||||
pdef->maxSubtype,
|
||||
[=]() { return g_model.moduleData[moduleIdx].subType; },
|
||||
[=](int16_t newValue) {
|
||||
g_model.moduleData[moduleIdx].subType = newValue;
|
||||
resetMultiProtocolsOptions(moduleIdx);
|
||||
SET_DIRTY();
|
||||
// update(); ??? how to set focus properly ???
|
||||
update();
|
||||
//mmSubProtocol->setFocus(SET_FOCUS_DEFAULT);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
grid.nextLine();
|
||||
|
||||
// Multimodule status
|
||||
@@ -664,46 +684,122 @@ class ModuleWindow : public FormGroup {
|
||||
new StaticText(this, grid.getFieldSlot(), statusText);
|
||||
}*/
|
||||
|
||||
// Multi optional feature row
|
||||
const uint8_t multi_proto = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
if (pdef->optionsstr) {
|
||||
grid.nextLine();
|
||||
new StaticText(this, grid.getLabelSlot(true), pdef->optionsstr);
|
||||
if (multi_proto == MODULE_SUBTYPE_MULTI_FS_AFHDS2A) {
|
||||
auto edit = new NumberEdit(this, grid.getFieldSlot(2,0), 50, 400,
|
||||
GET_DEFAULT(50 + 5 * g_model.moduleData[moduleIdx].multi.optionValue),
|
||||
SET_VALUE(g_model.moduleData[moduleIdx].multi.optionValue, (newValue- 50) / 5));
|
||||
edit->setStep(5);
|
||||
}
|
||||
else if (multi_proto == MODULE_SUBTYPE_MULTI_OLRS) {
|
||||
new NumberEdit(this, grid.getFieldSlot(2,0), -1, 7, GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
}
|
||||
else {
|
||||
new NumberEdit(this, grid.getFieldSlot(2,0), -128, 127, GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
if (MULTIMODULE_PROTOCOL_KNOWN(moduleIdx)) {
|
||||
// Multi optional feature row
|
||||
const char *title = getMultiOptionTitleStatic(moduleIdx);
|
||||
if (title != nullptr) {
|
||||
grid.nextLine();
|
||||
new StaticText(this, grid.getLabelSlot(true), title);
|
||||
|
||||
//Show RSSI next to RF Freq Fine Tune
|
||||
if (getMultiOptionTitle(moduleIdx) == STR_MULTI_RFTUNE)
|
||||
{
|
||||
new DynamicNumber<int>(this, grid.getFieldSlot(2, 1), [] {
|
||||
return (int)TELEMETRY_RSSI();}, 0, "RSSI: ", " db");
|
||||
// int optionValue =
|
||||
// g_model.moduleData[moduleIdx].multi.optionValue;
|
||||
int8_t min, max;
|
||||
getMultiOptionValues(multi_proto, min, max);
|
||||
|
||||
if (title == STR_MULTI_RFPOWER) {
|
||||
new Choice(this, grid.getFieldSlot(2, 0), STR_MULTI_POWER, 0, 15,
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
} else if (title == STR_MULTI_TELEMETRY) {
|
||||
new Choice(this, grid.getFieldSlot(2, 0),
|
||||
STR_MULTI_TELEMETRY_MODE, min, max,
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
} else if (title == STR_MULTI_WBUS) {
|
||||
new Choice(this, grid.getFieldSlot(2, 0), STR_MULTI_WBUS_MODE, 0,
|
||||
1,
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
} else if (multi_proto == MODULE_SUBTYPE_MULTI_FS_AFHDS2A) {
|
||||
auto edit = new NumberEdit(
|
||||
this, grid.getFieldSlot(2, 0), 50, 400,
|
||||
GET_DEFAULT(
|
||||
50 + 5 * g_model.moduleData[moduleIdx].multi.optionValue),
|
||||
SET_VALUE(g_model.moduleData[moduleIdx].multi.optionValue,
|
||||
(newValue - 50) / 5));
|
||||
edit->setStep(5);
|
||||
} else if (multi_proto == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
new CheckBox(
|
||||
this, grid.getFieldSlot(2, 0),
|
||||
[=]() {
|
||||
return g_model.moduleData[moduleIdx].multi.optionValue &
|
||||
0x01;
|
||||
},
|
||||
[=](int16_t newValue) {
|
||||
g_model.moduleData[moduleIdx].multi.optionValue =
|
||||
(g_model.moduleData[moduleIdx].multi.optionValue &
|
||||
0xFE) +
|
||||
newValue;
|
||||
});
|
||||
} else {
|
||||
if (min == 0 && max == 1) {
|
||||
new CheckBox(
|
||||
this, grid.getFieldSlot(2, 0),
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
} else {
|
||||
new NumberEdit(
|
||||
this, grid.getFieldSlot(2, 0), -128, 127,
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.optionValue));
|
||||
|
||||
// Show RSSI next to RF Freq Fine Tune
|
||||
if (title == STR_MULTI_RFTUNE) {
|
||||
new DynamicNumber<int>(
|
||||
this, grid.getFieldSlot(2, 1),
|
||||
[] { return (int)TELEMETRY_RSSI(); }, 0, "RSSI: ", " db");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bind on power up
|
||||
grid.nextLine();
|
||||
new StaticText(this, grid.getLabelSlot(true),g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM2 ? STR_MULTI_DSM_AUTODTECT : STR_MULTI_AUTOBIND);
|
||||
new CheckBox(this, grid.getFieldSlot(), GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.autoBindMode));
|
||||
|
||||
if (multi_proto == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
|
||||
const char* servoRates[] = { "22ms", "11ms" };
|
||||
|
||||
new StaticText(this, grid.getLabelSlot(true), STR_MULTI_SERVOFREQ);
|
||||
new Choice(
|
||||
this, grid.getFieldSlot(), servoRates, 0, 1,
|
||||
[=]() {
|
||||
return (g_model.moduleData[moduleIdx].multi.optionValue & 0x02) >> 1;
|
||||
},
|
||||
[=](int16_t newValue) {
|
||||
g_model.moduleData[moduleIdx].multi.optionValue =
|
||||
(g_model.moduleData[moduleIdx].multi.optionValue & 0xFD) +
|
||||
(newValue << 1);
|
||||
});
|
||||
} else {
|
||||
// Bind on power up
|
||||
new StaticText(this, grid.getLabelSlot(true), STR_MULTI_AUTOBIND);
|
||||
new CheckBox(this, grid.getFieldSlot(),
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.autoBindMode));
|
||||
}
|
||||
|
||||
// Low power mode
|
||||
grid.nextLine();
|
||||
new StaticText(this, grid.getLabelSlot(true), STR_MULTI_LOWPOWER);
|
||||
new CheckBox(this, grid.getFieldSlot(), GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.lowPowerMode));
|
||||
new CheckBox(
|
||||
this, grid.getFieldSlot(),
|
||||
GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.lowPowerMode));
|
||||
|
||||
// Disable telemetry
|
||||
grid.nextLine();
|
||||
new StaticText(this, grid.getLabelSlot(true), STR_DISABLE_TELEM);
|
||||
new CheckBox(this, grid.getFieldSlot(), GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.disableMapping));
|
||||
new CheckBox(this, grid.getFieldSlot(),
|
||||
GET_SET_DEFAULT(
|
||||
g_model.moduleData[moduleIdx].multi.disableTelemetry));
|
||||
|
||||
if (MULTI_DISABLE_CHAN_MAP_ROW_STATIC(moduleIdx) != HIDDEN_ROW) {
|
||||
// Disable channel mapping
|
||||
grid.nextLine();
|
||||
new StaticText(this, grid.getLabelSlot(true), STR_DISABLE_CH_MAP);
|
||||
new CheckBox(this, grid.getFieldSlot(),
|
||||
GET_SET_DEFAULT(g_model.moduleData[moduleIdx].multi.disableMapping));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(AFHDS3)
|
||||
@@ -1021,15 +1117,16 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
|
||||
// Model name
|
||||
new StaticText(window, grid.getLabelSlot(), STR_MODELNAME);
|
||||
auto text = new RadioTextEdit(window, grid.getFieldSlot(), g_model.header.name, sizeof(g_model.header.name),
|
||||
0, MODEL_NAME_EXTRA_CHARS);
|
||||
auto text =
|
||||
new ModelTextEdit(window, grid.getFieldSlot(), g_model.header.name,
|
||||
sizeof(g_model.header.name), 0, MODEL_NAME_EXTRA_CHARS);
|
||||
text->setChangeHandler([=] {
|
||||
modelslist.load();
|
||||
auto model = modelslist.getCurrentModel();
|
||||
if (model) {
|
||||
model->setModelName(g_model.header.name);
|
||||
}
|
||||
SET_DIRTY();
|
||||
modelslist.load();
|
||||
auto model = modelslist.getCurrentModel();
|
||||
if (model) {
|
||||
model->setModelName(g_model.header.name);
|
||||
}
|
||||
SET_DIRTY();
|
||||
});
|
||||
grid.nextLine();
|
||||
|
||||
@@ -1139,7 +1236,17 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
|
||||
// Throttle source
|
||||
new StaticText(window, grid.getLabelSlot(true), STR_TTRACE);
|
||||
new SourceChoice(window, grid.getFieldSlot(), 0, MIXSRC_LAST_CH, GET_SET_DEFAULT(g_model.thrTraceSrc));
|
||||
auto sc = new SourceChoice(
|
||||
window, grid.getFieldSlot(), 0, MIXSRC_LAST_CH,
|
||||
[=]() { return throttleSource2Source(g_model.thrTraceSrc); },
|
||||
[=](int16_t src) {
|
||||
int16_t val = source2ThrottleSource(src);
|
||||
if (val >= 0) {
|
||||
g_model.thrTraceSrc = val;
|
||||
SET_DIRTY();
|
||||
}
|
||||
});
|
||||
sc->setAvailableHandler(isThrottleSourceAvailable);
|
||||
grid.nextLine();
|
||||
|
||||
// Throttle trim
|
||||
@@ -1149,7 +1256,10 @@ void ModelSetupPage::build(FormWindow * window)
|
||||
|
||||
// Throttle trim source
|
||||
new StaticText(window, grid.getLabelSlot(true), STR_TTRIM_SW);
|
||||
new SourceChoice(window, grid.getFieldSlot(), 0, NUM_TRIMS - 1, GET_SET_DEFAULT( g_model.thrTrimSw));
|
||||
new SourceChoice(
|
||||
window, grid.getFieldSlot(), MIXSRC_FIRST_TRIM, MIXSRC_LAST_TRIM,
|
||||
[=]() { return g_model.getThrottleStickTrimSource(); },
|
||||
[=](int16_t src) { g_model.setThrottleStickTrimSource(src); });
|
||||
grid.nextLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,19 +32,19 @@ class DebugInfoNumber : public Window
|
||||
public:
|
||||
DebugInfoNumber(Window * parent, const rect_t & rect, std::function<T()> numberHandler, LcdFlags textFlags = 0, const char * prefix = nullptr, const char * suffix = nullptr):
|
||||
Window(parent, rect, 0, textFlags),
|
||||
numberHandler(std::move(numberHandler)),
|
||||
prefix(prefix),
|
||||
suffix(suffix)
|
||||
{
|
||||
coord_t prefixSize = getTextWidth(prefix, 0, HEADER_COLOR | FONT(XS));
|
||||
new StaticText(this, {0, 0, prefixSize, rect.h}, prefix, 0, HEADER_COLOR | FONT(XS));
|
||||
new DynamicNumber<uint32_t>(this, {prefixSize, 0, rect.w - prefixSize, rect.h}, [] {
|
||||
return menusStack.available();
|
||||
});
|
||||
coord_t prefixSize = 0;
|
||||
if (prefix != nullptr) {
|
||||
prefixSize = getTextWidth(prefix, 0, HEADER_COLOR | FONT(XS));
|
||||
new StaticText(this, {0, 0, prefixSize, rect.h}, prefix, 0, HEADER_COLOR | FONT(XS));
|
||||
}
|
||||
new DynamicNumber<uint32_t>(this, {prefixSize, 0, rect.w - prefixSize, rect.h},
|
||||
numberHandler);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::function<T()> numberHandler;
|
||||
const char * prefix;
|
||||
const char * suffix;
|
||||
};
|
||||
|
||||
@@ -75,13 +75,13 @@ class ViewTextWindow : public Page
|
||||
}
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer* dc)
|
||||
void paint(BitmapBuffer* dc) override
|
||||
{
|
||||
Page::paint(dc);
|
||||
drawVerticalScrollbar(dc);
|
||||
}
|
||||
#endif
|
||||
virtual void checkEvents();
|
||||
void checkEvents() override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override { return "ViewTextWindow"; };
|
||||
@@ -123,4 +123,4 @@ bool isInSetup;
|
||||
};
|
||||
};
|
||||
|
||||
void readModelNotes();
|
||||
void readModelNotes();
|
||||
|
||||
@@ -75,7 +75,7 @@ class OutputsWidget: public Widget
|
||||
dc->drawSizedText(barLft + 23, barTop, g_model.limitData[curChan - 1].name, sizeof(g_model.limitData[curChan - 1].name), FONT(XS) | DEFAULT_COLOR | LEFT);
|
||||
}
|
||||
else {
|
||||
drawSource(dc, barLft + 1, barTop, curChan, FONT(XS) | DEFAULT_COLOR | LEFT);
|
||||
drawSource(dc, barLft + 1, barTop, MIXSRC_FIRST_CH+curChan-1, FONT(XS) | DEFAULT_COLOR | LEFT);
|
||||
}
|
||||
}
|
||||
return lastChan - 1;
|
||||
@@ -111,7 +111,7 @@ class OutputsWidget: public Widget
|
||||
lastRefresh = now;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
#include "opentx.h"
|
||||
#include "widgets_container_impl.h"
|
||||
|
||||
// libopemui defines TIMOUR as zero
|
||||
#ifdef TIMEHOUR
|
||||
#undef TIMEHOUR
|
||||
#define TIMEHOUR 0x2000
|
||||
#endif
|
||||
|
||||
class TimerWidget: public Widget
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -86,30 +86,45 @@ class ValueWidget: public Widget
|
||||
if (timerState.val < 0) {
|
||||
color = ALARM_COLOR;
|
||||
}
|
||||
drawSource(dc, NUMBERS_PADDING, 2, field, color);
|
||||
drawSource(dc, NUMBERS_PADDING + 1, 3, field, COLOR2FLAGS(BLACK));
|
||||
drawTimer(dc, xValue, yValue, abs(timerState.val), attrValue | FONT(XL) | color);
|
||||
}
|
||||
|
||||
if (field == MIXSRC_TX_TIME) {
|
||||
drawTimer(dc, xValue, yValue, getValue(MIXSRC_TX_TIME),
|
||||
attrValue | FONT(XL) | color);
|
||||
}
|
||||
|
||||
if (field >= MIXSRC_FIRST_TELEM) {
|
||||
TelemetryItem & telemetryItem = telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3];
|
||||
if (!telemetryItem.isAvailable() || telemetryItem.isOld()) {
|
||||
color = TEXT_DISABLE_COLOR;
|
||||
if (persistentData->options[2].value.boolValue) {
|
||||
drawSource(dc, xLabel + 1, yLabel + 1, field, attrLabel | COLOR2FLAGS(BLACK));
|
||||
drawTimer(dc, xValue + 1, yValue + 1, abs(timerState.val),
|
||||
attrValue | FONT(STD) | COLOR2FLAGS(BLACK));
|
||||
}
|
||||
}
|
||||
drawSource(dc, xLabel, yLabel, field, attrLabel | color);
|
||||
drawTimer(dc, xValue, yValue, abs(timerState.val),
|
||||
attrValue | FONT(STD) | color);
|
||||
|
||||
if (persistentData->options[2].value.boolValue) {
|
||||
drawSource(dc,xLabel + 1, yLabel + 1, field, attrLabel | COLOR2FLAGS(BLACK));
|
||||
drawSourceValue(dc, xValue + 1, yValue + 1, field, attrValue | COLOR2FLAGS(BLACK));
|
||||
}
|
||||
} else if (field == MIXSRC_TX_TIME) {
|
||||
int32_t tme = getValue(MIXSRC_TX_TIME);
|
||||
if (persistentData->options[2].value.boolValue) {
|
||||
drawSource(dc, xLabel + 1, yLabel + 1, field, COLOR2FLAGS(BLACK));
|
||||
drawTimer(dc, xValue + 1, yValue + 1, tme,
|
||||
attrValue | FONT(STD) | COLOR2FLAGS(BLACK));
|
||||
}
|
||||
drawSource(dc, xLabel, yLabel, field, attrLabel | color);
|
||||
drawTimer(dc, xValue, yValue, tme,
|
||||
attrValue | FONT(STD) | color);
|
||||
} else {
|
||||
|
||||
drawSource(dc, xLabel, yLabel, field, attrLabel | color);
|
||||
drawSourceValue(dc, xValue, yValue, field, attrValue | color);
|
||||
if (field >= MIXSRC_FIRST_TELEM) {
|
||||
TelemetryItem& telemetryItem =
|
||||
telemetryItems[(field - MIXSRC_FIRST_TELEM) / 3];
|
||||
if (!telemetryItem.isAvailable() || telemetryItem.isOld()) {
|
||||
color = TEXT_DISABLE_COLOR;
|
||||
}
|
||||
}
|
||||
|
||||
if (persistentData->options[2].value.boolValue) {
|
||||
drawSource(dc, xLabel + 1, yLabel + 1, field,
|
||||
attrLabel | COLOR2FLAGS(BLACK));
|
||||
drawSourceValue(dc, xValue + 1, yValue + 1, field,
|
||||
attrValue | COLOR2FLAGS(BLACK));
|
||||
}
|
||||
|
||||
drawSource(dc, xLabel, yLabel, field, attrLabel | color);
|
||||
drawSourceValue(dc, xValue, yValue, field, attrValue | color);
|
||||
}
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
|
||||
@@ -442,12 +442,15 @@ bool isSwitch2POSWarningStateAvailable(int state)
|
||||
// return isSwitchAvailable(swtch, TimersContext);
|
||||
//}
|
||||
|
||||
bool isThrottleSourceAvailable(int source)
|
||||
bool isThrottleSourceAvailable(int src)
|
||||
{
|
||||
if (source >= THROTTLE_SOURCE_FIRST_POT && source < THROTTLE_SOURCE_FIRST_POT+NUM_POTS+NUM_SLIDERS && !IS_POT_SLIDER_AVAILABLE(POT1+source-THROTTLE_SOURCE_FIRST_POT))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
#if !defined(LIBOPENUI)
|
||||
src = throttleSource2Source(src);
|
||||
#endif
|
||||
return isSourceAvailable(src) &&
|
||||
((src == MIXSRC_Thr) ||
|
||||
((src >= MIXSRC_FIRST_POT) && (src <= MIXSRC_LAST_POT)) ||
|
||||
((src >= MIXSRC_FIRST_CH) && (src <= MIXSRC_LAST_CH)));
|
||||
}
|
||||
|
||||
bool isLogicalSwitchFunctionAvailable(int function)
|
||||
@@ -1097,6 +1100,13 @@ const mm_protocol_definition *getMultiProtocolDefinition (uint8_t protocol)
|
||||
#endif
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
const char * getMultiOptionTitleStatic(uint8_t moduleIdx)
|
||||
{
|
||||
const uint8_t multi_proto = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(multi_proto);
|
||||
return pdef->optionsstr;
|
||||
}
|
||||
|
||||
const char * getMultiOptionTitle(uint8_t moduleIdx)
|
||||
{
|
||||
MultiModuleStatus &status = getMultiModuleStatus(moduleIdx);
|
||||
@@ -1107,10 +1117,7 @@ const char * getMultiOptionTitle(uint8_t moduleIdx)
|
||||
}
|
||||
return mm_options_strings::options[status.optionDisp];
|
||||
}
|
||||
else {
|
||||
const uint8_t multi_proto = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(multi_proto);
|
||||
return pdef->optionsstr;
|
||||
}
|
||||
|
||||
return getMultiOptionTitleStatic(moduleIdx);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -220,6 +220,21 @@ inline uint8_t IF_ALLOW_RACING_MODE(int)
|
||||
#endif
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
inline uint8_t MULTI_DISABLE_CHAN_MAP_ROW_STATIC(uint8_t moduleIdx)
|
||||
{
|
||||
if (!isModuleMultimodule(moduleIdx))
|
||||
return HIDDEN_ROW;
|
||||
|
||||
uint8_t protocol = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
if (protocol < MODULE_SUBTYPE_MULTI_LAST) {
|
||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(protocol);
|
||||
if (pdef->disable_ch_mapping)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return HIDDEN_ROW;
|
||||
}
|
||||
|
||||
inline uint8_t MULTI_DISABLE_CHAN_MAP_ROW(uint8_t moduleIdx)
|
||||
{
|
||||
if (!isModuleMultimodule(moduleIdx))
|
||||
@@ -230,14 +245,7 @@ inline uint8_t MULTI_DISABLE_CHAN_MAP_ROW(uint8_t moduleIdx)
|
||||
return status.supportsDisableMapping() == true ? 0 : HIDDEN_ROW;
|
||||
}
|
||||
|
||||
uint8_t protocol = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
if (protocol < MODULE_SUBTYPE_MULTI_LAST) {
|
||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(protocol);
|
||||
if (pdef->disable_ch_mapping)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return HIDDEN_ROW;
|
||||
return MULTI_DISABLE_CHAN_MAP_ROW_STATIC(moduleIdx);
|
||||
}
|
||||
|
||||
inline bool isMultiProtocolSelectable(int protocol)
|
||||
@@ -355,6 +363,7 @@ inline uint8_t MODULE_OPTION_ROW(uint8_t moduleIdx) {
|
||||
void editStickHardwareSettings(coord_t x, coord_t y, int idx, event_t event,
|
||||
LcdFlags flags, uint8_t old_editMode);
|
||||
|
||||
const char * getMultiOptionTitleStatic(uint8_t moduleIdx);
|
||||
const char *getMultiOptionTitle(uint8_t moduleIdx);
|
||||
|
||||
const char * writeScreenshot();
|
||||
|
||||
Reference in New Issue
Block a user