fix(yaml): flex switch warnings (#4949)

Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <neilh713@tpg.com.au>
This commit is contained in:
Raphael Coeffic
2024-05-03 13:14:50 +10:00
committed by GitHub
co-authored by raphaelcoeffic 3djc elecpower
parent dd87ecb89a
commit 0d6ce7d22d
22 changed files with 174 additions and 101 deletions
+5 -5
View File
@@ -975,7 +975,7 @@ void menuModelSetup(event_t event)
break;
}
swarnstate_t states = g_model.switchWarningState;
swarnstate_t states = g_model.switchWarning;
lcdDrawTextAlignedLeft(y, STR_SWITCHWARNING);
#if defined(PCBXLITE)
@@ -1003,10 +1003,10 @@ void menuModelSetup(event_t event)
swarnstate_t sw_mask = 0;
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i))
if (g_model.switchWarningState & (0x07 << (3 * i)))
if (g_model.switchWarning & (0x07 << (3 * i)))
sw_mask |= (0x07 << (3 * i));
}
g_model.switchWarningState = switches_states & sw_mask;
g_model.switchWarning = switches_states & sw_mask;
AUDIO_WARNING1();
storageDirty(EE_MODEL);
}
@@ -1024,10 +1024,10 @@ void menuModelSetup(event_t event)
l_posHorz == current && old_posHorz >= 0) {
uint8_t curr_state = (states & 0x07);
// remove old setting
g_model.switchWarningState &= ~(0x07 << (3 * i));
g_model.switchWarning &= ~(0x07 << (3 * i));
// add the new one (if switch UP and 2POS, jump directly to DOWN)
curr_state += (curr_state != 1 || IS_CONFIG_3POS(i) ? 1 : 2);
g_model.switchWarningState |= (curr_state & 0x03) << (3 * i);
g_model.switchWarning |= (curr_state & 0x03) << (3 * i);
storageDirty(EE_MODEL);
#if defined(PCBXLITE)
s_editMode = 0;
+5 -5
View File
@@ -872,7 +872,7 @@ void menuModelSetup(event_t event)
}
#endif
lcdDrawTextAlignedLeft(y, STR_SWITCHWARNING);
swarnstate_t states = g_model.switchWarningState;
swarnstate_t states = g_model.switchWarning;
if (attr) {
s_editMode = 0;
@@ -889,10 +889,10 @@ void menuModelSetup(event_t event)
swarnstate_t sw_mask = 0;
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
if (SWITCH_WARNING_ALLOWED(i))
if (g_model.switchWarningState & (0x07 << (3 * i)))
if (g_model.switchWarning & (0x07 << (3 * i)))
sw_mask |= (0x07 << (3 * i));
}
g_model.switchWarningState = switches_states & sw_mask;
g_model.switchWarning = switches_states & sw_mask;
AUDIO_WARNING1();
storageDirty(EE_MODEL);
}
@@ -912,10 +912,10 @@ void menuModelSetup(event_t event)
l_posHorz == current) {
uint8_t curr_state = (states & 0x07);
// remove old setting
g_model.switchWarningState &= ~(0x07 << (3 * i));
g_model.switchWarning &= ~(0x07 << (3 * i));
// add the new one (if switch UP and 2POS, jump directly to DOWN)
curr_state += (curr_state != 1 || IS_CONFIG_3POS(i) ? 1 : 2);
g_model.switchWarningState |= (curr_state & 0x03) << (3 * i);
g_model.switchWarning |= (curr_state & 0x03) << (3 * i);
storageDirty(EE_MODEL);
}
lcdDrawChar(
+5 -5
View File
@@ -188,7 +188,7 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP)
static std::string switchWarninglabel(swsrc_t index)
{
auto warn_pos = g_model.switchWarningState >> (3 * index) & 0x07;
auto warn_pos = g_model.switchWarning >> (3 * index) & 0x07;
return std::string(switchGetName(index)) +
std::string(getSwitchWarnSymbol(warn_pos));
}
@@ -244,14 +244,14 @@ void SwitchWarnMatrix::onPress(uint8_t btn_id)
if (btn_id >= MAX_SWITCHES) return;
auto sw = sw_idx[btn_id];
swarnstate_t newstate = bfGet(g_model.switchWarningState, 3 * sw, 3);
swarnstate_t newstate = bfGet(g_model.switchWarning, 3 * sw, 3);
if (newstate == 1 && SWITCH_CONFIG(sw) != SWITCH_3POS)
newstate = 3;
else
newstate = (newstate + 1) % 4;
g_model.switchWarningState =
bfSet(g_model.switchWarningState, newstate, 3 * sw, 3);
g_model.switchWarning =
bfSet(g_model.switchWarning, newstate, 3 * sw, 3);
SET_DIRTY();
setTextAndState(btn_id);
@@ -260,7 +260,7 @@ void SwitchWarnMatrix::onPress(uint8_t btn_id)
bool SwitchWarnMatrix::isActive(uint8_t btn_id)
{
if (btn_id >= MAX_SWITCHES) return false;
return bfGet(g_model.switchWarningState, 3 * sw_idx[btn_id], 3) != 0;
return bfGet(g_model.switchWarning, 3 * sw_idx[btn_id], 3) != 0;
}
PotWarnMatrix::PotWarnMatrix(Window* parent, const rect_t& r) :
@@ -59,7 +59,7 @@ void SwitchWarnDialog::checkEvents()
FullScreenDialog::checkEvents();
std::string warn_txt;
swarnstate_t states = g_model.switchWarningState;
swarnstate_t states = g_model.switchWarning;
for (int i = 0; i < MAX_SWITCHES; ++i) {
if (SWITCH_WARNING_ALLOWED(i)) {
swarnstate_t mask = ((swarnstate_t)0x07 << (i * 3));