feat: add inverted sources (#4722)
Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
@@ -535,6 +535,8 @@ enum MixSources {
|
||||
|
||||
MIXSRC_FIRST_TELEM SKIP,
|
||||
MIXSRC_LAST_TELEM SKIP = MIXSRC_FIRST_TELEM + 3 * MAX_TELEMETRY_SENSORS - 1,
|
||||
|
||||
MIXSRC_INVERT SKIP,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ PACK(struct CurveRef {
|
||||
PACK(struct MixData {
|
||||
int16_t weight:11 CUST(in_read_weight,in_write_weight); // GV1=-1024, -GV1=1023
|
||||
uint16_t destCh:5;
|
||||
uint16_t srcRaw:10 CUST(r_mixSrcRaw,w_mixSrcRaw); // srcRaw=0 means not used
|
||||
int16_t srcRaw:10 CUST(r_mixSrcRawEx,w_mixSrcRawEx); // srcRaw=0 means not used
|
||||
uint16_t carryTrim:1;
|
||||
uint16_t mixWarn:2; // mixer warning
|
||||
uint16_t mltpx:2 ENUM(MixerMultiplex);
|
||||
@@ -99,7 +99,7 @@ PACK(struct ExpoData {
|
||||
uint16_t scale:14;
|
||||
CUST_ATTR(carryTrim, r_carryTrim, nullptr); //pre 2.9
|
||||
int16_t trimSource:6;
|
||||
uint16_t srcRaw:10 ENUM(MixSources) CUST(r_mixSrcRaw,w_mixSrcRaw);
|
||||
int16_t srcRaw:10 ENUM(MixSources) CUST(r_mixSrcRawEx,w_mixSrcRawEx);
|
||||
uint32_t chn:5;
|
||||
int32_t swtch:10 CUST(r_swtchSrc,w_swtchSrc);
|
||||
uint32_t flightModes:9 CUST(r_flightModes, w_flightModes);
|
||||
|
||||
@@ -125,7 +125,7 @@ extern int8_t s_copySrcRow;
|
||||
extern int8_t s_copyTgtOfs;
|
||||
extern uint8_t s_currIdx;
|
||||
extern uint8_t s_currIdxSubMenu;
|
||||
extern uint16_t s_currSrcRaw;
|
||||
extern mixsrc_t s_currSrcRaw;
|
||||
extern uint16_t s_currScale;
|
||||
extern uint8_t s_copySrcIdx;
|
||||
extern uint8_t s_copySrcCh;
|
||||
|
||||
@@ -657,23 +657,34 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
|
||||
putsVolts(x, y, g_vbat100mV, att);
|
||||
}
|
||||
|
||||
void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
|
||||
{
|
||||
if (idx == MIXSRC_NONE) {
|
||||
uint16_t aidx = abs(idx);
|
||||
bool inverted = idx < 0;
|
||||
|
||||
if (aidx == MIXSRC_NONE) {
|
||||
lcdDrawText(x, y, STR_EMPTY, att);
|
||||
}
|
||||
else if (idx <= MIXSRC_LAST_INPUT) {
|
||||
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[idx-MIXSRC_FIRST_INPUT][0])
|
||||
lcdDrawSizedText(x+8, y, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
|
||||
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, idx, att|LEADING0|LEFT, 2);
|
||||
lcdDrawNumber(x+8, y, aidx, att|LEADING0|LEFT, 2);
|
||||
}
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (idx <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
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);
|
||||
|
||||
@@ -70,5 +70,5 @@ void editSingleName(coord_t x, coord_t y, const char* label, char* name,
|
||||
|
||||
uint8_t s_currIdx;
|
||||
uint8_t s_currIdxSubMenu;
|
||||
uint16_t s_currSrcRaw;
|
||||
mixsrc_t s_currSrcRaw;
|
||||
uint16_t s_currScale;
|
||||
|
||||
@@ -79,7 +79,7 @@ void menuModelExpoOne(event_t event)
|
||||
uint8_t old_editMode = s_editMode;
|
||||
|
||||
SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX,
|
||||
{0, 0, 0, ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, LABEL(Curve), 1,
|
||||
{0, 0, 0, abs(ed->srcRaw) >= MIXSRC_FIRST_TELEM ? (uint8_t)0 : (uint8_t)HIDDEN_ROW, 0, 0, LABEL(Curve), 1,
|
||||
CASE_FLIGHT_MODES(FM_ROW(LABEL(Flight Mode))) CASE_FLIGHT_MODES(FM_ROW((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE)) 0 /*, ...*/});
|
||||
|
||||
int8_t sub = menuVerticalPosition;
|
||||
@@ -112,14 +112,14 @@ void menuModelExpoOne(event_t event)
|
||||
lcdDrawTextAlignedLeft(y, STR_SOURCE);
|
||||
drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, RIGHT|STREXPANDED|attr);
|
||||
if (attr)
|
||||
ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailableInInputs);
|
||||
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, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, convertTelemValue(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), RIGHT | attr);
|
||||
if (attr)
|
||||
ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
|
||||
ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
|
||||
break;
|
||||
|
||||
case EXPO_FIELD_WEIGHT:
|
||||
@@ -161,13 +161,13 @@ void menuModelExpoOne(event_t event)
|
||||
case EXPO_FIELD_TRIM:
|
||||
lcdDrawTextAlignedLeft(y, STR_TRIM);
|
||||
{
|
||||
const char* trim_str = getTrimSourceLabel(ed->srcRaw, ed->trimSource);
|
||||
const char* trim_str = getTrimSourceLabel(abs(ed->srcRaw), ed->trimSource);
|
||||
LcdFlags flags = RIGHT | (menuHorizontalPosition==0 ? attr : 0);
|
||||
lcdDrawText(EXPO_ONE_2ND_COLUMN, y, trim_str, flags);
|
||||
|
||||
if (attr) {
|
||||
int8_t min = TRIM_ON;
|
||||
if (ed->srcRaw >= MIXSRC_FIRST_STICK && ed->srcRaw <= MIXSRC_LAST_STICK) {
|
||||
if (abs(ed->srcRaw) >= MIXSRC_FIRST_STICK && abs(ed->srcRaw) <= MIXSRC_LAST_STICK) {
|
||||
min = -TRIM_OFF;
|
||||
}
|
||||
ed->trimSource = -checkIncDecModel(event, -ed->trimSource, min, keysGetMaxTrims());
|
||||
|
||||
@@ -116,7 +116,7 @@ void menuModelLogicalSwitchOne(event_t event)
|
||||
else {
|
||||
v1_val = cs->v1;
|
||||
drawSource(CSWONE_2ND_COLUMN, y, v1_val, attr);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
if (attr) {
|
||||
@@ -152,7 +152,7 @@ void menuModelLogicalSwitchOne(event_t event)
|
||||
}
|
||||
else if (cstate == LS_FAMILY_COMP) {
|
||||
drawSource(CSWONE_2ND_COLUMN, y, cs->v2, attr);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
else {
|
||||
@@ -175,7 +175,7 @@ void menuModelLogicalSwitchOne(event_t event)
|
||||
getMixSrcRange(v1_val, v2_min, v2_max, &lf);
|
||||
if ((cs->func == LS_FUNC_APOS) || (cs->func == LS_FUNC_ANEG) || (cs->func == LS_FUNC_ADIFFEGREATER))
|
||||
v2_min = 0;
|
||||
drawSourceCustomValue(CSWONE_2ND_COLUMN, y, v1_val, (v1_val <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2), lf);
|
||||
drawSourceCustomValue(CSWONE_2ND_COLUMN, y, v1_val, (abs(v1_val) <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2), lf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ void menuModelLogicalSwitches(event_t event)
|
||||
lcdDrawNumber(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1);
|
||||
}
|
||||
else {
|
||||
source_t v1 = cs->v1;
|
||||
mixsrc_t v1 = cs->v1;
|
||||
drawSource(CSW_2ND_COLUMN, y, v1, 0);
|
||||
if (v1 >= MIXSRC_FIRST_TELEM) {
|
||||
drawSourceCustomValue(CSW_3RD_COLUMN, y, v1, convertLswTelemValue(cs), LEFT);
|
||||
|
||||
@@ -138,7 +138,8 @@ void menuModelMixOne(event_t event)
|
||||
case MIX_FIELD_SOURCE:
|
||||
lcdDrawTextAlignedLeft(y, STR_SOURCE);
|
||||
drawSource(MIXES_2ND_COLUMN, y, md2->srcRaw, STREXPANDED|attr);
|
||||
if (attr) CHECK_INCDEC_MODELSOURCE(event, md2->srcRaw, 1, MIXSRC_LAST);
|
||||
if (attr)
|
||||
md2->srcRaw = checkIncDec(event, md2->srcRaw, 1, MIXSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailable);
|
||||
break;
|
||||
|
||||
case MIX_FIELD_WEIGHT:
|
||||
|
||||
@@ -351,7 +351,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_TELEM;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN - (val_displayed == 0 ? 0 : 2 * FW), y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable);
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
}
|
||||
@@ -368,7 +368,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#define WARNING_LINE_X 12
|
||||
#define WARNING_LINE_Y MESSAGEBOX_Y + 2
|
||||
|
||||
#define POPUP_MENU_MAX_LINES 12
|
||||
#define POPUP_MENU_MAX_LINES 13
|
||||
#define MENU_MAX_DISPLAY_LINES 6
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ extern int8_t s_copySrcRow;
|
||||
extern int8_t s_copyTgtOfs;
|
||||
extern uint8_t s_currIdx;
|
||||
extern uint8_t s_currIdxSubMenu;
|
||||
extern uint16_t s_currSrcRaw;
|
||||
extern mixsrc_t s_currSrcRaw;
|
||||
extern uint16_t s_currScale;
|
||||
extern uint8_t s_copySrcIdx;
|
||||
extern uint8_t s_copySrcCh;
|
||||
|
||||
@@ -627,23 +627,34 @@ 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, uint32_t idx, LcdFlags att)
|
||||
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
|
||||
{
|
||||
if (idx == MIXSRC_NONE) {
|
||||
uint16_t aidx = abs(idx);
|
||||
bool inverted = idx < 0;
|
||||
|
||||
if (aidx == MIXSRC_NONE) {
|
||||
lcdDrawText(x, y, STR_EMPTY, att);
|
||||
}
|
||||
else if (idx <= MIXSRC_LAST_INPUT) {
|
||||
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[idx-MIXSRC_FIRST_INPUT]))
|
||||
lcdDrawSizedText(x+8, y, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
|
||||
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, idx, att|LEADING0|LEFT, 2);
|
||||
lcdDrawNumber(x+8, y, aidx, att|LEADING0|LEFT, 2);
|
||||
}
|
||||
|
||||
else if (idx <= MIXSRC_LAST_LUA) {
|
||||
div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
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);
|
||||
|
||||
@@ -112,7 +112,7 @@ 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, uint32_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);
|
||||
|
||||
|
||||
@@ -74,5 +74,5 @@ void editSingleName(coord_t x, coord_t y, const char * label, char *name, uint8_
|
||||
|
||||
uint8_t s_currIdx;
|
||||
uint8_t s_currIdxSubMenu;
|
||||
uint16_t s_currSrcRaw;
|
||||
mixsrc_t s_currSrcRaw;
|
||||
uint16_t s_currScale;
|
||||
|
||||
@@ -103,10 +103,10 @@ void menuModelExpoOne(event_t event)
|
||||
lcdDrawTextAlignedLeft(y, STR_SOURCE);
|
||||
drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|attr);
|
||||
if (attr && menuHorizontalPosition==0)
|
||||
ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailableInInputs);
|
||||
if (ed->srcRaw >= MIXSRC_FIRST_TELEM) {
|
||||
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN+30, y, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, getValue(ed->srcRaw), LEFT|(menuHorizontalPosition==1?attr:0));
|
||||
if (attr && menuHorizontalPosition == 1) ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
|
||||
ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailableInInputs);
|
||||
if (abs(ed->srcRaw) >= MIXSRC_FIRST_TELEM) {
|
||||
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN+30, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, getValue(ed->srcRaw), LEFT|(menuHorizontalPosition==1?attr:0));
|
||||
if (attr && menuHorizontalPosition == 1) ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
|
||||
}
|
||||
else if (attr) {
|
||||
menuHorizontalPosition = 0;
|
||||
@@ -115,8 +115,8 @@ void menuModelExpoOne(event_t event)
|
||||
|
||||
case EXPO_FIELD_SCALE:
|
||||
lcdDrawTextAlignedLeft(y, STR_SCALE);
|
||||
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale), LEFT|attr);
|
||||
if (attr) ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
|
||||
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, convertTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1, ed->scale), LEFT|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:
|
||||
@@ -152,13 +152,13 @@ void menuModelExpoOne(event_t event)
|
||||
case EXPO_FIELD_TRIM:
|
||||
lcdDrawTextAlignedLeft(y, STR_TRIM);
|
||||
{
|
||||
const char* trim_str = getTrimSourceLabel(ed->srcRaw, ed->trimSource);
|
||||
const char* trim_str = getTrimSourceLabel(abs(ed->srcRaw), ed->trimSource);
|
||||
LcdFlags flags = RIGHT | (menuHorizontalPosition==0 ? attr : 0);
|
||||
lcdDrawText(EXPO_ONE_2ND_COLUMN, y, trim_str, flags);
|
||||
|
||||
if (attr) {
|
||||
int8_t min = TRIM_ON;
|
||||
if (ed->srcRaw >= MIXSRC_FIRST_STICK && ed->srcRaw <= MIXSRC_LAST_STICK) {
|
||||
if (abs(ed->srcRaw) >= MIXSRC_FIRST_STICK && abs(ed->srcRaw) <= MIXSRC_LAST_STICK) {
|
||||
min = -TRIM_OFF;
|
||||
}
|
||||
ed->trimSource = -checkIncDecModel(event, -ed->trimSource, min, keysGetMaxTrims());
|
||||
|
||||
@@ -117,7 +117,7 @@ void menuModelLogicalSwitches(event_t event)
|
||||
|
||||
// CSW params
|
||||
unsigned int cstate = lswFamily(cs->func);
|
||||
int v1_val = cs->v1;
|
||||
mixsrc_t v1_val = cs->v1;
|
||||
int16_t v1_min = 0, v1_max = MIXSRC_LAST_TELEM;
|
||||
int16_t v2_min = 0, v2_max = MIXSRC_LAST_TELEM;
|
||||
int16_t v3_min =-1, v3_max = 100;
|
||||
@@ -149,7 +149,7 @@ void menuModelLogicalSwitches(event_t event)
|
||||
v1_val = cs->v1;
|
||||
drawSource(CSW_2ND_COLUMN, y, v1_val, attr1);
|
||||
drawSource(CSW_3RD_COLUMN, y, cs->v2, attr2);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
else if (cstate == LS_FAMILY_TIMER) {
|
||||
@@ -164,7 +164,7 @@ void menuModelLogicalSwitches(event_t event)
|
||||
v1_val = cs->v1;
|
||||
drawSource(CSW_2ND_COLUMN, y, v1_val, attr1);
|
||||
if (horz == 1) {
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailableInCustomSwitches);
|
||||
}
|
||||
else {
|
||||
@@ -175,7 +175,7 @@ void menuModelLogicalSwitches(event_t event)
|
||||
getMixSrcRange(v1_val, v2_min, v2_max, &lf);
|
||||
if ((cs->func == LS_FUNC_APOS) || (cs->func == LS_FUNC_ANEG) || (cs->func == LS_FUNC_ADIFFEGREATER))
|
||||
v2_min = 0;
|
||||
drawSourceCustomValue(CSW_3RD_COLUMN, y, v1_val, (v1_val <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2), lf);
|
||||
drawSourceCustomValue(CSW_3RD_COLUMN, y, v1_val, (abs(v1_val) <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2), lf);
|
||||
}
|
||||
|
||||
// CSW AND switch
|
||||
@@ -228,14 +228,14 @@ void menuModelLogicalSwitches(event_t event)
|
||||
cs->v1 = CHECK_INCDEC_PARAM(event, v1_val, v1_min, v1_max);
|
||||
break;
|
||||
case LS_FIELD_V2:
|
||||
if (v1_val >= MIXSRC_FIRST_TIMER) {
|
||||
if (abs(v1_val) >= MIXSRC_FIRST_TIMER) {
|
||||
INCDEC_SET_FLAG(EE_MODEL | INCDEC_REP10 | NO_INCDEC_MARKS);
|
||||
}
|
||||
cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max);
|
||||
if (cstate==LS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(event);
|
||||
getvalue_t x = getValue(v1_val);
|
||||
if (v1_val <= MIXSRC_LAST_CH) {
|
||||
if (abs(v1_val) <= MIXSRC_LAST_CH) {
|
||||
cs->v2 = calcRESXto100(x);
|
||||
}
|
||||
storageDirty(EE_MODEL);
|
||||
|
||||
@@ -126,7 +126,8 @@ void menuModelMixOne(event_t event)
|
||||
case MIX_FIELD_SOURCE:
|
||||
lcdDrawTextAlignedLeft(y, STR_SOURCE);
|
||||
drawSource(MIXES_2ND_COLUMN, y, md2->srcRaw, STREXPANDED|attr);
|
||||
if (attr) CHECK_INCDEC_MODELSOURCE(event, md2->srcRaw, 1, MIXSRC_LAST);
|
||||
if (attr)
|
||||
md2->srcRaw = checkIncDec(event, md2->srcRaw, 1, MIXSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailable);
|
||||
break;
|
||||
|
||||
case MIX_FIELD_WEIGHT:
|
||||
|
||||
@@ -326,7 +326,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_TELEM;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalFunctions : isSourceAvailable);
|
||||
}
|
||||
}
|
||||
@@ -335,7 +335,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
}
|
||||
@@ -372,7 +372,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
|
||||
val_max = MIXSRC_LAST_CH;
|
||||
drawSource(MODEL_SPECIAL_FUNC_3RD_COLUMN, y, val_displayed, attr);
|
||||
if (active) {
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE);
|
||||
INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE | INCDEC_SOURCE_INVERT);
|
||||
INCDEC_ENABLE_CHECK(isSourceAvailable);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y MESSAGEBOX_Y + 2
|
||||
|
||||
#define POPUP_MENU_MAX_LINES 12
|
||||
#define POPUP_MENU_MAX_LINES 13
|
||||
#define MENU_MAX_DISPLAY_LINES 6
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ void CurveDataEdit::update()
|
||||
}
|
||||
}
|
||||
|
||||
void CurveEdit::SetCurrentSource(uint32_t source)
|
||||
void CurveEdit::SetCurrentSource(mixsrc_t source)
|
||||
{
|
||||
CurveEdit::currentSource = source;
|
||||
if (source)
|
||||
|
||||
@@ -31,7 +31,7 @@ class CurveEdit: public Window
|
||||
{
|
||||
public:
|
||||
CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
|
||||
static void SetCurrentSource(uint32_t source);
|
||||
static void SetCurrentSource(mixsrc_t source);
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override
|
||||
{
|
||||
|
||||
@@ -95,14 +95,14 @@ InputSource::InputSource(Window *parent, ExpoData *input) :
|
||||
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_size(lvobj, lv_pct(100), LV_SIZE_CONTENT);
|
||||
|
||||
new SourceChoice(this, rect_t{}, INPUTSRC_FIRST, INPUTSRC_LAST,
|
||||
GET_DEFAULT(input->srcRaw), [=](int32_t newValue) {
|
||||
input->srcRaw = newValue;
|
||||
lv_event_send(lvobj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
SET_DIRTY();
|
||||
});
|
||||
lv_obj_add_event_cb(lvobj, InputSource::value_changed, LV_EVENT_VALUE_CHANGED,
|
||||
nullptr);
|
||||
new SourceChoice(
|
||||
this, rect_t{}, INPUTSRC_FIRST, INPUTSRC_LAST, GET_DEFAULT(input->srcRaw),
|
||||
[=](int32_t newValue) {
|
||||
input->srcRaw = newValue;
|
||||
lv_event_send(lvobj, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
SET_DIRTY();
|
||||
}, true);
|
||||
lv_obj_add_event_cb(lvobj, InputSource::value_changed, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
|
||||
sensor_form = new Window(this, rect_t{});
|
||||
sensor_form->padAll(PAD_TINY);
|
||||
|
||||
@@ -110,7 +110,7 @@ void MixEditWindow::buildBody(Window *form)
|
||||
line = form->newLine(grid);
|
||||
new StaticText(line, rect_t{}, STR_SOURCE);
|
||||
new SourceChoice(line, rect_t{}, 0, MIXSRC_LAST,
|
||||
GET_SET_DEFAULT(mix->srcRaw));
|
||||
GET_SET_DEFAULT(mix->srcRaw), true);
|
||||
CurveEdit::SetCurrentSource(mix->srcRaw);
|
||||
|
||||
// Weight
|
||||
|
||||
@@ -122,7 +122,7 @@ class LogicalSwitchEditPage : public Page
|
||||
break;
|
||||
case LS_FAMILY_COMP:
|
||||
new SourceChoice(line, rect_t{}, 0, MIXSRC_LAST_TELEM,
|
||||
GET_SET_DEFAULT(cs->v1));
|
||||
GET_SET_DEFAULT(cs->v1), true);
|
||||
break;
|
||||
case LS_FAMILY_TIMER:
|
||||
timer =
|
||||
@@ -144,7 +144,7 @@ class LogicalSwitchEditPage : public Page
|
||||
v2Edit->setValue(cs->v2);
|
||||
}
|
||||
SET_DIRTY();
|
||||
});
|
||||
}, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class LogicalSwitchEditPage : public Page
|
||||
} break;
|
||||
case LS_FAMILY_COMP:
|
||||
new SourceChoice(line, rect_t{}, 0, MIXSRC_LAST_TELEM,
|
||||
GET_SET_DEFAULT(cs->v2));
|
||||
GET_SET_DEFAULT(cs->v2), true);
|
||||
break;
|
||||
case LS_FAMILY_TIMER:
|
||||
timer =
|
||||
@@ -208,7 +208,7 @@ class LogicalSwitchEditPage : public Page
|
||||
GET_SET_DEFAULT(cs->v2));
|
||||
|
||||
v2Edit->setDisplayHandler([=](int value) -> std::string {
|
||||
if (cs->v1 <= MIXSRC_LAST_CH) value = calc100toRESX(value);
|
||||
if (abs(cs->v1) <= MIXSRC_LAST_CH) value = calc100toRESX(value);
|
||||
std::string txt = getSourceCustomValueString(cs->v1, value, 0);
|
||||
return txt;
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
class SourceChoiceMenuToolbar : public MenuToolbar
|
||||
{
|
||||
public:
|
||||
SourceChoiceMenuToolbar(SourceChoice *choice, Menu *menu) :
|
||||
SourceChoiceMenuToolbar(SourceChoice* choice, Menu* menu) :
|
||||
MenuToolbar(choice, menu, FILTER_COLUMNS)
|
||||
{
|
||||
addButton(STR_CHAR_INPUT, MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, nullptr,
|
||||
@@ -104,9 +104,79 @@ class SourceChoiceMenuToolbar : public MenuToolbar
|
||||
if ((nxtBtnPos > filterColumns) && choice->isValueAvailable &&
|
||||
choice->isValueAvailable(0))
|
||||
addButton(STR_SELECT_MENU_CLR, 0, 0, nullptr, nullptr, true);
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
if (choice->canInvert) {
|
||||
invertBtn = new MenuToolbarButton(this, {0, 0, LV_PCT(100), 0},
|
||||
STR_SELECT_MENU_INV);
|
||||
invertBtn->check(choice->inverted);
|
||||
lv_obj_align(invertBtn->getLvObj(), LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
|
||||
invertBtn->setPressHandler([=]() {
|
||||
lv_obj_clear_state(invertBtn->getLvObj(), LV_STATE_FOCUSED);
|
||||
invertChoice();
|
||||
return choice->inverted;
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void invertChoice()
|
||||
{
|
||||
SourceChoice* sourceChoice = (SourceChoice*)choice;
|
||||
if (sourceChoice->canInvert) {
|
||||
sourceChoice->inverted = !sourceChoice->inverted;
|
||||
auto idx = menu->selection();
|
||||
sourceChoice->fillMenu(menu, filter);
|
||||
menu->select(idx);
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
invertBtn->check(sourceChoice->inverted);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void longPress()
|
||||
{
|
||||
lv_indev_t* indev = lv_indev_get_act();
|
||||
if (indev->driver->type == LV_INDEV_TYPE_KEYPAD) {
|
||||
invertChoice();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
MenuToolbarButton* invertBtn = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
void SourceChoice::LongPressHandler(void* data)
|
||||
{
|
||||
SourceChoice* src = (SourceChoice*)data;
|
||||
if (src && src->canInvert) {
|
||||
int16_t val = src->_getValue();
|
||||
if (src->isValueAvailable && src->isValueAvailable(-val)) {
|
||||
src->setValue(-val);
|
||||
src->invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SourceChoice::setValue(int value)
|
||||
{
|
||||
if (inMenu) {
|
||||
if (inverted) value = -value;
|
||||
inMenu = false;
|
||||
}
|
||||
Choice::setValue(value);
|
||||
}
|
||||
|
||||
int SourceChoice::getIntValue() const
|
||||
{
|
||||
int value = Choice::getIntValue();
|
||||
if (inMenu) value = abs(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
// defined in gui/gui_common.cpp
|
||||
uint8_t switchToMix(uint8_t source);
|
||||
|
||||
@@ -114,6 +184,9 @@ void SourceChoice::openMenu()
|
||||
{
|
||||
setEditMode(true); // this needs to be done first before menu is created.
|
||||
|
||||
inverted = getIntValue() < 0;
|
||||
inMenu = true;
|
||||
|
||||
auto menu = new Menu(this);
|
||||
if (menuTitle) menu->setTitle(menuTitle);
|
||||
|
||||
@@ -149,15 +222,19 @@ void SourceChoice::openMenu()
|
||||
|
||||
SourceChoice::SourceChoice(Window *parent, const rect_t &rect, int16_t vmin,
|
||||
int16_t vmax, std::function<int16_t()> getValue,
|
||||
std::function<void(int16_t)> setValue) :
|
||||
Choice(parent, rect, vmin, vmax, getValue, setValue, STR_SOURCE)
|
||||
std::function<void(int16_t)> setValue, bool allowInvert) :
|
||||
Choice(parent, rect, vmin, vmax, getValue, setValue, STR_SOURCE), canInvert(allowInvert)
|
||||
{
|
||||
setTextHandler([=](int value) {
|
||||
if (inMenu && inverted) value = -value;
|
||||
|
||||
if (isValueAvailable && !isValueAvailable(value))
|
||||
return std::to_string(0); // we will fix this later
|
||||
|
||||
return std::string(getSourceString(value));
|
||||
});
|
||||
|
||||
set_lv_LongPressHandler(LongPressHandler, this);
|
||||
|
||||
setAvailableHandler([](int v) { return isSourceAvailable(v); });
|
||||
}
|
||||
|
||||
@@ -33,11 +33,21 @@ class SourceChoice : public Choice
|
||||
public:
|
||||
SourceChoice(Window* parent, const rect_t& rect, int16_t vmin, int16_t vmax,
|
||||
std::function<int16_t()> getValue,
|
||||
std::function<void(int16_t)> setValue);
|
||||
std::function<void(int16_t)> setValue, bool allowInvert = false);
|
||||
|
||||
static void LongPressHandler(void* data);
|
||||
|
||||
protected:
|
||||
friend SourceChoiceMenuToolbar;
|
||||
|
||||
bool inMenu = false;
|
||||
bool canInvert = false;
|
||||
|
||||
void setValue(int value) override;
|
||||
int getIntValue() const override;
|
||||
|
||||
void invertChoice();
|
||||
|
||||
void openMenu() override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
|
||||
@@ -373,7 +373,7 @@ void FunctionEditPage::addSourceChoice(FormLine *line, const char *title,
|
||||
CustomFunctionData *cfn, int16_t vmax)
|
||||
{
|
||||
new StaticText(line, rect_t{}, title);
|
||||
new SourceChoice(line, rect_t{}, 0, vmax, GET_SET_DEFAULT(CFN_PARAM(cfn)));
|
||||
new SourceChoice(line, rect_t{}, 0, vmax, GET_SET_DEFAULT(CFN_PARAM(cfn)), true);
|
||||
}
|
||||
|
||||
NumberEdit *FunctionEditPage::addNumberEdit(FormLine *line, const char *title,
|
||||
|
||||
@@ -98,7 +98,9 @@ class SwitchChoiceMenuToolbar : public MenuToolbar
|
||||
}
|
||||
|
||||
protected:
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
MenuToolbarButton* invertBtn = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
void SwitchChoice::LongPressHandler(void* data)
|
||||
|
||||
@@ -460,8 +460,10 @@ void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, int32_t value,
|
||||
}
|
||||
}
|
||||
|
||||
void drawSourceCustomValue(coord_t x, coord_t y, source_t source, int32_t value, LcdFlags flags)
|
||||
void drawSourceCustomValue(coord_t x, coord_t y, mixsrc_t source, int32_t value, LcdFlags flags)
|
||||
{
|
||||
source = abs(source);
|
||||
|
||||
if (source >= MIXSRC_FIRST_TELEM) {
|
||||
source = (source-MIXSRC_FIRST_TELEM) / 3;
|
||||
drawSensorCustomValue(x, y, source, value, flags);
|
||||
|
||||
@@ -175,11 +175,13 @@ void drawFunction(FnFuncP fn, uint8_t offset)
|
||||
|
||||
void drawCursor(FnFuncP fn, uint8_t offset)
|
||||
{
|
||||
int16_t src = abs(s_currSrcRaw);
|
||||
|
||||
int x512 = getValue(s_currSrcRaw);
|
||||
if (s_currSrcRaw >= MIXSRC_FIRST_TELEM) {
|
||||
if (src >= MIXSRC_FIRST_TELEM) {
|
||||
if (s_currScale > 0)
|
||||
x512 = (x512 * 1024) / convertTelemValue(s_currSrcRaw - MIXSRC_FIRST_TELEM + 1, s_currScale);
|
||||
drawSensorCustomValue(LCD_W - FW - offset, 6 * FH, (s_currSrcRaw - MIXSRC_FIRST_TELEM) / 3, x512, 0);
|
||||
x512 = (x512 * 1024) / convertTelemValue(src - MIXSRC_FIRST_TELEM + 1, s_currScale);
|
||||
drawSensorCustomValue(LCD_W - FW - offset, 6 * FH, (src - MIXSRC_FIRST_TELEM) / 3, x512, 0);
|
||||
}
|
||||
else {
|
||||
lcdDrawNumber(LCD_W - FW - offset, 6*FH, calcRESXto1000(x512), RIGHT | PREC1);
|
||||
|
||||
@@ -179,7 +179,7 @@ int getChannelsUsed()
|
||||
bool isSourceAvailable(int source)
|
||||
{
|
||||
if (source < 0)
|
||||
return false;
|
||||
source = -source;
|
||||
|
||||
if (source >= MIXSRC_FIRST_INPUT && source <= MIXSRC_LAST_INPUT) {
|
||||
return isInputAvailable(source - MIXSRC_FIRST_INPUT);
|
||||
|
||||
@@ -129,7 +129,7 @@ void drawTelemScreenDate(coord_t x, coord_t y, source_t sensor, LcdFlags flags=0
|
||||
void drawGPSPosition(coord_t x, coord_t y, int32_t longitude, int32_t latitude, LcdFlags flags=0);
|
||||
void drawGPSSensorValue(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags flags=0);
|
||||
void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, int32_t value, LcdFlags flags=0);
|
||||
void drawSourceCustomValue(coord_t x, coord_t y, source_t channel, int32_t val, LcdFlags flags=0);
|
||||
void drawSourceCustomValue(coord_t x, coord_t y, mixsrc_t channel, int32_t val, LcdFlags flags=0);
|
||||
void drawSourceValue(coord_t x, coord_t y, source_t channel, LcdFlags flags=0);
|
||||
|
||||
// model_setup Defines that are used in all uis in the same way
|
||||
|
||||
@@ -115,6 +115,8 @@ void onSourceLongEnterPress(const char * result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (result == STR_MENU_INVERT) {
|
||||
checkIncDecSelection = MIXSRC_INVERT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ extern int8_t s_editMode; // global editmode
|
||||
#define INCDEC_SOURCE 0x10
|
||||
#define INCDEC_REP10 0x40
|
||||
#define NO_DBLKEYS 0x80
|
||||
#define INCDEC_SOURCE_INVERT 0x100
|
||||
|
||||
int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
unsigned int i_flags = 0, IsValueAvailable isValueAvailable = nullptr,
|
||||
@@ -96,7 +97,7 @@ void check(event_t event, uint8_t curr, const MenuHandler *menuTab,
|
||||
vertpos_t rowcount, uint8_t flags = 0);
|
||||
|
||||
#define INCDEC_DECLARE_VARS(f) \
|
||||
uint8_t incdecFlag = (f); \
|
||||
uint16_t incdecFlag = (f); \
|
||||
IsValueAvailable isValueAvailable = nullptr
|
||||
|
||||
#define INCDEC_SET_FLAG(f) incdecFlag = (f)
|
||||
|
||||
@@ -61,6 +61,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
|
||||
if (s_editMode > 0) {
|
||||
bool invert = false;
|
||||
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
|
||||
invert = true;
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
|
||||
if (event == evt_rot_inc || event == EVT_KEY_FIRST(KEY_PLUS) ||
|
||||
event == EVT_KEY_REPT(KEY_PLUS)) {
|
||||
|
||||
@@ -119,22 +126,19 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (invert) {
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
s_editMode = 0;
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
else {
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(event);
|
||||
@@ -178,10 +182,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i_flags & INCDEC_SOURCE_INVERT) POPUP_MENU_ADD_ITEM(STR_MENU_INVERT);
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
newval = checkIncDecSelection;
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
@@ -212,6 +217,15 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
checkIncDecSelection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
else {
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
return newval;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
|
||||
if (s_editMode > 0) {
|
||||
bool invert = false;
|
||||
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
|
||||
invert = true;
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
|
||||
if (event == evt_rot_inc || event == EVT_KEY_FIRST(KEY_PLUS) ||
|
||||
event == EVT_KEY_REPT(KEY_PLUS)) {
|
||||
|
||||
@@ -119,6 +126,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (invert) {
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
@@ -127,27 +139,6 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
newval = !val;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
#if !defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
|
||||
(newval != i_min) && stops.contains(newval)) {
|
||||
bool pause = (newval > val ? !stops.contains(newval + 1)
|
||||
: !stops.contains(newval - 1));
|
||||
if (pause) {
|
||||
pauseEvents(event); // delay before auto-repeat continues
|
||||
}
|
||||
}
|
||||
if (!IS_KEY_REPT(event)) {
|
||||
AUDIO_KEY_PRESS();
|
||||
}
|
||||
#endif
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
else {
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (i_flags & INCDEC_SOURCE) {
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(event);
|
||||
@@ -191,10 +182,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i_flags & INCDEC_SOURCE_INVERT) POPUP_MENU_ADD_ITEM(STR_MENU_INVERT);
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
newval = checkIncDecSelection;
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
@@ -225,6 +217,49 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
checkIncDecSelection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
#if !defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
|
||||
(newval != i_min) && stops.contains(newval)) {
|
||||
bool pause = (newval > val ? !stops.contains(newval + 1)
|
||||
: !stops.contains(newval - 1));
|
||||
if (pause) {
|
||||
pauseEvents(event); // delay before auto-repeat continues
|
||||
}
|
||||
}
|
||||
if (!IS_KEY_REPT(event)) {
|
||||
AUDIO_KEY_PRESS();
|
||||
}
|
||||
#endif
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
else {
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
if (newval != val) {
|
||||
#if !defined(ROTARY_ENCODER_NAVIGATION)
|
||||
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
|
||||
(newval != i_min) && stops.contains(newval)) {
|
||||
bool pause = (newval > val ? !stops.contains(newval + 1)
|
||||
: !stops.contains(newval - 1));
|
||||
if (pause) {
|
||||
pauseEvents(event); // delay before auto-repeat continues
|
||||
}
|
||||
}
|
||||
if (!IS_KEY_REPT(event)) {
|
||||
AUDIO_KEY_PRESS();
|
||||
}
|
||||
#endif
|
||||
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
|
||||
checkIncDec_Ret = (newval > val ? 1 : -1);
|
||||
}
|
||||
else {
|
||||
checkIncDec_Ret = 0;
|
||||
}
|
||||
|
||||
return newval;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
int newval = val;
|
||||
|
||||
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_RIGHT) || event == EVT_KEY_REPT(KEY_RIGHT) ||
|
||||
event == EVT_KEY_FIRST(KEY_UP) || event == EVT_KEY_REPT(KEY_UP)) {
|
||||
do {
|
||||
@@ -109,6 +116,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (invert) {
|
||||
newval = -newval;
|
||||
val = -val;
|
||||
}
|
||||
}
|
||||
|
||||
if (!READ_ONLY() && i_min == 0 && i_max == 1 &&
|
||||
@@ -179,10 +191,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i_flags & INCDEC_SOURCE_INVERT) POPUP_MENU_ADD_ITEM(STR_MENU_INVERT);
|
||||
POPUP_MENU_START(onSourceLongEnterPress);
|
||||
}
|
||||
if (checkIncDecSelection != 0) {
|
||||
newval = checkIncDecSelection;
|
||||
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
|
||||
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
|
||||
s_editMode = EDIT_MODIFY_FIELD;
|
||||
checkIncDecSelection = 0;
|
||||
|
||||
+27
-12
@@ -155,29 +155,31 @@ int expo(int x, int k)
|
||||
return neg ? -y : y;
|
||||
}
|
||||
|
||||
void applyExpos(int16_t * anas, uint8_t mode, uint8_t ovwrIdx, int16_t ovwrValue)
|
||||
void applyExpos(int16_t * anas, uint8_t mode, int16_t ovwrIdx, int16_t ovwrValue)
|
||||
{
|
||||
int8_t cur_chn = -1;
|
||||
|
||||
for (uint8_t i=0; i<MAX_EXPOS; i++) {
|
||||
if (mode == e_perout_mode_normal) mixState[i].activeExpo = false;
|
||||
ExpoData * ed = expoAddress(i);
|
||||
mixsrc_t srcRaw = ed->srcRaw;
|
||||
mixsrc_t src = abs(srcRaw);
|
||||
if (!EXPO_VALID(ed)) break; // end of list
|
||||
if (ed->chn == cur_chn)
|
||||
continue;
|
||||
if (ed->flightModes & (1<<mixerCurrentFlightMode))
|
||||
continue;
|
||||
if (ed->srcRaw >= MIXSRC_FIRST_TRAINER && ed->srcRaw <= MIXSRC_LAST_TRAINER && !isTrainerValid())
|
||||
if (src >= MIXSRC_FIRST_TRAINER && src <= MIXSRC_LAST_TRAINER && !isTrainerValid())
|
||||
continue;
|
||||
if (getSwitch(ed->swtch)) {
|
||||
int32_t v;
|
||||
if (ed->srcRaw == ovwrIdx) {
|
||||
if (srcRaw == ovwrIdx) {
|
||||
v = ovwrValue;
|
||||
}
|
||||
else {
|
||||
v = getValue(ed->srcRaw);
|
||||
if (ed->srcRaw >= MIXSRC_FIRST_TELEM && ed->scale > 0) {
|
||||
v = (v * 1024) / convertTelemValue(ed->srcRaw-MIXSRC_FIRST_TELEM+1, ed->scale);
|
||||
v = getValue(srcRaw);
|
||||
if (src >= MIXSRC_FIRST_TELEM && ed->scale > 0) {
|
||||
v = (v * 1024) / convertTelemValue(src-MIXSRC_FIRST_TELEM+1, ed->scale);
|
||||
}
|
||||
v = limit<int32_t>(-1024, v, 1024);
|
||||
}
|
||||
@@ -201,11 +203,12 @@ void applyExpos(int16_t * anas, uint8_t mode, uint8_t ovwrIdx, int16_t ovwrValue
|
||||
//========== TRIMS ================
|
||||
if (ed->trimSource < TRIM_ON)
|
||||
virtualInputsTrims[cur_chn] = -ed->trimSource - 1;
|
||||
else if (ed->trimSource == TRIM_ON && ed->srcRaw >= MIXSRC_FIRST_STICK &&
|
||||
ed->srcRaw <= MIXSRC_LAST_STICK)
|
||||
virtualInputsTrims[cur_chn] = ed->srcRaw - MIXSRC_FIRST_STICK;
|
||||
else if (ed->trimSource == TRIM_ON && src >= MIXSRC_FIRST_STICK &&
|
||||
src <= MIXSRC_LAST_STICK)
|
||||
virtualInputsTrims[cur_chn] = src - MIXSRC_FIRST_STICK;
|
||||
else
|
||||
virtualInputsTrims[cur_chn] = -1;
|
||||
// if (srcRaw < 0) v = -v;
|
||||
anas[cur_chn] = v;
|
||||
}
|
||||
}
|
||||
@@ -313,7 +316,7 @@ static const getvalue_t _switch_3pos_lookup[] = {
|
||||
|
||||
// TODO same naming convention than the drawSource
|
||||
// *valid added to return status to Lua for invalid sources
|
||||
getvalue_t getValue(mixsrc_t i, bool* valid)
|
||||
getvalue_t _getValue(mixsrc_t i, bool* valid)
|
||||
{
|
||||
if (i == MIXSRC_NONE) {
|
||||
if (valid != nullptr) *valid = false;
|
||||
@@ -325,7 +328,7 @@ getvalue_t getValue(mixsrc_t i, bool* valid)
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (i <= MIXSRC_LAST_LUA) {
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
div_t qr = div(i-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
div_t qr = div((uint16_t)(i-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
|
||||
return scriptInputsOutputs[qr.quot].outputs[qr.rem].value;
|
||||
#else
|
||||
if (valid != nullptr) *valid = false;
|
||||
@@ -464,7 +467,7 @@ getvalue_t getValue(mixsrc_t i, bool* valid)
|
||||
return 0;
|
||||
}
|
||||
i -= MIXSRC_FIRST_TELEM;
|
||||
div_t qr = div(i, 3);
|
||||
div_t qr = div((uint16_t)i, 3);
|
||||
TelemetryItem & telemetryItem = telemetryItems[qr.quot];
|
||||
switch (qr.rem) {
|
||||
case 1:
|
||||
@@ -595,6 +598,18 @@ void evalInputs(uint8_t mode)
|
||||
}
|
||||
}
|
||||
|
||||
getvalue_t getValue(mixsrc_t i, bool* valid)
|
||||
{
|
||||
bool invert = false;
|
||||
if (i < 0) {
|
||||
invert = true;
|
||||
i = -i;
|
||||
}
|
||||
getvalue_t v = _getValue(i, valid);
|
||||
if (invert) v = -v;
|
||||
return v;
|
||||
}
|
||||
|
||||
#if defined(SURFACE_RADIO)
|
||||
constexpr int IDLE_TRIM_SCALE = 1;
|
||||
#else
|
||||
|
||||
+13
-11
@@ -1881,43 +1881,45 @@ bool modelTelemetryEnabled() {
|
||||
|
||||
void getMixSrcRange(const int source, int16_t & valMin, int16_t & valMax, LcdFlags * flags)
|
||||
{
|
||||
if (source >= MIXSRC_FIRST_TRIM && source <= MIXSRC_LAST_TRIM) {
|
||||
int asrc = abs(source);
|
||||
|
||||
if (asrc >= MIXSRC_FIRST_TRIM && asrc <= MIXSRC_LAST_TRIM) {
|
||||
valMax = g_model.extendedTrims ? TRIM_EXTENDED_MAX : TRIM_MAX;
|
||||
valMin = -valMax;
|
||||
}
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (source >= MIXSRC_FIRST_LUA && source <= MIXSRC_LAST_LUA) {
|
||||
else if (asrc >= MIXSRC_FIRST_LUA && asrc <= MIXSRC_LAST_LUA) {
|
||||
valMax = 30000;
|
||||
valMin = -valMax;
|
||||
}
|
||||
#endif
|
||||
else if (source < MIXSRC_FIRST_CH) {
|
||||
else if (asrc < MIXSRC_FIRST_CH) {
|
||||
valMax = 100;
|
||||
valMin = -valMax;
|
||||
}
|
||||
else if (source <= MIXSRC_LAST_CH) {
|
||||
else if (asrc <= MIXSRC_LAST_CH) {
|
||||
valMax = g_model.extendedLimits ? LIMIT_EXT_PERCENT : 100;
|
||||
valMin = -valMax;
|
||||
}
|
||||
#if defined(GVARS)
|
||||
else if (source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR) {
|
||||
valMax = min<int>(CFN_GVAR_CST_MAX, MODEL_GVAR_MAX(source-MIXSRC_FIRST_GVAR));
|
||||
valMin = max<int>(CFN_GVAR_CST_MIN, MODEL_GVAR_MIN(source-MIXSRC_FIRST_GVAR));
|
||||
if (flags && g_model.gvars[source-MIXSRC_FIRST_GVAR].prec)
|
||||
else if (asrc >= MIXSRC_FIRST_GVAR && asrc <= MIXSRC_LAST_GVAR) {
|
||||
valMax = min<int>(CFN_GVAR_CST_MAX, MODEL_GVAR_MAX(asrc-MIXSRC_FIRST_GVAR));
|
||||
valMin = max<int>(CFN_GVAR_CST_MIN, MODEL_GVAR_MIN(asrc-MIXSRC_FIRST_GVAR));
|
||||
if (flags && g_model.gvars[asrc-MIXSRC_FIRST_GVAR].prec)
|
||||
*flags |= PREC1;
|
||||
}
|
||||
#endif
|
||||
else if (source == MIXSRC_TX_VOLTAGE) {
|
||||
else if (asrc == MIXSRC_TX_VOLTAGE) {
|
||||
valMax = 255;
|
||||
valMin = 0;
|
||||
if (flags)
|
||||
*flags |= PREC1;
|
||||
}
|
||||
else if (source == MIXSRC_TX_TIME) {
|
||||
else if (asrc == MIXSRC_TX_TIME) {
|
||||
valMax = 23 * 60 + 59;
|
||||
valMin = 0;
|
||||
}
|
||||
else if (source >= MIXSRC_FIRST_TIMER && source <= MIXSRC_LAST_TIMER) {
|
||||
else if (asrc >= MIXSRC_FIRST_TIMER && asrc <= MIXSRC_LAST_TIMER) {
|
||||
valMax = 9 * 60 * 60 - 1;
|
||||
valMin = -valMax;
|
||||
if (flags)
|
||||
|
||||
+1
-1
@@ -401,7 +401,7 @@ int expo(int x, int k);
|
||||
|
||||
extern void getMixSrcRange(const int source, int16_t & valMin, int16_t & valMax, LcdFlags * flags = nullptr);
|
||||
|
||||
void applyExpos(int16_t * anas, uint8_t mode, uint8_t ovwrIdx=0, int16_t ovwrValue=0);
|
||||
void applyExpos(int16_t * anas, uint8_t mode, int16_t ovwrIdx=0, int16_t ovwrValue=0);
|
||||
int16_t applyLimits(uint8_t channel, int32_t value);
|
||||
|
||||
void evalInputs(uint8_t mode);
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef uint16_t event_t;
|
||||
typedef uint32_t tmr10ms_t;
|
||||
typedef int32_t rotenc_t;
|
||||
typedef int32_t getvalue_t;
|
||||
typedef uint32_t mixsrc_t;
|
||||
typedef int32_t mixsrc_t;
|
||||
typedef int32_t swsrc_t;
|
||||
typedef int16_t safetych_t;
|
||||
typedef int16_t gvar_t;
|
||||
|
||||
@@ -395,7 +395,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -429,7 +429,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -417,6 +417,38 @@ static bool w_mixSrcRaw(const YamlNode* node, uint32_t val, yaml_writer_func wf,
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint32_t r_mixSrcRawEx(const YamlNode* node, const char* val, uint8_t val_len)
|
||||
{
|
||||
bool invert = false;
|
||||
if (val[0] == '!') {
|
||||
invert = true;
|
||||
val += 1;
|
||||
val_len -= 1;
|
||||
}
|
||||
int32_t rv = r_mixSrcRaw(node, val, val_len);
|
||||
if (invert)
|
||||
rv = -rv;
|
||||
return (uint32_t)rv;
|
||||
}
|
||||
|
||||
static bool w_mixSrcRawExNoQuote(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque)
|
||||
{
|
||||
// Check for negative 10 bit value. TODO: handle this better!
|
||||
val &= 0x3FF;
|
||||
if (val >= 512) {
|
||||
if (!wf(opaque, "!", 1)) return false;
|
||||
val = 1024 - val;
|
||||
}
|
||||
return w_mixSrcRaw(node, val, wf, opaque);
|
||||
}
|
||||
|
||||
static bool w_mixSrcRawEx(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque)
|
||||
{
|
||||
if (!wf(opaque, "\"", 1)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(node, val, wf, opaque)) return false;
|
||||
return wf(opaque, "\"", 1);
|
||||
}
|
||||
|
||||
static void r_rssiDisabled(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
const char* val, uint8_t val_len)
|
||||
{
|
||||
@@ -1459,7 +1491,7 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
case FUNC_BACKLIGHT:
|
||||
case FUNC_PLAY_VALUE:
|
||||
// find "," and cut val_len
|
||||
CFN_PARAM(cfn) = r_mixSrcRaw(nullptr, val, l_sep);
|
||||
CFN_PARAM(cfn) = r_mixSrcRawEx(nullptr, val, l_sep);
|
||||
break;
|
||||
|
||||
case FUNC_PLAY_SOUND:
|
||||
@@ -1554,10 +1586,10 @@ static void r_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
CFN_PARAM(cfn) = yaml_str2int(val, l_sep);
|
||||
break;
|
||||
case FUNC_ADJUST_GVAR_SOURCE:
|
||||
CFN_PARAM(cfn) = r_mixSrcRaw(nullptr, val, l_sep);
|
||||
CFN_PARAM(cfn) = r_mixSrcRawEx(nullptr, val, l_sep);
|
||||
break;
|
||||
case FUNC_ADJUST_GVAR_GVAR: {
|
||||
uint32_t gvar = r_mixSrcRaw(nullptr, val, l_sep);
|
||||
uint32_t gvar = r_mixSrcRawEx(nullptr, val, l_sep);
|
||||
if (gvar >= MIXSRC_FIRST_GVAR) {
|
||||
CFN_PARAM(cfn) = gvar - MIXSRC_FIRST_GVAR;
|
||||
}
|
||||
@@ -1680,7 +1712,7 @@ static bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
case FUNC_VOLUME:
|
||||
case FUNC_BACKLIGHT:
|
||||
case FUNC_PLAY_VALUE:
|
||||
if (!w_mixSrcRaw(nullptr, CFN_PARAM(cfn), wf, opaque)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(nullptr, CFN_PARAM(cfn), wf, opaque)) return false;
|
||||
break;
|
||||
|
||||
case FUNC_PLAY_SOUND:
|
||||
@@ -1739,10 +1771,10 @@ static bool w_customFn(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
if (!wf(opaque, str, strlen(str))) return false;
|
||||
break;
|
||||
case FUNC_ADJUST_GVAR_SOURCE:
|
||||
if (!w_mixSrcRaw(nullptr, CFN_PARAM(cfn), wf, opaque)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(nullptr, CFN_PARAM(cfn), wf, opaque)) return false;
|
||||
break;
|
||||
case FUNC_ADJUST_GVAR_GVAR:
|
||||
if (!w_mixSrcRaw(nullptr, CFN_PARAM(cfn) + MIXSRC_FIRST_GVAR, wf, opaque)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(nullptr, CFN_PARAM(cfn) + MIXSRC_FIRST_GVAR, wf, opaque)) return false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1837,11 +1869,11 @@ static void r_logicSw(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
|
||||
case LS_FAMILY_COMP:
|
||||
ls->v1 = r_mixSrcRaw(nullptr, val, l_sep);
|
||||
ls->v1 = r_mixSrcRawEx(nullptr, val, l_sep);
|
||||
val += l_sep; val_len -= l_sep;
|
||||
if (!val_len || val[0] != ',') return;
|
||||
val++; val_len--;
|
||||
ls->v2 = r_mixSrcRaw(nullptr, val, val_len);
|
||||
ls->v2 = r_mixSrcRawEx(nullptr, val, val_len);
|
||||
break;
|
||||
|
||||
case LS_FAMILY_TIMER:
|
||||
@@ -1853,7 +1885,7 @@ static void r_logicSw(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
|
||||
default:
|
||||
ls->v1 = r_mixSrcRaw(nullptr, val, l_sep);
|
||||
ls->v1 = r_mixSrcRawEx(nullptr, val, l_sep);
|
||||
val += l_sep; val_len -= l_sep;
|
||||
if (!val_len || val[0] != ',') return;
|
||||
val++; val_len--;
|
||||
@@ -1902,9 +1934,9 @@ static bool w_logicSw(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
|
||||
case LS_FAMILY_COMP:
|
||||
if (!w_mixSrcRaw(nullptr, ls->v1, wf, opaque)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(nullptr, ls->v1, wf, opaque)) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
if (!w_mixSrcRaw(nullptr, ls->v2, wf, opaque)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(nullptr, ls->v2, wf, opaque)) return false;
|
||||
break;
|
||||
|
||||
case LS_FAMILY_TIMER:
|
||||
@@ -1916,7 +1948,7 @@ static bool w_logicSw(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!w_mixSrcRaw(nullptr, ls->v1, wf, opaque)) return false;
|
||||
if (!w_mixSrcRawExNoQuote(nullptr, ls->v1, wf, opaque)) return false;
|
||||
if (!wf(opaque,",",1)) return false;
|
||||
// TODO?: ls->v1 <= MIXSRC_LAST_CH ? calc100toRESX(ls->v2) : ls->v2
|
||||
str = yaml_signed2str(ls->v2);
|
||||
|
||||
@@ -422,7 +422,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -456,7 +456,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -422,7 +422,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -456,7 +456,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -395,7 +395,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -429,7 +429,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -395,7 +395,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -429,7 +429,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -424,7 +424,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -458,7 +458,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -424,7 +424,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -458,7 +458,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -395,7 +395,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -429,7 +429,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -396,7 +396,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -430,7 +430,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
@@ -398,7 +398,7 @@ static const struct YamlNode struct_CurveRef[] = {
|
||||
static const struct YamlNode struct_MixData[] = {
|
||||
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
|
||||
YAML_UNSIGNED( "destCh", 5 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "carryTrim", 1 ),
|
||||
YAML_UNSIGNED( "mixWarn", 2 ),
|
||||
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
|
||||
@@ -432,7 +432,7 @@ static const struct YamlNode struct_ExpoData[] = {
|
||||
YAML_UNSIGNED( "scale", 14 ),
|
||||
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
|
||||
YAML_SIGNED( "trimSource", 6 ),
|
||||
YAML_UNSIGNED_CUST( "srcRaw", 10, r_mixSrcRaw, w_mixSrcRaw ),
|
||||
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
|
||||
YAML_UNSIGNED( "chn", 5 ),
|
||||
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
|
||||
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
|
||||
|
||||
+20
-11
@@ -609,9 +609,17 @@ const char *getPotLabel(uint8_t idx)
|
||||
// this should be declared in header, but it used so much foreign symbols that
|
||||
// we declare it in cpp-file and pre-instantiate it for the uses
|
||||
template <size_t L>
|
||||
char *getSourceString(char (&dest)[L], mixsrc_t idx)
|
||||
char *getSourceString(char (&destRef)[L], mixsrc_t idx)
|
||||
{
|
||||
size_t dest_len = L;
|
||||
char* dest = destRef;
|
||||
|
||||
if (idx < 0) {
|
||||
idx = -idx;
|
||||
dest[0] = '!';
|
||||
dest += 1;
|
||||
dest_len -= 1;
|
||||
}
|
||||
|
||||
if (idx == MIXSRC_NONE) {
|
||||
strncpy(dest, STR_EMPTY, dest_len - 1);
|
||||
@@ -634,7 +642,7 @@ char *getSourceString(char (&dest)[L], mixsrc_t idx)
|
||||
#if defined(LUA_INPUTS)
|
||||
else if (idx <= MIXSRC_LAST_LUA) {
|
||||
#if defined(LUA_MODEL_SCRIPTS)
|
||||
div_t qr = div(idx - MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
|
||||
div_t qr = div((uint16_t)(idx - MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
|
||||
if (qr.quot < MAX_SCRIPTS &&
|
||||
qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
|
||||
static_assert(L > sizeof(STR_CHAR_LUA) - 1, "dest string too small");
|
||||
@@ -658,7 +666,7 @@ char *getSourceString(char (&dest)[L], mixsrc_t idx)
|
||||
}
|
||||
}
|
||||
#else
|
||||
strncpy(dest, "N/A", L - 1);
|
||||
strncpy(dest, "N/A", dest_len-1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -723,7 +731,7 @@ char *getSourceString(char (&dest)[L], mixsrc_t idx)
|
||||
} else if (idx <= MIXSRC_LAST_CH) {
|
||||
auto ch = idx - MIXSRC_FIRST_CH;
|
||||
if (g_model.limitData[ch].name[0] != '\0') {
|
||||
copyToTerminated(dest, g_model.limitData[ch].name);
|
||||
strAppend(dest, g_model.limitData[ch].name, LEN_CHANNEL_NAME);
|
||||
} else {
|
||||
strAppendStringWithIndex(dest, STR_CH, ch + 1);
|
||||
}
|
||||
@@ -759,21 +767,21 @@ char *getSourceString(char (&dest)[L], mixsrc_t idx)
|
||||
} else if (idx <= MIXSRC_LAST_TIMER) {
|
||||
idx -= MIXSRC_FIRST_TIMER;
|
||||
if (g_model.timers[idx].name[0] != '\0') {
|
||||
copyToTerminated(dest, g_model.timers[idx].name);
|
||||
strAppend(dest, g_model.timers[idx].name, LEN_TIMER_NAME);
|
||||
} else {
|
||||
strAppendStringWithIndex(dest, STR_SRC_TIMER, idx + 1);
|
||||
}
|
||||
} else {
|
||||
idx -= MIXSRC_FIRST_TELEM;
|
||||
div_t qr = div(idx, 3);
|
||||
char *pos = strAppend(dest, STR_CHAR_TELEMETRY, 2);
|
||||
div_t qr = div((uint16_t)idx, 3);
|
||||
char* pos = strAppend(dest, STR_CHAR_TELEMETRY, 2);
|
||||
pos = strAppend(pos, g_model.telemetrySensors[qr.quot].label,
|
||||
sizeof(g_model.telemetrySensors[qr.quot].label));
|
||||
if (qr.rem) *pos = (qr.rem == 2 ? '+' : '-');
|
||||
*++pos = '\0';
|
||||
}
|
||||
dest[L - 1] = '\0'; // assert the termination
|
||||
return dest;
|
||||
destRef[L - 1] = '\0'; // assert the termination
|
||||
return destRef;
|
||||
}
|
||||
|
||||
// pre-instantiate for use from external
|
||||
@@ -850,9 +858,10 @@ char *getSensorCustomValueString(char (&dest)[L], uint8_t sensor, int32_t val,
|
||||
}
|
||||
|
||||
template <size_t L>
|
||||
char *getSourceCustomValueString(char (&dest)[L], source_t source, int32_t val,
|
||||
char *getSourceCustomValueString(char (&dest)[L], mixsrc_t source, int32_t val,
|
||||
LcdFlags flags)
|
||||
{
|
||||
source = abs(source);
|
||||
size_t len = L - 1;
|
||||
if (source >= MIXSRC_FIRST_TELEM) {
|
||||
source = (source - MIXSRC_FIRST_TELEM) / 3;
|
||||
@@ -967,7 +976,7 @@ std::string formatNumberAsString(int32_t val, LcdFlags flags, uint8_t len,
|
||||
return std::string(s);
|
||||
}
|
||||
|
||||
char *getSourceCustomValueString(source_t source, int32_t val, LcdFlags flags)
|
||||
char *getSourceCustomValueString(mixsrc_t source, int32_t val, LcdFlags flags)
|
||||
{
|
||||
return getSourceCustomValueString(_static_str_buffer, source, val, flags);
|
||||
}
|
||||
|
||||
+2
-16
@@ -112,7 +112,7 @@ template <size_t L>
|
||||
char *getSourceString(char (&dest)[L], mixsrc_t idx);
|
||||
|
||||
template <size_t L>
|
||||
char *getSourceCustomValueString(char (&dest)[L], source_t source, int32_t val,
|
||||
char *getSourceCustomValueString(char (&dest)[L], mixsrc_t source, int32_t val,
|
||||
LcdFlags flags);
|
||||
|
||||
#endif
|
||||
@@ -120,7 +120,7 @@ char *getSourceCustomValueString(char (&dest)[L], source_t source, int32_t val,
|
||||
char *getFlightModeString(char *dest, int8_t idx);
|
||||
|
||||
char *getSourceString(mixsrc_t idx);
|
||||
char *getSourceCustomValueString(source_t source, int32_t val, LcdFlags flags);
|
||||
char *getSourceCustomValueString(mixsrc_t source, int32_t val, LcdFlags flags);
|
||||
char *getSwitchPositionName(swsrc_t idx);
|
||||
char *getCurveString(int idx);
|
||||
char *getTimerString(int32_t tme, TimerOptions timerOptions = {.options = 0});
|
||||
@@ -151,20 +151,6 @@ void clearStruct(S &s)
|
||||
template <size_t N>
|
||||
using offset_t = std::integral_constant<size_t, N>;
|
||||
|
||||
template <size_t DL, size_t SL, size_t O = 0>
|
||||
void copyToTerminated(char (&dest)[DL], const char (&src)[SL],
|
||||
const offset_t<O> = offset_t<0>{})
|
||||
{
|
||||
// unfortinately std::min() isn't constexpr in C++11
|
||||
// static constexpr size_t len = std::min(DL - O - 1, SL);
|
||||
static constexpr size_t dl{DL - O - 1};
|
||||
static_assert(dl > 0, "wrong sizes or offset");
|
||||
static constexpr size_t len = (dl < SL) ? dl : SL;
|
||||
strncpy(&dest[O], &src[0], len);
|
||||
static_assert((len + O) < DL, "wrong sizes of offset");
|
||||
dest[len + O] = '\0';
|
||||
}
|
||||
|
||||
template <size_t L1, size_t L2>
|
||||
int strncasecmp(char (&s1)[L1], const char (&s2)[L2])
|
||||
{
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include "themes/etx_lv_theme.h"
|
||||
#include "translations.h"
|
||||
|
||||
constexpr uint32_t MENUS_TOOLBAR_BUTTON_WIDTH = 32;
|
||||
|
||||
static const lv_obj_class_t menu_button_class = {
|
||||
.base_class = &button_class,
|
||||
.constructor_cb = nullptr,
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "button.h"
|
||||
#include "choice.h"
|
||||
|
||||
constexpr uint32_t MENUS_TOOLBAR_BUTTON_WIDTH = 32;
|
||||
|
||||
class Menu;
|
||||
|
||||
class MenuToolbarButton : public ButtonBase
|
||||
|
||||
Reference in New Issue
Block a user