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