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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user