feat: add inverted sources (#4722)

Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
Neil Horne
2024-05-25 09:25:15 +10:00
committed by GitHub
co-authored by elecpower
parent ca50d4ee04
commit 80659c3e3f
87 changed files with 798 additions and 496 deletions
@@ -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);