diff --git a/src/eez/gui/page.cpp b/src/eez/gui/page.cpp index 1ec369689..65b36aec6 100644 --- a/src/eez/gui/page.cpp +++ b/src/eez/gui/page.cpp @@ -45,12 +45,10 @@ void Page::pageFree() { void Page::pageWillAppear() { } -bool Page::onEncoder(int counter) { - return false; +void Page::onEncoder(int counter) { } -bool Page::onEncoderClicked() { - return false; +void Page::onEncoderClicked() { } Unit Page::getEncoderUnit() { @@ -188,14 +186,18 @@ ToastMessagePage *ToastMessagePage::create(ToastType type, const char *message, return page; } -bool ToastMessagePage::onEncoder(int counter) { - popPage(); - return false; +void ToastMessagePage::onEncoder(int counter) { + if (counter < 0) { + popPage(); + } } -bool ToastMessagePage::onEncoderClicked() { - popPage(); - return false; +void ToastMessagePage::onEncoderClicked() { + if (hasAction()) { + eez::gui::executeAction((int)(int16_t)actionWidget.action); + } else { + popPage(); + } } void ToastMessagePage::refresh(const WidgetCursor& widgetCursor) { diff --git a/src/eez/gui/page.h b/src/eez/gui/page.h index efa42b30a..96afc262a 100644 --- a/src/eez/gui/page.h +++ b/src/eez/gui/page.h @@ -36,8 +36,8 @@ class Page { virtual void pageWillAppear(); - virtual bool onEncoder(int counter); - virtual bool onEncoderClicked(); + virtual void onEncoder(int counter); + virtual void onEncoderClicked(); virtual Unit getEncoderUnit(); virtual int getDirty(); @@ -89,8 +89,8 @@ class ToastMessagePage : public InternalPage { void pageFree(); - bool onEncoder(int counter); - bool onEncoderClicked(); + void onEncoder(int counter); + void onEncoderClicked(); void refresh(const WidgetCursor& widgetCursor); void updatePage(const WidgetCursor& widgetCursor); diff --git a/src/eez/modules/psu/gui/numeric_keypad.cpp b/src/eez/modules/psu/gui/numeric_keypad.cpp index 899e4cf40..18c4bf47a 100644 --- a/src/eez/modules/psu/gui/numeric_keypad.cpp +++ b/src/eez/modules/psu/gui/numeric_keypad.cpp @@ -579,26 +579,24 @@ void NumericKeypad::cancel() { #if OPTION_ENCODER -bool NumericKeypad::onEncoderClicked() { +void NumericKeypad::onEncoderClicked() { if (m_state == START) { if (getActivePageId() == PAGE_ID_EDIT_MODE_KEYPAD) { - return false; + return; } } ok(); - return true; } -bool NumericKeypad::onEncoder(int counter) { +void NumericKeypad::onEncoder(int counter) { if (m_state == START) { if (getActivePageId() == PAGE_ID_EDIT_MODE_KEYPAD) { - return false; + return; } if (m_startValue.getType() == VALUE_TYPE_FLOAT) { float newValue = mcu::encoder::increment(m_startValue, counter, m_options.min, m_options.max, m_options.channelIndex, 0.01f); m_startValue = MakeValue(newValue, m_startValue.getUnit()); - return true; } else if (m_startValue.getType() == VALUE_TYPE_INT) { int newValue = m_startValue.getInt() + counter; @@ -611,13 +609,10 @@ bool NumericKeypad::onEncoder(int counter) { } m_startValue = data::Value(newValue); - - return true; } } sound::playBeep(); - return true; } #endif diff --git a/src/eez/modules/psu/gui/numeric_keypad.h b/src/eez/modules/psu/gui/numeric_keypad.h index b0878bff4..9e9831655 100644 --- a/src/eez/modules/psu/gui/numeric_keypad.h +++ b/src/eez/modules/psu/gui/numeric_keypad.h @@ -110,8 +110,8 @@ class NumericKeypad : public Keypad { void cancel(); #if OPTION_ENCODER - bool onEncoderClicked(); - bool onEncoder(int counter); + void onEncoderClicked(); + void onEncoder(int counter); #endif Unit getSwitchToUnit(); diff --git a/src/eez/modules/psu/gui/page_ch_settings_trigger.cpp b/src/eez/modules/psu/gui/page_ch_settings_trigger.cpp index acc5aec8e..808c29f32 100644 --- a/src/eez/modules/psu/gui/page_ch_settings_trigger.cpp +++ b/src/eez/modules/psu/gui/page_ch_settings_trigger.cpp @@ -481,7 +481,7 @@ void ChSettingsListsPage::set() { } } -bool ChSettingsListsPage::onEncoder(int counter) { +void ChSettingsListsPage::onEncoder(int counter) { #if OPTION_ENCODER data::Cursor cursor(getCursorIndexWithinPage()); uint16_t dataId = getDataIdAtCursor(); @@ -497,32 +497,29 @@ bool ChSettingsListsPage::onEncoder(int counter) { float newValue = mcu::encoder::increment(value, counter, min.getFloat(), max.getFloat(), g_channel->channelIndex, 0); setFocusedValue(newValue); - - return true; #endif - return false; } -bool ChSettingsListsPage::onEncoderClicked() { +void ChSettingsListsPage::onEncoderClicked() { uint16_t dataId = getDataIdAtCursor(); int iRow = getRowIndex(); if (dataId == DATA_ID_CHANNEL_LIST_DWELL) { if (iRow <= m_voltageListLength) { m_iCursor += 1; - return true; + return; } if (iRow <= m_currentListLength) { m_iCursor += 2; - return true; + return; } m_iCursor += 3; } else if (dataId == DATA_ID_CHANNEL_LIST_VOLTAGE) { if (iRow <= m_currentListLength) { m_iCursor += 1; - return true; + return; } m_iCursor += 2; @@ -531,8 +528,6 @@ bool ChSettingsListsPage::onEncoderClicked() { } moveCursorToFirstAvailableCell(); - - return true; } Unit ChSettingsListsPage::getEncoderUnit() { diff --git a/src/eez/modules/psu/gui/page_ch_settings_trigger.h b/src/eez/modules/psu/gui/page_ch_settings_trigger.h index 1550b10f8..e797cf7d6 100644 --- a/src/eez/modules/psu/gui/page_ch_settings_trigger.h +++ b/src/eez/modules/psu/gui/page_ch_settings_trigger.h @@ -68,8 +68,8 @@ class ChSettingsListsPage : public SetPage { int getDirty(); void set(); - bool onEncoder(int counter); - bool onEncoderClicked(); + void onEncoder(int counter); + void onEncoderClicked(); Unit getEncoderUnit(); void showInsertMenu(); diff --git a/src/eez/modules/psu/gui/psu.cpp b/src/eez/modules/psu/gui/psu.cpp index b690b5cb3..efcf03e38 100644 --- a/src/eez/modules/psu/gui/psu.cpp +++ b/src/eez/modules/psu/gui/psu.cpp @@ -1210,38 +1210,21 @@ void onEncoder(int counter, bool clicked) { int activePageId = getActivePageId(); if (activePageId == PAGE_ID_EDIT_MODE_KEYPAD || activePageId == PAGE_ID_NUMERIC_KEYPAD) { - if (((NumericKeypad *)getActiveKeypad())->onEncoder(counter)) { - return; - } + ((NumericKeypad *)getActiveKeypad())->onEncoder(counter); } - #if defined(EEZ_PLATFORM_SIMULATOR) - if (activePageId == PAGE_ID_FRONT_PANEL_NUMERIC_KEYPAD) { - if (((NumericKeypad *)getActiveKeypad())->onEncoder(counter)) { - return; - } + else if (activePageId == PAGE_ID_FRONT_PANEL_NUMERIC_KEYPAD) { + ((NumericKeypad *)getActiveKeypad())->onEncoder(counter); } #endif - - if (activePageId == PAGE_ID_EDIT_MODE_STEP) { + else if (activePageId == PAGE_ID_EDIT_MODE_STEP) { edit_mode_step::onEncoder(counter); - return; - } - - if (activePageId == PAGE_ID_FILE_MANAGER) { + } else if (activePageId == PAGE_ID_FILE_MANAGER) { file_manager::onEncoder(counter); - return; - } - - if (activePageId == PAGE_ID_DEBUG_TRACE_LOG) { + } else if (activePageId == PAGE_ID_DEBUG_TRACE_LOG) { eez::debug::onEncoder(counter); - return; - } - - if (activePage) { - if (activePage->onEncoder(counter)) { - return; - } + } else if (activePage) { + activePage->onEncoder(counter); } } @@ -1260,26 +1243,18 @@ void onEncoder(int counter, bool clicked) { } sound::playClick(); - } - - int activePageId = getActivePageId(); - if (activePageId == PAGE_ID_EDIT_MODE_KEYPAD || activePageId == PAGE_ID_NUMERIC_KEYPAD) { - if (((NumericKeypad *)getActiveKeypad())->onEncoderClicked()) { - return; + } else { + int activePageId = getActivePageId(); + if (activePageId == PAGE_ID_EDIT_MODE_KEYPAD || activePageId == PAGE_ID_NUMERIC_KEYPAD) { + ((NumericKeypad *)getActiveKeypad())->onEncoderClicked(); } - } - #if defined(EEZ_PLATFORM_SIMULATOR) - if (activePageId == PAGE_ID_FRONT_PANEL_NUMERIC_KEYPAD) { - if (((NumericKeypad *)getActiveKeypad())->onEncoderClicked()) { - return; + else if (activePageId == PAGE_ID_FRONT_PANEL_NUMERIC_KEYPAD) { + ((NumericKeypad *)getActiveKeypad())->onEncoderClicked(); } - } #endif - - if (activePage) { - if (activePage->onEncoderClicked()) { - return; + else if (activePage) { + activePage->onEncoderClicked(); } } }