diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index fd2c97cae..08c87bbf6 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -161,6 +161,7 @@ add_definitions(-DLIBOPENUI) add_gui_src(fullscreen_dialog.cpp) add_gui_src(message_dialog.cpp) add_gui_src(confirm_dialog.cpp) +add_gui_src(popups.cpp) add_gui_src(timeedit.cpp) add_gui_src(curve.cpp) add_gui_src(sourcechoice.cpp) diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index 2dcdb5148..3e651de62 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -332,6 +332,12 @@ LvglWrapper::LvglWrapper() window->setActiveScreen(); } +LvglWrapper* LvglWrapper::instance() +{ + if (!_instance) _instance = new LvglWrapper(); + return _instance; +} + void LvglWrapper::run() { #if defined(SIMU) @@ -341,3 +347,11 @@ void LvglWrapper::run() #endif lv_timer_handler(); } + +void LvglWrapper::pollInputs() +{ + lv_indev_t* indev = nullptr; + while((indev = lv_indev_get_next(indev)) != nullptr) { + lv_indev_read_timer_cb(indev->driver->read_timer); + } +} diff --git a/radio/src/gui/colorlcd/LvglWrapper.h b/radio/src/gui/colorlcd/LvglWrapper.h index 2057303fd..5e7ba903d 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.h +++ b/radio/src/gui/colorlcd/LvglWrapper.h @@ -61,22 +61,19 @@ class LvglWidgetFactory bool styleInitialized; }; -class LvglWrapper { -public: +class LvglWrapper +{ + public: + static LvglWrapper* instance(); + + void run(); + void pollInputs(); + + private: LvglWrapper(); ~LvglWrapper() {} - static LvglWrapper* instance() - { - if (!_instance) - _instance = new LvglWrapper(); - - return _instance; - } - void run(); - -private: - static LvglWrapper* _instance; + static LvglWrapper *_instance; tmr10ms_t lastTick = 0; }; diff --git a/radio/src/gui/colorlcd/popups.cpp b/radio/src/gui/colorlcd/popups.cpp new file mode 100644 index 000000000..4d6313b63 --- /dev/null +++ b/radio/src/gui/colorlcd/popups.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) EdgeTX + * + * Based on code named + * opentx - https://github.com/opentx/opentx + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "popups.h" +#include "libopenui.h" + +static MessageDialog * createPopupInformation(const char * message) +{ + return new MessageDialog(MainWindow::instance(), "Message", message); +} + +static MessageDialog * createPopupWarning(const char * message) +{ + return new MessageDialog(MainWindow::instance(), "Warning", message); +} + +void POPUP_INFORMATION(const char * message) +{ + auto popup = createPopupInformation(message); + while (popup->getParent()) { + WDG_RESET(); + lv_refr_now(nullptr); + LvglWrapper::instance()->pollInputs(); + RTOS_WAIT_MS(20); + } +} + +void POPUP_WARNING(const char * message, const char * info) +{ + auto popup = createPopupWarning(message); + if (info) { + popup->setInfoText(std::string(info)); + } + while (popup->getParent()) { + WDG_RESET(); + lv_refr_now(nullptr); + LvglWrapper::instance()->pollInputs(); + RTOS_WAIT_MS(20); + } +} diff --git a/radio/src/gui/colorlcd/popups.h b/radio/src/gui/colorlcd/popups.h index ee7e7afaa..2b4cd5cbc 100644 --- a/radio/src/gui/colorlcd/popups.h +++ b/radio/src/gui/colorlcd/popups.h @@ -19,45 +19,11 @@ * GNU General Public License for more details. */ -#ifndef _POPUPS_H_ -#define _POPUPS_H_ +#pragma once -#include "libopenui.h" #include typedef std::function ProgressHandler; -inline MessageDialog * createPopupInformation(const char * message) -{ - return new MessageDialog(MainWindow::instance(), "Message", message); -} - -inline MessageDialog * createPopupWarning(const char * message) -{ - return new MessageDialog(MainWindow::instance(), "Warning", message); -} - -inline void POPUP_INFORMATION(const char * message) -{ - auto popup = createPopupInformation(message); - while (popup->getParent()) { - WDG_RESET(); - MainWindow::instance()->run(false); - LvglWrapper::instance()->run(); - } -} - -inline void POPUP_WARNING(const char * message, const char * info = nullptr) -{ - auto popup = createPopupWarning(message); - if (info) { - popup->setInfoText(std::string(info)); - } - while (popup->getParent()) { - WDG_RESET(); - MainWindow::instance()->run(false); - LvglWrapper::instance()->run(); - } -} - -#endif // _POPUPS_H_ +void POPUP_INFORMATION(const char * message); +void POPUP_WARNING(const char * message, const char * info = nullptr); diff --git a/radio/src/gui/colorlcd/radio_sdmanager.cpp b/radio/src/gui/colorlcd/radio_sdmanager.cpp index 83b8d2818..d2b1e178a 100644 --- a/radio/src/gui/colorlcd/radio_sdmanager.cpp +++ b/radio/src/gui/colorlcd/radio_sdmanager.cpp @@ -138,8 +138,7 @@ class FlashDialog: public FullScreenDialog int total) -> void { setMessage(message); progress.setValue(total > 0 ? count * 100 / total : 0); - MainWindow::instance()->run(false); - LvglWrapper::instance()->run(); + lv_refr_now(nullptr); }); deleteLater(); } diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index c665709b5..78258004f 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit c665709b5121192c555e50199c689cfbf6a05574 +Subproject commit 78258004fe624d624029aefdb2ae40053b23a8e5