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