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:
philmoz
2024-07-26 20:51:21 +10:00
committed by GitHub
co-authored by philmoz 3djc elecpower
parent 326c58a7fd
commit 4b917b762c
87 changed files with 2751 additions and 1671 deletions
+87 -10
View File
@@ -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);
}
}
+2 -3
View File
@@ -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);
+20 -7
View File
@@ -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;
}
}
}
+9 -6
View File
@@ -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);
+7 -7
View File
@@ -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);
}
}
}