fix: switch display
This commit is contained in:
committed by
Raphael Coeffic
parent
dd968c1fdb
commit
99ed405b84
@@ -425,6 +425,7 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event)
|
||||
#endif
|
||||
|
||||
static const char* _pots_warn_modes[] = { "OFF", "Man", "Auto" };
|
||||
static const char* _fct_sw_start[] = { STR_CHAR_UP, STR_CHAR_DOWN, "=" };
|
||||
|
||||
void menuModelSetup(event_t event)
|
||||
{
|
||||
@@ -670,13 +671,13 @@ void menuModelSetup(event_t event)
|
||||
|
||||
case ITEM_MODEL_SETUP_FS_STARTUP:
|
||||
{
|
||||
char c;
|
||||
const char* s;
|
||||
lcdDrawText(0, y, INDENT "Start", menuHorizontalPosition < 0 ? attr : 0);
|
||||
for (uint8_t i = 0; i < NUM_FUNCTIONS_SWITCHES; i++) {
|
||||
uint8_t startPos = (g_model.functionSwitchStartConfig >> 2 * i) & 0x03;
|
||||
c = STR_CHAR_UP STR_CHAR_DOWN "="[(g_model.functionSwitchStartConfig >> 2 * i) & 0x03];
|
||||
s = _fct_sw_start[(g_model.functionSwitchStartConfig >> 2 * i) & 0x03];
|
||||
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN - (2 + FW) + i * 2 * FW, y, i + 1, 0);
|
||||
lcdDrawChar(lcdNextPos, y, c, attr && (menuHorizontalPosition == i) ? (s_editMode ? INVERS + BLINK : INVERS) : 0);
|
||||
lcdDrawText(lcdNextPos, y, s, attr && (menuHorizontalPosition == i) ? (s_editMode ? INVERS + BLINK : INVERS) : 0);
|
||||
if (attr && menuHorizontalPosition == i) {
|
||||
CHECK_INCDEC_MODELVAR(event, startPos, 0, 2);
|
||||
}
|
||||
@@ -855,12 +856,12 @@ void menuModelSetup(event_t event)
|
||||
s_editMode = 0;
|
||||
#endif
|
||||
}
|
||||
c = (" " STR_CHAR_UP "-" STR_CHAR_DOWN)[states & 0x03];
|
||||
lcdDrawSizedText(
|
||||
MODEL_SETUP_2ND_COLUMN + qr.rem * ((2 * FW) + 1),
|
||||
y + FH * qr.quot, FIRSTSW_STR[i] + sizeof(STR_CHAR_SWITCH) - 1, 1,
|
||||
attr && (menuHorizontalPosition == current) ? INVERS : 0);
|
||||
lcdDrawChar(lcdNextPos, y + FH * qr.quot, c);
|
||||
lcdDrawText(lcdNextPos, y + FH * qr.quot,
|
||||
getSwitchWarnSymbol(states & 0x03));
|
||||
++current;
|
||||
}
|
||||
states >>= 3;
|
||||
|
||||
@@ -250,6 +250,8 @@ public:
|
||||
skip(width - pos%width);
|
||||
}
|
||||
|
||||
void reset() { curPtr = src; }
|
||||
|
||||
private:
|
||||
enum State {RLE_FIRST_BYTE, RLE_SECOND_BYTE, RLE_CONTINUE} state;
|
||||
const uint8_t* src;
|
||||
|
||||
@@ -752,12 +752,12 @@ void menuModelSetup(event_t event)
|
||||
g_model.switchWarningState |= (curr_state & 0x03) << (3 * i);
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
c = (" " STR_CHAR_UP "-" STR_CHAR_DOWN)[states & 0x03];
|
||||
lcdDrawChar(
|
||||
MODEL_SETUP_2ND_COLUMN + qr.rem * (2 * FW + 1),
|
||||
y + FH * qr.quot, 'A' + i,
|
||||
line && (menuHorizontalPosition == current) ? INVERS : 0);
|
||||
lcdDrawChar(lcdNextPos, y + FH * qr.quot, c);
|
||||
lcdDrawText(lcdNextPos, y + FH * qr.quot,
|
||||
getSwitchWarnSymbol(states & 0x03));
|
||||
++current;
|
||||
}
|
||||
states >>= 3;
|
||||
|
||||
+30
-18
@@ -477,6 +477,32 @@ char *getSwitchName(char *dest, swsrc_t idx)
|
||||
return dest;
|
||||
}
|
||||
|
||||
static const char* _switch_state_str[] {
|
||||
" ",
|
||||
STR_CHAR_UP,
|
||||
"-",
|
||||
STR_CHAR_DOWN,
|
||||
};
|
||||
|
||||
const char* getSwitchWarnSymbol(uint8_t pos)
|
||||
{
|
||||
// 0: NONE
|
||||
// 1: UP
|
||||
// 2: MIDDLE
|
||||
// 3: DOWN
|
||||
if (pos >= 4) return "";
|
||||
return _switch_state_str[pos];
|
||||
}
|
||||
|
||||
const char* getSwitchPositionSymbol(uint8_t pos)
|
||||
{
|
||||
// 0: UP
|
||||
// 1: MIDDLE
|
||||
// 2: DOWN
|
||||
if (pos >= 3) return "";
|
||||
return _switch_state_str[pos + 1];
|
||||
}
|
||||
|
||||
char *getSwitchPositionName(char *dest, swsrc_t idx)
|
||||
{
|
||||
if (idx == SWSRC_NONE) {
|
||||
@@ -494,26 +520,12 @@ char *getSwitchPositionName(char *dest, swsrc_t idx)
|
||||
#define IDX_TRIMS_IN_STR_VSWITCHES (1)
|
||||
#define IDX_ON_IN_STR_VSWITCHES \
|
||||
(IDX_TRIMS_IN_STR_VSWITCHES + SWSRC_LAST_TRIM - SWSRC_FIRST_TRIM + 1)
|
||||
|
||||
if (idx <= SWSRC_LAST_SWITCH) {
|
||||
div_t swinfo = switchInfo(idx);
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
if (idx >= SWSRC_FIRST_FUNCTION_SWITCH && idx <= (SWSRC_FIRST_FUNCTION_SWITCH + NUM_FUNCTIONS_SWITCHES)) {
|
||||
s = getSwitchName(s, idx);
|
||||
*s++ = (STR_CHAR_UP "-" STR_CHAR_DOWN)[swinfo.rem];
|
||||
*s = '\0';
|
||||
}
|
||||
else {
|
||||
s = getSwitchName(s, idx);
|
||||
*s++ = (STR_CHAR_UP "-" STR_CHAR_DOWN)[swinfo.rem];
|
||||
*s = '\0';
|
||||
}
|
||||
#else
|
||||
s = getSwitchName(s, idx);
|
||||
*s++ = (STR_CHAR_UP "-" STR_CHAR_DOWN)[swinfo.rem];
|
||||
*s = '\0';
|
||||
#endif
|
||||
|
||||
s = getSwitchName(s, idx);
|
||||
s = strAppend(s, getSwitchPositionSymbol(swinfo.rem), 2);
|
||||
*s = '\0';
|
||||
}
|
||||
|
||||
#if NUM_XPOTS > 0
|
||||
|
||||
@@ -76,6 +76,8 @@ char *getFormattedTimerString(char *dest, int32_t tme, TimerOptions timerOptions
|
||||
char *getCurveString(char *dest, int idx);
|
||||
char *getGVarString(char *dest, int idx);
|
||||
char *getGVarString(int idx);
|
||||
const char* getSwitchWarnSymbol(uint8_t pos);
|
||||
const char* getSwitchPositionSymbol(uint8_t pos);
|
||||
char *getSwitchPositionName(char *dest, swsrc_t idx);
|
||||
char *getSwitchName(char *dest, swsrc_t idx);
|
||||
|
||||
|
||||
@@ -746,13 +746,6 @@ void checkSwitches()
|
||||
}
|
||||
#elif defined(GUI)
|
||||
|
||||
static const char* switch_state_str[] {
|
||||
" ",
|
||||
STR_CHAR_UP,
|
||||
"-",
|
||||
STR_CHAR_DOWN,
|
||||
};
|
||||
|
||||
void checkSwitches()
|
||||
{
|
||||
swarnstate_t last_bad_switches = 0xff;
|
||||
@@ -788,7 +781,7 @@ void checkSwitches()
|
||||
((states & mask) == (switches_states & mask)) ? 0 : INVERS;
|
||||
if (attr) {
|
||||
if (++numWarnings < 6) {
|
||||
const char* s = switch_state_str[(states & mask) >> (i * 3)];
|
||||
const char* s = getSwitchWarnSymbol((states & mask) >> (i * 3));
|
||||
drawSource(x, y, MIXSRC_FIRST_SWITCH + i, attr);
|
||||
lcdDrawText(lcdNextPos, y, s, attr);
|
||||
x = lcdNextPos + 3;
|
||||
|
||||
Reference in New Issue
Block a user