Skip to content

Commit

Permalink
Handle preview events the same way as any other event.
Browse files Browse the repository at this point in the history
  • Loading branch information
herm committed Oct 22, 2021
1 parent eead2fb commit a33d291
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions software/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ static void ui_select(uint8_t event, const MenuItem *item, uint8_t display)
The child handler is called to update the bottom display. */
void ui_submenu(uint8_t event, const MenuItem *item)
{
if (event & EVENT_PREVIEW) {
if (event == EVENT_PREVIEW) {
// Show nothing as preview (this menu's name is shown in top display by parent item's handler)
ui_text(" ", DP_BOT);
return;
}

ui_select(event, item, DP_TOP);
if (current_subitem->handler) {
current_subitem->handler(event | EVENT_PREVIEW, current_subitem);
current_subitem->handler(EVENT_PREVIEW, current_subitem);
} else {
ui_text("===", DP_BOT); //Show warning that no handler is defined (makes no sense for ui_submenu!)
}
Expand Down Expand Up @@ -320,7 +320,7 @@ static uint8_t ui_find_active_subitem(const MenuItem *item)
Very similar to ui_submenu, but selection happens in the bottom menu and no subitem preview is shown (only the caption). */
void ui_select_item(uint8_t event, const MenuItem *item)
{
if (event & EVENT_PREVIEW) {
if (event == EVENT_PREVIEW) {
// Show selected value in bottom display as preview
ui_text(item->subitems[ui_find_active_subitem(item)]->caption, DP_BOT);
return;
Expand Down Expand Up @@ -350,7 +350,7 @@ void ui_edit_value_internal(uint8_t event, const NumericEdit *edit, uint8_t leds
{
static uint16_t value;
uint8_t display = DP_BOT, display2 = DP_TOP;
if (event & EVENT_PREVIEW) {
if (event == EVENT_PREVIEW) {
ui_number(*edit->var, edit->dot_offset, display);
return;
}
Expand Down Expand Up @@ -454,7 +454,7 @@ void ui_edit_setpoint(uint8_t event, const MenuItem *item)
label = "===";
break;
}
if (!(event & EVENT_PREVIEW)) ui_text(label, DP_TOP);
if (event != EVENT_PREVIEW) ui_text(label, DP_TOP);
if (edit) ui_edit_value_internal(event, edit, leds);
}

Expand Down Expand Up @@ -530,7 +530,7 @@ void ui_show_values(uint8_t event)
/* Shared code from run and info mode */
static void ui_run_info_mode(uint8_t event)
{
if (event & EVENT_PREVIEW) {
if (event == EVENT_PREVIEW) {
// Show nothing as preview (this menu's name is shown in top display by parent item's handler)
ui_text(" ", DP_BOT);
return;
Expand Down Expand Up @@ -580,7 +580,7 @@ void ui_clear_counters(uint8_t event, const MenuItem *item)
{
static uint8_t timer = 0;
(void) item; // unused
if (event & EVENT_PREVIEW) {
if (event == EVENT_PREVIEW) {
// Show nothing as preview (this menu's name is shown in top display by parent item's handler)
ui_text("CNT", DP_BOT);
return;
Expand Down

0 comments on commit a33d291

Please sign in to comment.