feat(color): handle long press enter for pre-flight switch checks (#6282)
This commit is contained in:
@@ -1206,17 +1206,7 @@ void menuModelSetup(event_t event)
|
|||||||
if (menuHorizontalPosition < 0 ||
|
if (menuHorizontalPosition < 0 ||
|
||||||
menuHorizontalPosition >= switchWarningsCount) {
|
menuHorizontalPosition >= switchWarningsCount) {
|
||||||
START_NO_HIGHLIGHT();
|
START_NO_HIGHLIGHT();
|
||||||
getMovedSwitch();
|
setAllPreflightSwitchStates();
|
||||||
// Mask switches enabled for warnings
|
|
||||||
swarnstate_t sw_mask = 0;
|
|
||||||
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
|
|
||||||
if (SWITCH_WARNING_ALLOWED(i))
|
|
||||||
if (g_model.switchWarning & (0x07 << (3 * i)))
|
|
||||||
sw_mask |= (0x07 << (3 * i));
|
|
||||||
}
|
|
||||||
g_model.switchWarning = switches_states & sw_mask;
|
|
||||||
AUDIO_WARNING1();
|
|
||||||
storageDirty(EE_MODEL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -879,17 +879,7 @@ void menuModelSetup(event_t event)
|
|||||||
killEvents(event);
|
killEvents(event);
|
||||||
if (menuHorizontalPosition < 0) {
|
if (menuHorizontalPosition < 0) {
|
||||||
START_NO_HIGHLIGHT();
|
START_NO_HIGHLIGHT();
|
||||||
getMovedSwitch();
|
setAllPreflightSwitchStates();
|
||||||
// Mask switches enabled for warnings
|
|
||||||
swarnstate_t sw_mask = 0;
|
|
||||||
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
|
|
||||||
if (SWITCH_WARNING_ALLOWED(i))
|
|
||||||
if (g_model.switchWarning & (0x07 << (3 * i)))
|
|
||||||
sw_mask |= (0x07 << (3 * i));
|
|
||||||
}
|
|
||||||
g_model.switchWarning = switches_states & sw_mask;
|
|
||||||
AUDIO_WARNING1();
|
|
||||||
storageDirty(EE_MODEL);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,12 @@ static void btnmatrix_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
|
|||||||
{
|
{
|
||||||
etx_obj_add_style(obj, styles->rounded, LV_PART_MAIN);
|
etx_obj_add_style(obj, styles->rounded, LV_PART_MAIN);
|
||||||
etx_obj_add_style(obj, styles->bg_opacity_20,
|
etx_obj_add_style(obj, styles->bg_opacity_20,
|
||||||
LV_PART_MAIN | LV_STATE_FOCUSED);
|
LV_PART_MAIN | LV_STATE_EDITED);
|
||||||
|
|
||||||
etx_bg_color(obj, COLOR_THEME_FOCUS_INDEX, LV_PART_MAIN | LV_STATE_FOCUSED);
|
etx_solid_bg(obj, COLOR_THEME_FOCUS_INDEX, LV_PART_MAIN | LV_STATE_FOCUSED);
|
||||||
|
|
||||||
etx_std_style(obj, LV_PART_ITEMS, PAD_LARGE);
|
etx_std_style(obj, LV_PART_ITEMS, PAD_LARGE);
|
||||||
|
etx_remove_border_color(obj, LV_PART_ITEMS | LV_STATE_FOCUSED);
|
||||||
|
|
||||||
etx_obj_add_style(obj, styles->border_color[COLOR_THEME_FOCUS_INDEX],
|
etx_obj_add_style(obj, styles->border_color[COLOR_THEME_FOCUS_INDEX],
|
||||||
LV_PART_ITEMS | LV_STATE_EDITED);
|
LV_PART_ITEMS | LV_STATE_EDITED);
|
||||||
@@ -82,7 +83,7 @@ ButtonMatrix::ButtonMatrix(Window* parent, const rect_t& r) :
|
|||||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||||
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
lv_obj_clear_flag(lvobj, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||||
|
|
||||||
lv_obj_add_event_cb(lvobj, btn_matrix_event, LV_EVENT_ALL, this);
|
lv_obj_add_event_cb(lvobj, btn_matrix_event, LV_EVENT_VALUE_CHANGED, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonMatrix::~ButtonMatrix() { deallocate(); }
|
ButtonMatrix::~ButtonMatrix() { deallocate(); }
|
||||||
|
|||||||
@@ -47,13 +47,7 @@ class SwitchWarnMatrix : public ButtonMatrix
|
|||||||
|
|
||||||
initBtnMap(min((int)btn_cnt, SW_BTNS), btn_cnt);
|
initBtnMap(min((int)btn_cnt, SW_BTNS), btn_cnt);
|
||||||
|
|
||||||
uint8_t btn_id = 0;
|
setAllState();
|
||||||
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
|
|
||||||
if (SWITCH_WARNING_ALLOWED(i)) {
|
|
||||||
setTextAndState(btn_id);
|
|
||||||
btn_id++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
@@ -65,8 +59,13 @@ class SwitchWarnMatrix : public ButtonMatrix
|
|||||||
padAll(PAD_SMALL);
|
padAll(PAD_SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onPress(uint8_t btn_id)
|
void onPress(uint8_t btn_id) override
|
||||||
{
|
{
|
||||||
|
if (longPress) {
|
||||||
|
longPress = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (btn_id >= MAX_SWITCHES) return;
|
if (btn_id >= MAX_SWITCHES) return;
|
||||||
auto sw = sw_idx[btn_id];
|
auto sw = sw_idx[btn_id];
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ class SwitchWarnMatrix : public ButtonMatrix
|
|||||||
setTextAndState(btn_id);
|
setTextAndState(btn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isActive(uint8_t btn_id)
|
bool isActive(uint8_t btn_id) override
|
||||||
{
|
{
|
||||||
if (btn_id >= MAX_SWITCHES) return false;
|
if (btn_id >= MAX_SWITCHES) return false;
|
||||||
return bfGet(g_model.switchWarning, 3 * sw_idx[btn_id], 3) != 0;
|
return bfGet(g_model.switchWarning, 3 * sw_idx[btn_id], 3) != 0;
|
||||||
@@ -105,6 +104,26 @@ class SwitchWarnMatrix : public ButtonMatrix
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t sw_idx[MAX_SWITCHES];
|
uint8_t sw_idx[MAX_SWITCHES];
|
||||||
|
bool longPress = false;
|
||||||
|
|
||||||
|
void setAllState()
|
||||||
|
{
|
||||||
|
uint8_t btn_id = 0;
|
||||||
|
for (uint8_t i = 0; i < MAX_SWITCHES; i++) {
|
||||||
|
if (SWITCH_WARNING_ALLOWED(i)) {
|
||||||
|
setTextAndState(btn_id);
|
||||||
|
btn_id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool onLongPress() override
|
||||||
|
{
|
||||||
|
longPress = true;
|
||||||
|
setAllPreflightSwitchStates();
|
||||||
|
setAllState();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PotWarnMatrix : public ButtonMatrix
|
class PotWarnMatrix : public ButtonMatrix
|
||||||
|
|||||||
@@ -1213,3 +1213,18 @@ void logicalSwitchesCopyState(uint8_t src, uint8_t dst)
|
|||||||
{
|
{
|
||||||
lswFm[dst] = lswFm[src];
|
lswFm[dst] = lswFm[src];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setAllPreflightSwitchStates()
|
||||||
|
{
|
||||||
|
getMovedSwitch();
|
||||||
|
// Mask switches enabled for warnings
|
||||||
|
swarnstate_t sw_mask = 0;
|
||||||
|
for(uint8_t i = 0; i < switchGetMaxSwitches(); i++) {
|
||||||
|
if (SWITCH_WARNING_ALLOWED(i))
|
||||||
|
if (g_model.switchWarning & (0x07 << (3 * i)))
|
||||||
|
sw_mask |= (0x07 << (3 * i));
|
||||||
|
}
|
||||||
|
g_model.switchWarning = switches_states & sw_mask;
|
||||||
|
AUDIO_WARNING1();
|
||||||
|
storageDirty(EE_MODEL);
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,3 +111,5 @@ void fsLedRGB(uint8_t, uint32_t color);
|
|||||||
uint32_t fsGetLedRGB(uint8_t index);
|
uint32_t fsGetLedRGB(uint8_t index);
|
||||||
uint8_t getRGBColorIndex(uint32_t color);
|
uint8_t getRGBColorIndex(uint32_t color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void setAllPreflightSwitchStates();
|
||||||
|
|||||||
Reference in New Issue
Block a user