feat: use any source for expo/weight/offset (#5220)
Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
co-authored by
philmoz
3djc
elecpower
parent
326c58a7fd
commit
4b917b762c
@@ -47,7 +47,7 @@
|
||||
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-3)
|
||||
#define CURVE_CENTER_Y (LCD_H/2)
|
||||
|
||||
#define MIXES_2ND_COLUMN (12*FW)
|
||||
#define MIXES_2ND_COLUMN (10*FW)
|
||||
|
||||
// Temporary no highlight
|
||||
extern uint8_t noHighlightCounter;
|
||||
@@ -80,6 +80,10 @@ uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label,
|
||||
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr,
|
||||
event_t event);
|
||||
|
||||
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
|
||||
int16_t min, int16_t max, LcdFlags attr, event_t event,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin);
|
||||
|
||||
#if defined(GVARS)
|
||||
|
||||
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) \
|
||||
@@ -110,8 +114,6 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
|
||||
|
||||
#endif
|
||||
|
||||
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
|
||||
|
||||
void editName(coord_t x, coord_t y, char *name, uint8_t size, event_t event,
|
||||
uint8_t active, LcdFlags attr, uint8_t old_editMode);
|
||||
|
||||
@@ -198,7 +200,8 @@ void showAlertBox(const char * title, const char * text, const char * action , u
|
||||
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuViewTelemetry
|
||||
#define IS_OTHER_VIEW_DISPLAYED() menuHandlers[0] == menuChannelsView
|
||||
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin);
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
void displayFlightModes(coord_t x, coord_t y, FlightModesType value);
|
||||
|
||||
@@ -662,55 +662,6 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
|
||||
putsVolts(x, y, g_vbat100mV, att);
|
||||
}
|
||||
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
|
||||
{
|
||||
uint16_t aidx = abs(idx);
|
||||
bool inverted = idx < 0;
|
||||
|
||||
if (aidx == MIXSRC_NONE) {
|
||||
lcdDrawText(x, y, STR_EMPTY, att);
|
||||
}
|
||||
else if (aidx <= MIXSRC_LAST_INPUT) {
|
||||
if (inverted) {
|
||||
lcdDrawChar(x, y, '!');
|
||||
x += 2;
|
||||
}
|
||||
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
|
||||
lcdDrawSolidFilledRect(x, y, 7, 7);
|
||||
if (g_model.inputNames[aidx-MIXSRC_FIRST_INPUT][0])
|
||||
lcdDrawSizedText(x+8, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
|
||||
else
|
||||
lcdDrawNumber(x+8, y, aidx, att|LEADING0|LEFT, 2);
|
||||
}
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (aidx <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div((uint16_t)(aidx-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (inverted) {
|
||||
lcdDrawChar(x, y, '!');
|
||||
x += 2;
|
||||
}
|
||||
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
|
||||
lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE);
|
||||
lcdDrawFilledRect(x, y, 7, 7, 0);
|
||||
lcdDrawSizedText(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
|
||||
lcdDrawChar(lcdLastRightPos, y, 'a' + qr.rem, att);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
const char* s = getSourceString(idx);
|
||||
if (idx >= MIXSRC_FIRST_TELEM && idx <= MIXSRC_LAST_TELEM)
|
||||
s += strlen(STR_CHAR_TELEMETRY);
|
||||
lcdDrawText(x, y, s, att);
|
||||
}
|
||||
}
|
||||
|
||||
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
|
||||
{
|
||||
lcdDrawText(x, y, getAnalogShortLabel(idx), att);
|
||||
|
||||
@@ -116,7 +116,6 @@ void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val);
|
||||
void drawModelName(coord_t x, coord_t y, char * name, uint8_t id, LcdFlags att);
|
||||
#if !defined(BOOT) // TODO not here ...
|
||||
void drawSwitch(coord_t x, coord_t y, swsrc_t swtch, LcdFlags att=0, bool autoBold = true);
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
|
||||
#endif
|
||||
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
|
||||
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#define EXPO_ONE_2ND_COLUMN (7*FW+3*FW+2)
|
||||
#define EXPO_ONE_2ND_COLUMN (6*FW+1)
|
||||
|
||||
int expoFn(int x)
|
||||
{
|
||||
@@ -91,39 +91,39 @@ void menuModelExpoOne(event_t event)
|
||||
|
||||
switch (i) {
|
||||
case EXPO_FIELD_INPUT_NAME:
|
||||
editSingleName(EXPO_ONE_2ND_COLUMN - LEN_INPUT_NAME * FW, y,
|
||||
editSingleName(EXPO_ONE_2ND_COLUMN, y,
|
||||
STR_INPUTNAME, g_model.inputNames[ed->chn],
|
||||
LEN_INPUT_NAME, event, (attr != 0), old_editMode);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_LINE_NAME:
|
||||
editSingleName(EXPO_ONE_2ND_COLUMN - LEN_EXPOMIX_NAME * FW, y,
|
||||
editSingleName(EXPO_ONE_2ND_COLUMN, y,
|
||||
STR_EXPONAME, ed->name, LEN_EXPOMIX_NAME, event,
|
||||
(attr != 0), old_editMode);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_SOURCE:
|
||||
lcdDrawTextAlignedLeft(y, STR_SOURCE);
|
||||
drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, RIGHT|STREXPANDED|attr);
|
||||
drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|attr);
|
||||
if (attr)
|
||||
ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailableInInputs);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_SCALE:
|
||||
lcdDrawTextAlignedLeft(y, STR_SCALE);
|
||||
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, convertTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1, ed->scale), RIGHT | attr);
|
||||
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, convertTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1, ed->scale), attr);
|
||||
if (attr)
|
||||
ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_WEIGHT:
|
||||
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
|
||||
ed->weight = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->weight, -100, 100, RIGHT | attr, 0, event);
|
||||
ed->weight = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_WEIGHT, ed->weight,
|
||||
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_OFFSET:
|
||||
lcdDrawTextAlignedLeft(y, STR_OFFSET);
|
||||
ed->offset = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->offset, -100, 100, RIGHT | attr, 0, event);
|
||||
ed->offset = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_OFFSET, ed->offset,
|
||||
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_CURVE_LABEL:
|
||||
@@ -131,7 +131,7 @@ void menuModelExpoOne(event_t event)
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_CURVE:
|
||||
editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, RIGHT | attr);
|
||||
editCurveRef(FW + 1, y, ed->curve, event, attr, isSourceAvailableInInputs, INPUTSRC_FIRST);
|
||||
break;
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
@@ -140,23 +140,23 @@ void menuModelExpoOne(event_t event)
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_FLIGHT_MODES:
|
||||
ed->flightModes = editFlightModes(EXPO_ONE_2ND_COLUMN-9*FW+1, y, event, ed->flightModes, attr);
|
||||
ed->flightModes = editFlightModes(EXPO_ONE_2ND_COLUMN-5*FW-2, y, event, ed->flightModes, attr);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case EXPO_FIELD_SWITCH:
|
||||
ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, RIGHT | attr, event);
|
||||
ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_SIDE:
|
||||
ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VCURVEFUNC, 4-ed->mode, 1, 3, RIGHT | attr, event);
|
||||
ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VCURVEFUNC, 4-ed->mode, 1, 3, attr, event);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_TRIM:
|
||||
lcdDrawTextAlignedLeft(y, STR_TRIM);
|
||||
{
|
||||
const char* trim_str = getTrimSourceLabel(abs(ed->srcRaw), ed->trimSource);
|
||||
LcdFlags flags = RIGHT | (menuHorizontalPosition==0 ? attr : 0);
|
||||
LcdFlags flags = (menuHorizontalPosition==0 ? attr : 0);
|
||||
lcdDrawText(EXPO_ONE_2ND_COLUMN, y, trim_str, flags);
|
||||
|
||||
if (attr) {
|
||||
|
||||
@@ -43,13 +43,15 @@ enum MixFields {
|
||||
|
||||
extern uint8_t FM_ROW(uint8_t);
|
||||
|
||||
extern int32_t getSourceNumFieldValue(int16_t val, int16_t min, int16_t max);
|
||||
|
||||
void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
||||
{
|
||||
const int gaugeWidth = 33;
|
||||
const int gaugeHeight = 6;
|
||||
|
||||
int offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
|
||||
int weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
|
||||
int offset = getSourceNumFieldValue(md->offset, MIX_OFFSET_MIN, MIX_OFFSET_MAX) / 10;
|
||||
int weight = getSourceNumFieldValue(md->weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX) / 10;
|
||||
int barMin = offset - weight;
|
||||
int barMax = offset + weight;
|
||||
if (y > 15) {
|
||||
@@ -137,20 +139,15 @@ void menuModelMixOne(event_t event)
|
||||
break;
|
||||
|
||||
case MIX_FIELD_WEIGHT:
|
||||
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
|
||||
gvarWeightItem(MIXES_2ND_COLUMN, y, md2, attr|LEFT, event);
|
||||
md2->weight = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_WEIGHT, md2->weight,
|
||||
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, attr, event, isSourceAvailable, 1);
|
||||
break;
|
||||
|
||||
case MIX_FIELD_OFFSET:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_OFFSET);
|
||||
u_int8int16_t offset;
|
||||
MD_OFFSET_TO_UNION(md2, offset);
|
||||
offset.word = GVAR_MENU_ITEM(MIXES_2ND_COLUMN, y, offset.word, MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr|LEFT, 0, event);
|
||||
MD_UNION_TO_OFFSET(offset, md2);
|
||||
drawOffsetBar(MIXES_2ND_COLUMN+22, y, md2);
|
||||
md2->offset = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_OFFSET, md2->offset,
|
||||
MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr, event, isSourceAvailable, 1);
|
||||
drawOffsetBar(LCD_W - 33, y, md2);
|
||||
break;
|
||||
}
|
||||
|
||||
case MIX_FIELD_TRIM:
|
||||
lcdDrawTextAlignedLeft(y, STR_TRIM);
|
||||
@@ -162,7 +159,7 @@ void menuModelMixOne(event_t event)
|
||||
lcdDrawTextAlignedLeft(y, STR_CURVE);
|
||||
s_currSrcRaw = md2->srcRaw;
|
||||
s_currScale = 0;
|
||||
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
|
||||
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr, isSourceAvailable, 1);
|
||||
break;
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
|
||||
@@ -162,6 +162,30 @@ void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr)
|
||||
drawSlider(x, y, 5*FW - 1, value, max, attr);
|
||||
}
|
||||
|
||||
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
|
||||
int16_t min, int16_t max, LcdFlags attr, event_t event,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin)
|
||||
{
|
||||
if (title)
|
||||
lcdDrawTextAlignedLeft(y, title);
|
||||
SourceNumVal v;
|
||||
v.rawValue = value;
|
||||
if (v.isSource) {
|
||||
drawSource(x, y, v.value, attr);
|
||||
if (attr & (~RIGHT)) {
|
||||
value = checkIncDec(event, value, sourceMin, MIXSRC_LAST,
|
||||
EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_VALUE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isValueAvailable);
|
||||
}
|
||||
} else {
|
||||
lcdDrawNumber(x, y, v.value, attr);
|
||||
if (attr & (~RIGHT)) {
|
||||
value = checkIncDec(event, value, min, max,
|
||||
EE_MODEL|INCDEC_SOURCE_VALUE|NO_INCDEC_MARKS|(sourceMin == INPUTSRC_FIRST ? INCDEC_SOURCE_NOINPUTS : 0));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#if defined(GVARS)
|
||||
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags)
|
||||
{
|
||||
|
||||
@@ -91,6 +91,10 @@ uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label,
|
||||
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr,
|
||||
event_t event);
|
||||
|
||||
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
|
||||
int16_t min, int16_t max, LcdFlags attr, event_t event,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin);
|
||||
|
||||
#if defined(GVARS)
|
||||
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value,
|
||||
LcdFlags flags = 0);
|
||||
@@ -117,9 +121,8 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
|
||||
|
||||
#endif
|
||||
|
||||
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
|
||||
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin);
|
||||
|
||||
extern uint8_t editNameCursorPos;
|
||||
|
||||
|
||||
@@ -632,51 +632,6 @@ void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
|
||||
lcdDrawSizedText(x, y, getMainControlLabel(idx), UINT8_MAX, att);
|
||||
}
|
||||
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
|
||||
{
|
||||
uint16_t aidx = abs(idx);
|
||||
bool inverted = idx < 0;
|
||||
|
||||
if (aidx == MIXSRC_NONE) {
|
||||
lcdDrawText(x, y, STR_EMPTY, att);
|
||||
}
|
||||
else if (aidx <= MIXSRC_LAST_INPUT) {
|
||||
if (inverted) {
|
||||
lcdDrawChar(x, y, '!');
|
||||
x += 2;
|
||||
}
|
||||
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
|
||||
lcdDrawFilledRect(x, y, 7, 7);
|
||||
if (ZEXIST(g_model.inputNames[aidx-MIXSRC_FIRST_INPUT]))
|
||||
lcdDrawSizedText(x+8, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
|
||||
else
|
||||
lcdDrawNumber(x+8, y, aidx, att|LEADING0|LEFT, 2);
|
||||
}
|
||||
|
||||
else if (aidx <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div((uint16_t)(aidx-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (inverted) {
|
||||
lcdDrawChar(x, y, '!');
|
||||
x += 2;
|
||||
}
|
||||
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
|
||||
lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE);
|
||||
lcdDrawFilledRect(x, y, 7, 7);
|
||||
lcdDrawSizedText(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
|
||||
lcdDrawChar(lcdLastRightPos, y, 'a'+qr.rem, att);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lcdDrawText(x, y, getSourceString(idx), att);
|
||||
}
|
||||
}
|
||||
|
||||
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
|
||||
{
|
||||
lcdDrawText(x, y, getAnalogShortLabel(idx), att);
|
||||
|
||||
@@ -114,7 +114,6 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
|
||||
void drawModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
|
||||
void drawSwitch(coord_t x, coord_t y, int32_t swtch, LcdFlags att=0, bool autoBold = true);
|
||||
void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
|
||||
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
|
||||
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
|
||||
|
||||
|
||||
@@ -119,18 +119,18 @@ void menuModelExpoOne(event_t event)
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_WEIGHT:
|
||||
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
|
||||
ed->weight = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->weight, -100, 100, LEFT|attr, 0, event);
|
||||
ed->weight = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_WEIGHT, ed->weight,
|
||||
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_OFFSET:
|
||||
lcdDrawTextAlignedLeft(y, STR_OFFSET);
|
||||
ed->offset = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->offset, -100, 100, LEFT|attr, 0, event);
|
||||
ed->offset = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_OFFSET, ed->offset,
|
||||
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_CURVE:
|
||||
lcdDrawTextAlignedLeft(y, STR_CURVE);
|
||||
editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, attr);
|
||||
editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, attr, isSourceAvailableInInputs, INPUTSRC_FIRST);
|
||||
break;
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
|
||||
@@ -43,13 +43,15 @@ enum MixFields {
|
||||
|
||||
extern uint8_t FM_ROW(uint8_t);
|
||||
|
||||
extern int32_t getSourceNumFieldValue(int16_t val, int16_t min, int16_t max);
|
||||
|
||||
void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
|
||||
{
|
||||
const int gaugeWidth = 33;
|
||||
const int gaugeHeight = 6;
|
||||
|
||||
int offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
|
||||
int weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
|
||||
int offset = getSourceNumFieldValue(md->offset, MIX_OFFSET_MIN, MIX_OFFSET_MAX) / 10;
|
||||
int weight = getSourceNumFieldValue(md->weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX) / 10;
|
||||
int barMin = offset - weight;
|
||||
int barMax = offset + weight;
|
||||
if (y > 15) {
|
||||
@@ -130,20 +132,15 @@ void menuModelMixOne(event_t event)
|
||||
break;
|
||||
|
||||
case MIX_FIELD_WEIGHT:
|
||||
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
|
||||
gvarWeightItem(MIXES_2ND_COLUMN, y, md2, attr|LEFT, event);
|
||||
md2->weight = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_WEIGHT, md2->weight,
|
||||
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, attr, event, isSourceAvailable, 1);
|
||||
break;
|
||||
|
||||
case MIX_FIELD_OFFSET:
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_OFFSET);
|
||||
u_int8int16_t offset;
|
||||
MD_OFFSET_TO_UNION(md2, offset);
|
||||
offset.word = GVAR_MENU_ITEM(MIXES_2ND_COLUMN, y, offset.word, MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr|LEFT, 0, event);
|
||||
MD_UNION_TO_OFFSET(offset, md2);
|
||||
md2->offset = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_OFFSET, md2->offset,
|
||||
MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr, event, isSourceAvailable, 1);
|
||||
drawOffsetBar(MIXES_2ND_COLUMN+35, y, md2);
|
||||
break;
|
||||
}
|
||||
|
||||
case MIX_FIELD_TRIM:
|
||||
lcdDrawTextAlignedLeft(y, STR_TRIM);
|
||||
@@ -157,7 +154,7 @@ void menuModelMixOne(event_t event)
|
||||
lcdDrawTextAlignedLeft(y, STR_CURVE);
|
||||
s_currSrcRaw = md2->srcRaw;
|
||||
s_currScale = 0;
|
||||
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
|
||||
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr, isSourceAvailable, 1);
|
||||
break;
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
|
||||
@@ -120,6 +120,30 @@ void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr)
|
||||
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcdDrawFilledRect(x, y, 5*FW-1, FH-1);
|
||||
}
|
||||
|
||||
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
|
||||
int16_t min, int16_t max, LcdFlags attr, event_t event,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin)
|
||||
{
|
||||
if (title)
|
||||
lcdDrawTextAlignedLeft(y, title);
|
||||
SourceNumVal v;
|
||||
v.rawValue = value;
|
||||
if (v.isSource) {
|
||||
drawSource(x, y, v.value, attr);
|
||||
if (attr & (~RIGHT)) {
|
||||
value = checkIncDec(event, value, sourceMin,
|
||||
MIXSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_VALUE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isValueAvailable);
|
||||
}
|
||||
} else {
|
||||
lcdDrawNumber(x, y, v.value, attr);
|
||||
if (attr & (~RIGHT)) {
|
||||
value = checkIncDec(event, value, min, max,
|
||||
EE_MODEL|INCDEC_SOURCE_VALUE|NO_INCDEC_MARKS|(sourceMin == INPUTSRC_FIRST ? INCDEC_SOURCE_NOINPUTS : 0));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#if defined(GVARS)
|
||||
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags)
|
||||
{
|
||||
|
||||
@@ -111,6 +111,7 @@ set(GUI_SRC
|
||||
radio_tools.cpp
|
||||
radio_trainer.cpp
|
||||
radio_version.cpp
|
||||
source_numberedit.cpp
|
||||
)
|
||||
|
||||
macro(add_gui_src src)
|
||||
|
||||
@@ -243,7 +243,11 @@ void Curve::clearPoints()
|
||||
update();
|
||||
}
|
||||
|
||||
void Curve::update() { base.update(); }
|
||||
void Curve::update()
|
||||
{
|
||||
base.update();
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
void Curve::checkEvents()
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "curve_param.h"
|
||||
|
||||
#include "gvar_numberedit.h"
|
||||
#include "source_numberedit.h"
|
||||
#include "model_curves.h"
|
||||
#include "opentx.h"
|
||||
|
||||
@@ -37,21 +38,12 @@ void CurveParam::LongPressHandler(void* data)
|
||||
}
|
||||
}
|
||||
|
||||
void CurveParam::value_changed(lv_event_t* e)
|
||||
{
|
||||
auto obj = lv_event_get_target(e);
|
||||
auto param = (CurveParam*)lv_obj_get_user_data(obj);
|
||||
if (!param) return;
|
||||
|
||||
param->update();
|
||||
}
|
||||
|
||||
class CurveChoice : public Choice
|
||||
{
|
||||
public:
|
||||
CurveChoice(Window* parent, CurveRef* ref, std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView) :
|
||||
Choice(parent, rect_t{}, -MAX_CURVES, MAX_CURVES, GET_DEFAULT(ref->value), setRefValue),
|
||||
ref(ref), refreshView(refreshView)
|
||||
CurveChoice(Window* parent, std::function<int()> getRefValue, std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView) :
|
||||
Choice(parent, rect_t{}, -MAX_CURVES, MAX_CURVES, getRefValue, setRefValue),
|
||||
refreshView(std::move(refreshView))
|
||||
{
|
||||
setTextHandler([](int value) { return getCurveString(value); });
|
||||
}
|
||||
@@ -59,21 +51,21 @@ class CurveChoice : public Choice
|
||||
bool onLongPress() override
|
||||
{
|
||||
if (modelCurvesEnabled()) {
|
||||
if (ref->value) {
|
||||
ModelCurvesPage::pushEditCurve(abs(ref->value) - 1, refreshView);
|
||||
if (_getValue()) {
|
||||
ModelCurvesPage::pushEditCurve(abs(_getValue()) - 1, refreshView);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
CurveRef* ref;
|
||||
std::function<void(void)> refreshView;
|
||||
};
|
||||
|
||||
CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
|
||||
std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView) :
|
||||
Window(parent, rect), ref(ref)
|
||||
std::function<void(int32_t)> setRefValue, int16_t sourceMin,
|
||||
std::function<void(void)> refreshView) :
|
||||
Window(parent, rect), ref(ref), refreshView(std::move(refreshView))
|
||||
{
|
||||
padAll(PAD_TINY);
|
||||
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP);
|
||||
@@ -85,23 +77,42 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
|
||||
ref->type = newValue;
|
||||
ref->value = 0;
|
||||
SET_DIRTY();
|
||||
lv_event_send(lvobj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
update();
|
||||
});
|
||||
lv_obj_add_event_cb(lvobj, CurveParam::value_changed, LV_EVENT_VALUE_CHANGED,
|
||||
nullptr);
|
||||
|
||||
// CURVE_REF_DIFF
|
||||
// CURVE_REF_EXPO
|
||||
auto gv = new GVarNumberEdit(this, -100, 100, GET_DEFAULT(ref->value), setRefValue);
|
||||
auto gv = new SourceNumberEdit(this, -100, 100, GET_DEFAULT(ref->value), setRefValue, sourceMin);
|
||||
gv->setSuffix("%");
|
||||
value_edit = gv;
|
||||
|
||||
// CURVE_REF_FUNC
|
||||
func_choice = new Choice(this, rect_t{}, STR_VCURVEFUNC, 0, CURVE_BASE - 1,
|
||||
GET_DEFAULT(ref->value), setRefValue);
|
||||
[=]() {
|
||||
SourceNumVal v;
|
||||
v.rawValue = ref->value;
|
||||
return v.value;
|
||||
},
|
||||
[=](int32_t newValue) {
|
||||
SourceNumVal v;
|
||||
v.isSource = false;
|
||||
v.value = newValue;
|
||||
setRefValue(v.rawValue);
|
||||
});
|
||||
|
||||
// CURVE_REF_CUSTOM
|
||||
cust_choice = new CurveChoice(this, ref, setRefValue, refreshView);
|
||||
cust_choice = new CurveChoice(this,
|
||||
[=]() {
|
||||
SourceNumVal v;
|
||||
v.rawValue = ref->value;
|
||||
return v.value;
|
||||
},
|
||||
[=](int32_t newValue) {
|
||||
SourceNumVal v;
|
||||
v.isSource = false;
|
||||
v.value = newValue;
|
||||
setRefValue(v.rawValue);
|
||||
}, refreshView);
|
||||
|
||||
update();
|
||||
}
|
||||
@@ -117,14 +128,17 @@ void CurveParam::update()
|
||||
switch (ref->type) {
|
||||
case CURVE_REF_DIFF:
|
||||
case CURVE_REF_EXPO:
|
||||
value_edit->update();
|
||||
act_field = value_edit;
|
||||
break;
|
||||
|
||||
case CURVE_REF_FUNC:
|
||||
func_choice->update();
|
||||
act_field = func_choice;
|
||||
break;
|
||||
|
||||
case CURVE_REF_CUSTOM:
|
||||
cust_choice->update();
|
||||
act_field = cust_choice;
|
||||
break;
|
||||
|
||||
@@ -133,10 +147,11 @@ void CurveParam::update()
|
||||
}
|
||||
|
||||
act_field->show();
|
||||
if (refreshView)
|
||||
refreshView();
|
||||
|
||||
auto act_obj = act_field->getLvObj();
|
||||
if (has_focus) {
|
||||
lv_group_focus_obj(act_obj);
|
||||
}
|
||||
lv_event_send(act_obj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
}
|
||||
|
||||
@@ -24,24 +24,30 @@
|
||||
#include "window.h"
|
||||
|
||||
struct CurveRef;
|
||||
class Choice;
|
||||
class SourceNumberEdit;
|
||||
|
||||
class CurveParam : public Window
|
||||
{
|
||||
public:
|
||||
CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
|
||||
std::function<void(int32_t)> setRefValue,
|
||||
int16_t sourceMin,
|
||||
std::function<void(void)> refreshView = nullptr);
|
||||
|
||||
protected:
|
||||
// Curve
|
||||
CurveRef* ref;
|
||||
|
||||
// Controls
|
||||
Window* value_edit;
|
||||
Window* func_choice;
|
||||
Window* cust_choice;
|
||||
SourceNumberEdit* value_edit;
|
||||
Choice* func_choice;
|
||||
Choice* cust_choice;
|
||||
Window* act_field = nullptr;
|
||||
|
||||
void update();
|
||||
static void value_changed(lv_event_t* e);
|
||||
static void LongPressHandler(void* data);
|
||||
std::function<void(void)> refreshView;
|
||||
|
||||
public:
|
||||
CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
|
||||
std::function<void(int32_t)> setRefValue,
|
||||
std::function<void(void)> refreshView = nullptr);
|
||||
void update();
|
||||
|
||||
static void LongPressHandler(void* data);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "curve_param.h"
|
||||
#include "curveedit.h"
|
||||
#include "gvar_numberedit.h"
|
||||
#include "source_numberedit.h"
|
||||
#include "input_edit_adv.h"
|
||||
#include "input_source.h"
|
||||
#include "opentx.h"
|
||||
@@ -106,23 +107,23 @@ void InputEditWindow::buildBody(Window* form)
|
||||
line = form->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_WEIGHT);
|
||||
auto gvar =
|
||||
new GVarNumberEdit(line, -100, 100, GET_DEFAULT(input->weight),
|
||||
[=](int32_t newValue) {
|
||||
input->weight = newValue;
|
||||
preview->update();
|
||||
SET_DIRTY();
|
||||
});
|
||||
new SourceNumberEdit(line, -100, 100, GET_DEFAULT(input->weight),
|
||||
[=](int32_t newValue) {
|
||||
input->weight = newValue;
|
||||
preview->update();
|
||||
SET_DIRTY();
|
||||
}, INPUTSRC_FIRST);
|
||||
gvar->setSuffix("%");
|
||||
|
||||
// Offset
|
||||
line = form->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_OFFSET);
|
||||
gvar = new GVarNumberEdit(line, -100, 100,
|
||||
GET_DEFAULT(input->offset), [=](int32_t newValue) {
|
||||
input->offset = newValue;
|
||||
preview->update();
|
||||
SET_DIRTY();
|
||||
});
|
||||
gvar = new SourceNumberEdit(line, -100, 100,
|
||||
GET_DEFAULT(input->offset), [=](int32_t newValue) {
|
||||
input->offset = newValue;
|
||||
preview->update();
|
||||
SET_DIRTY();
|
||||
}, INPUTSRC_FIRST);
|
||||
gvar->setSuffix("%");
|
||||
|
||||
// Switch
|
||||
@@ -138,11 +139,13 @@ void InputEditWindow::buildBody(Window* form)
|
||||
new CurveParam(line, rect_t{}, &input->curve,
|
||||
[=](int32_t newValue) {
|
||||
input->curve.value = newValue;
|
||||
preview->update();
|
||||
if (preview)
|
||||
preview->update();
|
||||
SET_DIRTY();
|
||||
},
|
||||
}, INPUTSRC_FIRST,
|
||||
[=]() {
|
||||
preview->update();
|
||||
if (preview)
|
||||
preview->update();
|
||||
});
|
||||
lv_obj_set_style_grid_cell_x_align(param->getLvObj(), LV_GRID_ALIGN_STRETCH,
|
||||
0);
|
||||
@@ -164,3 +167,44 @@ void InputEditWindow::deleteLater(bool detach, bool trash)
|
||||
Page::deleteLater(detach, trash);
|
||||
}
|
||||
}
|
||||
|
||||
void InputEditWindow::checkEvents()
|
||||
{
|
||||
ExpoData* input = expoAddress(index);
|
||||
|
||||
bool updatePreview = false;
|
||||
getvalue_t val;
|
||||
SourceNumVal v;
|
||||
|
||||
v.rawValue = input->weight;
|
||||
if (v.isSource) {
|
||||
val = getValue(v.value);
|
||||
if (val != lastWeightVal) {
|
||||
lastWeightVal = val;
|
||||
updatePreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
v.rawValue = input->offset;
|
||||
if (v.isSource) {
|
||||
val = getValue(v.value);
|
||||
if (val != lastOffsetVal) {
|
||||
lastOffsetVal = val;
|
||||
updatePreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
v.rawValue = input->curve.value;
|
||||
if (v.isSource) {
|
||||
val = getValue(v.value);
|
||||
if (val != lastCurveVal) {
|
||||
lastCurveVal = val;
|
||||
updatePreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updatePreview)
|
||||
preview->update();
|
||||
|
||||
Page::checkEvents();
|
||||
}
|
||||
|
||||
@@ -38,9 +38,13 @@ class InputEditWindow : public Page
|
||||
protected:
|
||||
uint8_t input;
|
||||
uint8_t index;
|
||||
Curve* preview;
|
||||
Curve* preview = nullptr;
|
||||
getvalue_t lastWeightVal = 0;
|
||||
getvalue_t lastOffsetVal = 0;
|
||||
getvalue_t lastCurveVal = 0;
|
||||
|
||||
void buildBody(Window *window);
|
||||
|
||||
void checkEvents() override;
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
};
|
||||
|
||||
@@ -71,6 +71,7 @@ InputMixButtonBase::InputMixButtonBase(Window* parent, uint8_t index) :
|
||||
weight = lv_label_create(lvobj);
|
||||
lv_obj_set_pos(weight, WGT_X, WGT_Y);
|
||||
lv_obj_set_size(weight, WGT_W, WGT_H);
|
||||
etx_font(weight, FONT_XS_INDEX, LV_STATE_USER_1);
|
||||
|
||||
source = lv_label_create(lvobj);
|
||||
lv_obj_set_pos(source, SRC_X, SRC_Y);
|
||||
@@ -79,6 +80,7 @@ InputMixButtonBase::InputMixButtonBase(Window* parent, uint8_t index) :
|
||||
opts = lv_label_create(lvobj);
|
||||
lv_obj_set_pos(opts, OPT_X, OPT_Y);
|
||||
lv_obj_set_size(opts, OPT_W, OPT_H);
|
||||
etx_font(opts, FONT_XS_INDEX, LV_STATE_USER_1);
|
||||
}
|
||||
|
||||
InputMixButtonBase::~InputMixButtonBase()
|
||||
@@ -89,7 +91,12 @@ InputMixButtonBase::~InputMixButtonBase()
|
||||
void InputMixButtonBase::setWeight(gvar_t value, gvar_t min, gvar_t max)
|
||||
{
|
||||
char s[32];
|
||||
getValueOrGVarString(s, sizeof(s), value, min, max, 0, "%");
|
||||
getValueOrSrcVarString(s, sizeof(s), value, min, max, 0, "%");
|
||||
if (getTextWidth(s, 0, FONT(STD)) > WGT_W)
|
||||
lv_obj_add_state(weight, LV_STATE_USER_1);
|
||||
else
|
||||
lv_obj_clear_state(weight, LV_STATE_USER_1);
|
||||
|
||||
lv_label_set_text(weight, s);
|
||||
}
|
||||
|
||||
@@ -99,6 +106,16 @@ void InputMixButtonBase::setSource(mixsrc_t idx)
|
||||
lv_label_set_text(source, s);
|
||||
}
|
||||
|
||||
void InputMixButtonBase::setOpts(const char* s)
|
||||
{
|
||||
if (getTextWidth(s, 0, FONT(STD)) > OPT_W)
|
||||
lv_obj_add_state(opts, LV_STATE_USER_1);
|
||||
else
|
||||
lv_obj_clear_state(opts, LV_STATE_USER_1);
|
||||
|
||||
lv_label_set_text(opts, s);
|
||||
}
|
||||
|
||||
void InputMixButtonBase::setFlightModes(uint16_t modes)
|
||||
{
|
||||
if (!modelFMEnabled()) return;
|
||||
|
||||
@@ -54,6 +54,7 @@ class InputMixButtonBase : public ListLineButton
|
||||
|
||||
void setWeight(gvar_t value, gvar_t min, gvar_t max);
|
||||
void setSource(mixsrc_t idx);
|
||||
void setOpts(const char* s);
|
||||
void setFlightModes(uint16_t modes);
|
||||
|
||||
virtual void updatePos(coord_t x, coord_t y) = 0;
|
||||
@@ -66,7 +67,7 @@ class InputMixButtonBase : public ListLineButton
|
||||
static LAYOUT_VAL(BTN_W, 389, 229)
|
||||
static constexpr coord_t WGT_X = PAD_TINY;
|
||||
static constexpr coord_t WGT_Y = PAD_TINY;
|
||||
static LAYOUT_VAL(WGT_W, 43, 43)
|
||||
static LAYOUT_VAL(WGT_W, 50, 50)
|
||||
static LAYOUT_VAL(WGT_H, 21, 21)
|
||||
static constexpr coord_t SRC_X = WGT_X + WGT_W + PAD_TINY;
|
||||
static constexpr coord_t SRC_Y = WGT_Y;
|
||||
@@ -74,7 +75,7 @@ class InputMixButtonBase : public ListLineButton
|
||||
static constexpr coord_t SRC_H = WGT_H;
|
||||
static constexpr coord_t OPT_X = SRC_X + SRC_W + PAD_TINY;
|
||||
static constexpr coord_t OPT_Y = WGT_Y;
|
||||
static LAYOUT_VAL(OPT_W, 171, 106)
|
||||
static LAYOUT_VAL(OPT_W, 164, 99)
|
||||
static constexpr coord_t OPT_H = WGT_H;
|
||||
static LAYOUT_VAL(LN_X, 73, 73)
|
||||
static LAYOUT_VAL(FM_X, (OPT_X + OPT_W + PAD_TINY), 12)
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
#include "mixer_edit.h"
|
||||
|
||||
#include "channel_bar.h"
|
||||
#include "curve_param.h"
|
||||
#include "gvar_numberedit.h"
|
||||
#include "source_numberedit.h"
|
||||
#include "curve_param.h"
|
||||
#include "mixer_edit_adv.h"
|
||||
#include "mixes.h"
|
||||
#include "opentx.h"
|
||||
@@ -108,14 +109,14 @@ void MixEditWindow::buildBody(Window *form)
|
||||
// Weight
|
||||
line = form->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_WEIGHT);
|
||||
auto gvar = new GVarNumberEdit(line, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX,
|
||||
GET_SET_DEFAULT(mix->weight));
|
||||
gvar->setSuffix("%");
|
||||
auto svar = new SourceNumberEdit(line, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX,
|
||||
GET_SET_DEFAULT(mix->weight), 0);
|
||||
svar->setSuffix("%");
|
||||
|
||||
// Offset
|
||||
new StaticText(line, rect_t{}, STR_OFFSET);
|
||||
gvar = new GVarNumberEdit(line, MIX_OFFSET_MIN, MIX_OFFSET_MAX,
|
||||
GET_SET_DEFAULT(mix->offset));
|
||||
auto gvar = new SourceNumberEdit(line, MIX_OFFSET_MIN, MIX_OFFSET_MAX,
|
||||
GET_SET_DEFAULT(mix->offset), 0);
|
||||
gvar->setSuffix("%");
|
||||
|
||||
// Switch
|
||||
@@ -126,7 +127,7 @@ void MixEditWindow::buildBody(Window *form)
|
||||
|
||||
// Curve
|
||||
new StaticText(line, rect_t{}, STR_CURVE);
|
||||
new CurveParam(line, rect_t{}, &mix->curve, SET_DEFAULT(mix->curve.value));
|
||||
new CurveParam(line, rect_t{}, &mix->curve, SET_DEFAULT(mix->curve.value), 0);
|
||||
|
||||
line = form->newLine(grid);
|
||||
line->padAll(PAD_LARGE);
|
||||
|
||||
@@ -129,29 +129,29 @@ class InputLineButton : public InputMixButtonBase
|
||||
}
|
||||
}
|
||||
|
||||
if (line.swtch || line.curve.value) {
|
||||
if (line.swtch) {
|
||||
char* sw_pos = getSwitchPositionName(line.swtch);
|
||||
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
|
||||
if ((size_t)cnt >= maxlen)
|
||||
maxlen = 0;
|
||||
else {
|
||||
maxlen -= cnt;
|
||||
s += cnt;
|
||||
}
|
||||
}
|
||||
if (line.curve.value != 0) {
|
||||
getCurveRefString(s, maxlen, line.curve);
|
||||
int cnt = strnlen(s, maxlen);
|
||||
if ((size_t)cnt >= maxlen)
|
||||
maxlen = 0;
|
||||
else {
|
||||
maxlen -= cnt;
|
||||
s += cnt;
|
||||
}
|
||||
if (line.swtch) {
|
||||
char* sw_pos = getSwitchPositionName(line.swtch);
|
||||
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
|
||||
if ((size_t)cnt >= maxlen)
|
||||
maxlen = 0;
|
||||
else {
|
||||
maxlen -= cnt;
|
||||
s += cnt;
|
||||
}
|
||||
}
|
||||
lv_label_set_text_fmt(opts, "%.*s", (int)sizeof(tmp_str), tmp_str);
|
||||
|
||||
if (line.curve.value != 0) {
|
||||
getCurveRefString(s, maxlen, line.curve);
|
||||
int cnt = strnlen(s, maxlen);
|
||||
if ((size_t)cnt >= maxlen)
|
||||
maxlen = 0;
|
||||
else {
|
||||
maxlen -= cnt;
|
||||
s += cnt;
|
||||
}
|
||||
}
|
||||
|
||||
setOpts(s);
|
||||
|
||||
setFlightModes(line.flightModes);
|
||||
}
|
||||
|
||||
@@ -98,32 +98,25 @@ class MixLineButton : public InputMixButtonBase
|
||||
setSource(line.srcRaw);
|
||||
|
||||
char tmp_str[64];
|
||||
size_t maxlen = sizeof(tmp_str);
|
||||
|
||||
char *s = tmp_str;
|
||||
*s = '\0';
|
||||
|
||||
if (line.name[0]) {
|
||||
int cnt = lv_snprintf(s, maxlen, "%.*s ", (int)sizeof(line.name), line.name);
|
||||
if ((size_t)cnt >= maxlen) maxlen = 0;
|
||||
else { maxlen -= cnt; s += cnt; }
|
||||
s = strAppend(s, line.name, LEN_EXPOMIX_NAME);
|
||||
}
|
||||
|
||||
if (line.swtch || line.curve.value) {
|
||||
if (line.swtch) {
|
||||
char* sw_pos = getSwitchPositionName(line.swtch);
|
||||
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
|
||||
if ((size_t)cnt >= maxlen) maxlen = 0;
|
||||
else { maxlen -= cnt; s += cnt; }
|
||||
}
|
||||
if (line.curve.value != 0) {
|
||||
getCurveRefString(s, maxlen, line.curve);
|
||||
int cnt = strnlen(s, maxlen);
|
||||
if ((size_t)cnt >= maxlen) maxlen = 0;
|
||||
else { maxlen -= cnt; s += cnt; }
|
||||
}
|
||||
if (line.swtch) {
|
||||
if (tmp_str[0]) s = strAppend(s, " ");
|
||||
char* sw_pos = getSwitchPositionName(line.swtch);
|
||||
s = strAppend(s, sw_pos);
|
||||
}
|
||||
lv_label_set_text_fmt(opts, "%.*s", (int)sizeof(tmp_str), tmp_str);
|
||||
|
||||
if (line.curve.value != 0) {
|
||||
if (tmp_str[0]) s = strAppend(s, " ");
|
||||
getCurveRefString(s, sizeof(tmp_str) - (s - tmp_str), line.curve);
|
||||
}
|
||||
|
||||
setOpts(tmp_str);
|
||||
|
||||
mplex->refresh();
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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 "source_numberedit.h"
|
||||
|
||||
#include "opentx.h"
|
||||
#include "sourcechoice.h"
|
||||
|
||||
void SourceNumberEdit::value_changed(lv_event_t* e)
|
||||
{
|
||||
auto obj = lv_event_get_target(e);
|
||||
auto edit = (SourceNumberEdit*)lv_obj_get_user_data(obj);
|
||||
if (!edit) return;
|
||||
|
||||
edit->update();
|
||||
}
|
||||
|
||||
SourceNumberEdit::SourceNumberEdit(Window* parent,
|
||||
int32_t vmin, int32_t vmax,
|
||||
std::function<int32_t()> getValue,
|
||||
std::function<void(int32_t)> setValue,
|
||||
int16_t sourceMin,
|
||||
LcdFlags textFlags, int32_t voffset,
|
||||
int32_t vdefault) :
|
||||
Window(parent, {0, 0, NUM_EDIT_W + SRC_BTN_W + PAD_TINY * 3, EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY * 2}),
|
||||
vmin(vmin),
|
||||
vmax(vmax),
|
||||
getValue(getValue),
|
||||
setValue(setValue),
|
||||
textFlags(textFlags),
|
||||
voffset(voffset)
|
||||
{
|
||||
padAll(PAD_TINY);
|
||||
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
|
||||
lv_obj_set_size(lvobj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
|
||||
// Source field
|
||||
source_field = new SourceChoice(
|
||||
this, {0, 0, NUM_EDIT_W, 0}, sourceMin, INPUTSRC_LAST,
|
||||
[=]() {
|
||||
SourceNumVal v;
|
||||
v.rawValue = getValue();
|
||||
return v.value;
|
||||
},
|
||||
[=](int newValue) {
|
||||
SourceNumVal v = {(int16_t)newValue, true};
|
||||
setValue(v.rawValue);
|
||||
}, true);
|
||||
|
||||
num_field = new NumberEdit(
|
||||
this, {0, 0, NUM_EDIT_W, 0}, vmin, vmax,
|
||||
[=]() {
|
||||
SourceNumVal v;
|
||||
v.rawValue = getValue();
|
||||
return v.value;
|
||||
},
|
||||
[=](int newValue) {
|
||||
SourceNumVal v = {(int16_t)newValue, false};
|
||||
setValue(v.rawValue);
|
||||
},
|
||||
textFlags);
|
||||
num_field->setDefault(vdefault);
|
||||
|
||||
// The Source button
|
||||
m_srcBtn = new TextButton(this, {NUM_EDIT_W + PAD_TINY, 0, SRC_BTN_W, 0}, "SRC", [=]() {
|
||||
switchSourceMode();
|
||||
return isSource();
|
||||
});
|
||||
m_srcBtn->check(isSource());
|
||||
|
||||
lv_obj_add_event_cb(lvobj, SourceNumberEdit::value_changed,
|
||||
LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
|
||||
// update field type based on value
|
||||
update();
|
||||
}
|
||||
|
||||
bool SourceNumberEdit::isSource()
|
||||
{
|
||||
SourceNumVal v;
|
||||
v.rawValue = getValue();
|
||||
return v.isSource;
|
||||
}
|
||||
|
||||
void SourceNumberEdit::switchSourceMode()
|
||||
{
|
||||
SourceNumVal v;
|
||||
v.rawValue = getValue();
|
||||
v.isSource = !v.isSource;
|
||||
// TODO: convert value???
|
||||
v.value = 0;
|
||||
setValue(v.rawValue);
|
||||
|
||||
// update field type based on value
|
||||
update();
|
||||
}
|
||||
|
||||
void SourceNumberEdit::setSuffix(std::string value)
|
||||
{
|
||||
num_field->setSuffix(value);
|
||||
}
|
||||
|
||||
void SourceNumberEdit::update()
|
||||
{
|
||||
bool has_focus = act_field && act_field->hasFocus();
|
||||
|
||||
source_field->hide();
|
||||
num_field->hide();
|
||||
|
||||
if (isSource()) {
|
||||
// Source mode
|
||||
act_field = source_field;
|
||||
source_field->show();
|
||||
source_field->update();
|
||||
lv_event_send(source_field->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
} else {
|
||||
// number edit mode
|
||||
act_field = num_field;
|
||||
num_field->show();
|
||||
num_field->update();
|
||||
}
|
||||
|
||||
m_srcBtn->check(isSource());
|
||||
|
||||
if (has_focus) {
|
||||
lv_group_focus_obj(act_field->getLvObj());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 "choice.h"
|
||||
#include "form.h"
|
||||
#include "numberedit.h"
|
||||
|
||||
class TextButton;
|
||||
|
||||
class SourceNumberEdit : public Window
|
||||
{
|
||||
public:
|
||||
SourceNumberEdit(Window* parent, int32_t vmin, int32_t vmax,
|
||||
std::function<int32_t()> getValue,
|
||||
std::function<void(int32_t)> setValue,
|
||||
int16_t sourceMin,
|
||||
LcdFlags textFlags = 0, int32_t voffset = 0,
|
||||
int32_t vdefault = 0);
|
||||
|
||||
void switchSourceMode();
|
||||
void setSuffix(std::string value);
|
||||
|
||||
void setFastStep(int value) { num_field->setFastStep(value); }
|
||||
void setAccelFactor(int value) { num_field->setAccelFactor(value); }
|
||||
|
||||
void update();
|
||||
|
||||
static LAYOUT_VAL(NUM_EDIT_W, 84, 74)
|
||||
static LAYOUT_VAL(SRC_BTN_W, 38, 38)
|
||||
|
||||
protected:
|
||||
Choice* source_field = nullptr;
|
||||
NumberEdit* num_field = nullptr;
|
||||
FormField* act_field = nullptr;
|
||||
TextButton* m_srcBtn = nullptr;
|
||||
|
||||
int32_t vmin;
|
||||
int32_t vmax;
|
||||
std::function<int32_t()> getValue;
|
||||
std::function<void(int32_t)> setValue;
|
||||
LcdFlags textFlags;
|
||||
int32_t voffset;
|
||||
|
||||
bool isSource();
|
||||
|
||||
static void value_changed(lv_event_t* e);
|
||||
};
|
||||
@@ -292,14 +292,6 @@ void editName(coord_t x, coord_t y, char* name, uint8_t size, event_t event,
|
||||
}
|
||||
}
|
||||
|
||||
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event)
|
||||
{
|
||||
u_int8int16_t weight;
|
||||
MD_WEIGHT_TO_UNION(md, weight);
|
||||
weight.word = GVAR_MENU_ITEM(x, y, weight.word, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, attr, 0, event);
|
||||
MD_UNION_TO_WEIGHT(weight, md);
|
||||
}
|
||||
|
||||
void drawGVarName(coord_t x, coord_t y, int8_t idx, LcdFlags flags)
|
||||
{
|
||||
char s[8];
|
||||
@@ -405,12 +397,12 @@ void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags att)
|
||||
switch (curve.type) {
|
||||
case CURVE_REF_DIFF:
|
||||
lcdDrawText(x, y, "D", att);
|
||||
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
|
||||
editSrcVarFieldValue(lcdNextPos, y, nullptr, curve.value, -100, 100, LEFT|att, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case CURVE_REF_EXPO:
|
||||
lcdDrawText(x, y, "E", att);
|
||||
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
|
||||
editSrcVarFieldValue(lcdNextPos, y, nullptr, curve.value, -100, 100, LEFT|att, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case CURVE_REF_FUNC:
|
||||
@@ -543,3 +535,88 @@ void runFatalErrorScreen(const char * message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
|
||||
{
|
||||
uint16_t aidx = abs(idx);
|
||||
bool inverted = idx < 0;
|
||||
|
||||
if (aidx == MIXSRC_NONE) {
|
||||
lcdDrawText(x, y, STR_EMPTY, att);
|
||||
}
|
||||
else if (aidx <= MIXSRC_LAST_INPUT) {
|
||||
if (att & RIGHT) {
|
||||
if (g_model.inputNames[aidx-MIXSRC_FIRST_INPUT][0])
|
||||
lcdDrawSizedText(x, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
|
||||
else
|
||||
lcdDrawNumber(x, y, aidx, att|LEADING0, 2);
|
||||
x = lcdLastLeftPos - 5;
|
||||
if (inverted)
|
||||
lcdDrawChar(x-5, y, '-');
|
||||
lcdDrawChar(x, y+1, CHR_INPUT, RIGHT|TINSIZE);
|
||||
lcdDrawSolidFilledRect(x-1, y, 5, 7);
|
||||
} else {
|
||||
if (inverted) {
|
||||
lcdDrawChar(x-1, y, '-');
|
||||
x += 3;
|
||||
}
|
||||
lcdDrawChar(x+1, y+1, CHR_INPUT, TINSIZE);
|
||||
lcdDrawSolidFilledRect(x, y, 5, 7);
|
||||
if (g_model.inputNames[aidx-MIXSRC_FIRST_INPUT][0])
|
||||
lcdDrawSizedText(x+6, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
|
||||
else
|
||||
lcdDrawNumber(x+6, y, aidx, att|LEADING0, 2);
|
||||
}
|
||||
}
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (aidx <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div((uint16_t)(aidx-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
|
||||
if (att & RIGHT) {
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
|
||||
lcdDrawSizedText(x, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
|
||||
x = lcdLastLeftPos - 4;
|
||||
if (inverted)
|
||||
lcdDrawChar(x-5, y, '-');
|
||||
lcdDrawChar(x, y+1, '1'+qr.quot, TINSIZE);
|
||||
lcdDrawFilledRect(x-1, y, 5, 7, SOLID);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
lcdDrawChar(x, y, 'a' + qr.rem, att);
|
||||
drawStringWithIndex(lcdLastLeftPos, y, "LUA", qr.quot+1, att);
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (inverted)
|
||||
lcdDrawChar(lcdLastLeftPos, y, '-', att);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (inverted) {
|
||||
lcdDrawChar(x-1, y, '-');
|
||||
x += 3;
|
||||
}
|
||||
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
|
||||
lcdDrawChar(x+1, y+1, '1'+qr.quot, TINSIZE);
|
||||
lcdDrawFilledRect(x, y, 5, 7, SOLID);
|
||||
lcdDrawSizedText(x+5, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
|
||||
lcdDrawChar(lcdLastRightPos, y, 'a' + qr.rem, att);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
const char* s = getSourceString(idx);
|
||||
#if LCD_W < 212
|
||||
if (idx >= MIXSRC_FIRST_TELEM && idx <= MIXSRC_LAST_TELEM)
|
||||
s += strlen(STR_CHAR_TELEMETRY);
|
||||
#endif
|
||||
lcdDrawText(x, y, s, att);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _STDLCD_DRAW_FUNCTIONS_H_
|
||||
#define _STDLCD_DRAW_FUNCTIONS_H_
|
||||
#pragma once
|
||||
|
||||
#include "lcd.h"
|
||||
void lcdDrawMultiProtocolString(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t protocol, LcdFlags flags = 0);
|
||||
@@ -55,4 +54,4 @@ void drawFunction(FnFuncP fn, uint8_t offset = 0);
|
||||
void drawCursor(FnFuncP fn, uint8_t offset = 0);
|
||||
void drawCurve(coord_t offset = 0);
|
||||
|
||||
#endif // _STDLCD_DRAW_FUNCTIONS_H_
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
|
||||
|
||||
@@ -96,7 +96,8 @@ void menuModelCurvesAll(event_t event)
|
||||
}
|
||||
}
|
||||
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags)
|
||||
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags,
|
||||
IsValueAvailable isValueAvailable, int16_t sourceMin)
|
||||
{
|
||||
coord_t x1 = x;
|
||||
LcdFlags flags1 = flags;
|
||||
@@ -126,24 +127,36 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlag
|
||||
switch (curve.type) {
|
||||
case CURVE_REF_DIFF:
|
||||
case CURVE_REF_EXPO:
|
||||
curve.value = GVAR_MENU_ITEM(x, y, curve.value, -100, 100, LEFT | flags, 0, event);
|
||||
curve.value = editSrcVarFieldValue(x, y, nullptr, curve.value, -100, 100, flags, event, isValueAvailable, sourceMin);
|
||||
break;
|
||||
case CURVE_REF_FUNC:
|
||||
lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, curve.value, flags);
|
||||
if (active && menuHorizontalPosition==1) CHECK_INCDEC_MODELVAR_ZERO(event, curve.value, CURVE_BASE-1);
|
||||
{
|
||||
SourceNumVal v;
|
||||
v.rawValue = curve.value;
|
||||
lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, v.value, flags);
|
||||
if (active && menuHorizontalPosition==1) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, v.value, CURVE_BASE-1);
|
||||
curve.value = v.rawValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CURVE_REF_CUSTOM:
|
||||
drawCurveName(x, y, curve.value, flags);
|
||||
{
|
||||
SourceNumVal v;
|
||||
v.rawValue = curve.value;
|
||||
drawCurveName(x, y, v.value, flags);
|
||||
if (active && menuHorizontalPosition == 1) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && curve.value != 0) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && v.value != 0) {
|
||||
s_currIdxSubMenu = abs(curve.value) - 1;
|
||||
pushMenu(menuModelCurveOne);
|
||||
}
|
||||
else {
|
||||
CHECK_INCDEC_MODELVAR(event, curve.value, -MAX_CURVES, MAX_CURVES);
|
||||
CHECK_INCDEC_MODELVAR(event, v.value, -MAX_CURVES, MAX_CURVES);
|
||||
curve.value = v.rawValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -391,7 +391,7 @@ void menuModelExposAll(event_t event)
|
||||
coord_t y = MENU_HEADER_HEIGHT+1+(cur-menuVerticalOffset)*FH;
|
||||
if (i<MAX_EXPOS && (ed=expoAddress(i))->chn+1 == ch && EXPO_VALID(ed)) {
|
||||
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
|
||||
drawSource(0, y, ch, 0);
|
||||
drawSource(0, y, ch, ((s_copyMode || sub != cur) ? 0 : INVERS));
|
||||
}
|
||||
uint8_t mixCnt = 0;
|
||||
do {
|
||||
@@ -410,10 +410,10 @@ void menuModelExposAll(event_t event)
|
||||
s_currIdx = i;
|
||||
}
|
||||
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
|
||||
LcdFlags attr = ((s_copyMode || sub != cur) ? 0 : INVERS);
|
||||
|
||||
GVAR_MENU_ITEM(EXPO_LINE_WEIGHT_POS, y, ed->weight, -100, 100, RIGHT | attr | (isExpoActive(i) ? BOLD : 0), 0, 0);
|
||||
displayExpoLine(y, ed, attr);
|
||||
editSrcVarFieldValue(EXPO_LINE_WEIGHT_POS, y, nullptr, ed->weight,
|
||||
-100, 100, RIGHT | (isExpoActive(i) ? BOLD : 0),
|
||||
0, 0, 0);
|
||||
displayExpoLine(y, ed, 0);
|
||||
|
||||
if (s_copyMode) {
|
||||
if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
|
||||
@@ -422,11 +422,14 @@ void menuModelExposAll(event_t event)
|
||||
}
|
||||
if (cur == sub) {
|
||||
/* invert the raw when it's the current one */
|
||||
lcdDrawSolidFilledRect(EXPO_LINE_SELECT_POS+1, y, LCD_W-EXPO_LINE_SELECT_POS-2, 7);
|
||||
lcdDrawSolidFilledRect(0, y, LCD_W, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
cur++; y+=FH; mixCnt++; i++; ed++;
|
||||
if (sub == cur && ed->chn+1 == ch) {
|
||||
lcdDrawText(INDENT_WIDTH, y, "->", ((s_copyMode || sub != cur) ? 0 : INVERS));
|
||||
}
|
||||
} while (i<MAX_EXPOS && ed->chn+1 == ch && EXPO_VALID(ed));
|
||||
if (s_copyMode == MOVE_MODE && cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
|
||||
lcdDrawRect(EXPO_LINE_SELECT_POS, y-1, LCD_W-EXPO_LINE_SELECT_POS, 9, DOTTED);
|
||||
|
||||
@@ -307,7 +307,7 @@ void menuModelMixAll(event_t event)
|
||||
MixData * md = mixAddress(i);
|
||||
if (i < getMixCount() && (md->destCh + 1 == ch)) {
|
||||
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
|
||||
putsChn(0, y, ch, 0); // show CHx
|
||||
putsChn(0, y, ch, ((s_copyMode || sub != cur) ? 0 : INVERS)); // show CHx
|
||||
}
|
||||
uint8_t mixCnt = 0;
|
||||
do {
|
||||
@@ -326,17 +326,17 @@ void menuModelMixAll(event_t event)
|
||||
s_currIdx = i;
|
||||
}
|
||||
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
|
||||
LcdFlags attr = ((s_copyMode || sub != cur) ? 0 : INVERS);
|
||||
|
||||
if (mixCnt > 0) lcdDrawTextAtIndex(FW, y, STR_VMLTPX2, md->mltpx, 0);
|
||||
if (mixCnt > 0) lcdDrawTextAtIndex(FW, y, STR_VMLTPX2, md->mltpx, ((s_copyMode || sub != cur) ? 0 : INVERS));
|
||||
|
||||
drawSource(MIX_LINE_SRC_POS, y, md->srcRaw, 0);
|
||||
|
||||
if (mixCnt == 0 && md->mltpx == 1) {
|
||||
lcdDrawText(MIX_LINE_WEIGHT_POS, y, "MULT!", RIGHT | attr | (isMixActive(i) ? BOLD : 0));
|
||||
lcdDrawText(MIX_LINE_WEIGHT_POS, y, "MULT!", RIGHT | ((isMixActive(i) ? BOLD : 0)));
|
||||
}
|
||||
else {
|
||||
gvarWeightItem(MIX_LINE_WEIGHT_POS, y, md, RIGHT | attr | (isMixActive(i) ? BOLD : 0), 0);
|
||||
editSrcVarFieldValue(MIX_LINE_WEIGHT_POS, y, nullptr, md->weight,
|
||||
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, RIGHT | ((isMixActive(i) ? BOLD : 0)),
|
||||
0, 0, 0);
|
||||
}
|
||||
|
||||
#if LCD_W >= 212
|
||||
@@ -352,7 +352,7 @@ void menuModelMixAll(event_t event)
|
||||
}
|
||||
if (cur == sub) {
|
||||
/* invert the raw when it's the current one */
|
||||
lcdDrawSolidFilledRect(23, y, LCD_W-24, 7);
|
||||
lcdDrawSolidFilledRect(0, y, LCD_W, 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,8 @@ void onSourceLongEnterPress(const char * result)
|
||||
}
|
||||
} else if (result == STR_MENU_INVERT) {
|
||||
checkIncDecSelection = MIXSRC_INVERT;
|
||||
} else if (result == STR_CONSTANT) {
|
||||
checkIncDecSelection = MIXSRC_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ extern int8_t s_editMode; // global editmode
|
||||
#define INCDEC_REP10 0x40
|
||||
#define NO_DBLKEYS 0x80
|
||||
#define INCDEC_SOURCE_INVERT 0x100
|
||||
#define INCDEC_SOURCE_VALUE 0x200 // Field can be source or value
|
||||
#define INCDEC_SOURCE_NOINPUTS 0x400 // Do not allow Inputs in source selection
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
unsigned int i_flags = 0, IsValueAvailable isValueAvailable = nullptr,
|
||||
|
||||
@@ -51,7 +51,26 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
{
|
||||
int newval = val;
|
||||
|
||||
bool isSource = false;
|
||||
bool origIsSource = false;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.rawValue = val;
|
||||
// Save isSource flag;
|
||||
origIsSource = isSource = v.isSource;
|
||||
// Remove isSource flag;
|
||||
val = v.value;
|
||||
newval = v.value;
|
||||
}
|
||||
|
||||
if (s_editMode > 0) {
|
||||
bool invert = false;
|
||||
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
|
||||
invert = true;
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
|
||||
if (event == EVT_KEY_FIRST(KEY_UP) || event == EVT_KEY_REPT(KEY_UP) ||
|
||||
event == EVT_KEY_FIRST(KEY_RIGHT) || event == EVT_KEY_REPT(KEY_RIGHT)) {
|
||||
do {
|
||||
@@ -94,10 +113,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
|
||||
int source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (isSource) {
|
||||
// Only use moved source if already a source value
|
||||
newval = source;
|
||||
}
|
||||
} else {
|
||||
newval = source;
|
||||
}
|
||||
}
|
||||
#if defined(AUTOSWITCH)
|
||||
else {
|
||||
@@ -109,6 +135,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (invert) {
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
}
|
||||
|
||||
if (i_min == 0 && i_max == 1 &&
|
||||
@@ -117,6 +148,75 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
checkIncDecSelection = MIXSRC_NONE;
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
|
||||
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
|
||||
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
|
||||
}
|
||||
}
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (i_min <= MIXSRC_FIRST_LUA && i_max >= MIXSRC_FIRST_LUA) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable) != MIXSRC_NONE) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_LUA);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_STICK && i_max >= MIXSRC_FIRST_STICK) POPUP_MENU_ADD_ITEM(STR_MENU_STICKS);
|
||||
if (i_min <= MIXSRC_FIRST_POT && i_max >= MIXSRC_FIRST_POT) POPUP_MENU_ADD_ITEM(STR_MENU_POTS);
|
||||
if (i_min <= MIXSRC_MIN && i_max >= MIXSRC_MIN) POPUP_MENU_ADD_ITEM(STR_MENU_MIN);
|
||||
if (i_min <= MIXSRC_MAX && i_max >= MIXSRC_MAX) POPUP_MENU_ADD_ITEM(STR_MENU_MAX);
|
||||
#if defined(HELI)
|
||||
if (modelHeliEnabled())
|
||||
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI && isValueAvailable && isValueAvailable(MIXSRC_FIRST_HELI))
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
|
||||
#endif
|
||||
if (i_min <= MIXSRC_FIRST_TRIM && i_max >= MIXSRC_FIRST_TRIM) POPUP_MENU_ADD_ITEM(STR_MENU_TRIMS);
|
||||
if (i_min <= MIXSRC_FIRST_SWITCH && i_max >= MIXSRC_FIRST_SWITCH) POPUP_MENU_ADD_ITEM(STR_MENU_SWITCHES);
|
||||
if (i_min <= MIXSRC_FIRST_TRAINER && i_max >= MIXSRC_FIRST_TRAINER) POPUP_MENU_ADD_ITEM(STR_MENU_TRAINER);
|
||||
if (i_min <= MIXSRC_FIRST_CH && i_max >= MIXSRC_FIRST_CH) POPUP_MENU_ADD_ITEM(STR_MENU_CHANNELS);
|
||||
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable && isValueAvailable(MIXSRC_FIRST_GVAR)) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_GVARS);
|
||||
}
|
||||
|
||||
if (modelTelemetryEnabled() && i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
|
||||
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->isAvailable()) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_TELEMETRY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i_flags & INCDEC_SOURCE_INVERT) POPUP_MENU_ADD_ITEM(STR_MENU_INVERT);
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (checkIncDecSelection == MIXSRC_VALUE) {
|
||||
newval = 0;
|
||||
isSource = false;
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_INVERT)
|
||||
isSource = true;
|
||||
}
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
}
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
|
||||
(newval != i_min) && stops.contains(newval)) {
|
||||
@@ -136,6 +236,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.isSource = isSource;
|
||||
v.value = newval;
|
||||
newval = v.rawValue;
|
||||
}
|
||||
|
||||
return newval;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
#endif
|
||||
|
||||
bool isSource = false;
|
||||
bool origIsSource = false;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.rawValue = val;
|
||||
// Save isSource flag;
|
||||
origIsSource = isSource = v.isSource;
|
||||
// Remove isSource flag;
|
||||
val = v.value;
|
||||
newval = v.value;
|
||||
}
|
||||
|
||||
if (s_editMode > 0) {
|
||||
bool invert = false;
|
||||
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
|
||||
@@ -111,10 +123,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
|
||||
int source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (isSource) {
|
||||
// Only use moved source if already a source value
|
||||
newval = source;
|
||||
}
|
||||
} else {
|
||||
newval = source;
|
||||
}
|
||||
}
|
||||
#if defined(AUTOSWITCH)
|
||||
else {
|
||||
@@ -139,18 +158,24 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
checkIncDecSelection = MIXSRC_NONE;
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
|
||||
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
|
||||
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
|
||||
}
|
||||
}
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
if (i_min <= MIXSRC_FIRST_LUA && i_max >= MIXSRC_FIRST_LUA) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable) != MIXSRC_NONE) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable) != MIXSRC_NONE &&
|
||||
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_LUA);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +210,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (checkIncDecSelection == MIXSRC_VALUE) {
|
||||
newval = 0;
|
||||
isSource = false;
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_INVERT)
|
||||
isSource = true;
|
||||
}
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
}
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
@@ -216,7 +252,7 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
if (newval != val || isSource != origIsSource) {
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
@@ -224,6 +260,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.isSource = isSource;
|
||||
v.value = newval;
|
||||
newval = v.rawValue;
|
||||
}
|
||||
|
||||
return newval;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
#endif
|
||||
|
||||
bool isSource = false;
|
||||
bool origIsSource = false;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.rawValue = val;
|
||||
// Save isSource flag;
|
||||
origIsSource = isSource = v.isSource;
|
||||
// Remove isSource flag;
|
||||
val = v.value;
|
||||
newval = v.value;
|
||||
}
|
||||
|
||||
if (s_editMode > 0) {
|
||||
bool invert = false;
|
||||
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
|
||||
@@ -111,10 +123,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
|
||||
int source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (isSource) {
|
||||
// Only use moved source if already a source value
|
||||
newval = source;
|
||||
}
|
||||
} else {
|
||||
newval = source;
|
||||
}
|
||||
}
|
||||
#if defined(AUTOSWITCH)
|
||||
else {
|
||||
@@ -139,12 +158,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
checkIncDecSelection = MIXSRC_NONE;
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
|
||||
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
|
||||
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +209,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (checkIncDecSelection == MIXSRC_VALUE) {
|
||||
newval = 0;
|
||||
isSource = false;
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_INVERT)
|
||||
isSource = true;
|
||||
}
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
}
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
@@ -258,6 +293,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.isSource = isSource;
|
||||
v.value = newval;
|
||||
newval = v.rawValue;
|
||||
}
|
||||
|
||||
return newval;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
{
|
||||
int newval = val;
|
||||
|
||||
bool isSource = false;
|
||||
bool origIsSource = false;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.rawValue = val;
|
||||
// Save isSource flag;
|
||||
origIsSource = isSource = v.isSource;
|
||||
// Remove isSource flag;
|
||||
val = v.value;
|
||||
newval = v.value;
|
||||
}
|
||||
|
||||
if (s_editMode > 0) {
|
||||
bool invert = false;
|
||||
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
|
||||
@@ -101,10 +113,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
|
||||
#if defined(AUTOSOURCE)
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
|
||||
int source = GET_MOVED_SOURCE(i_min, i_max);
|
||||
if (source) {
|
||||
newval = source;
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (isSource) {
|
||||
// Only use moved source if already a source value
|
||||
newval = source;
|
||||
}
|
||||
} else {
|
||||
newval = source;
|
||||
}
|
||||
}
|
||||
#if defined(AUTOSWITCH)
|
||||
else {
|
||||
@@ -148,12 +167,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER) && !keysGetState(KEY_SHIFT)) {
|
||||
checkIncDecSelection = MIXSRC_NONE;
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
|
||||
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
|
||||
}
|
||||
|
||||
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
|
||||
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
|
||||
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
|
||||
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
|
||||
}
|
||||
}
|
||||
@@ -194,7 +218,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
if (checkIncDecSelection == MIXSRC_VALUE) {
|
||||
newval = 0;
|
||||
isSource = false;
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_INVERT)
|
||||
isSource = true;
|
||||
}
|
||||
} else {
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
}
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
@@ -225,6 +260,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE_VALUE) {
|
||||
SourceNumVal v;
|
||||
v.isSource = isSource;
|
||||
v.value = newval;
|
||||
newval = v.rawValue;
|
||||
}
|
||||
|
||||
return newval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user