@@ -56,9 +56,33 @@
|
||||
#include "coloredit.h"
|
||||
#include "draw_functions.h"
|
||||
|
||||
inline void POPUP_INFORMATION(const char * str)
|
||||
inline MessageDialog * createPopupInformation(const char * message)
|
||||
{
|
||||
new MessageDialog(&mainWindow, "Message", str);
|
||||
return new MessageDialog(&mainWindow, "Message", message);
|
||||
}
|
||||
|
||||
inline MessageDialog * createPopupWarning(const char * message)
|
||||
{
|
||||
return new MessageDialog(&mainWindow, "Warning", message);
|
||||
}
|
||||
|
||||
inline void POPUP_INFORMATION(const char * message)
|
||||
{
|
||||
auto popup = createPopupInformation(message);
|
||||
while (popup->getParent()) {
|
||||
mainWindow.run(false);
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
mainWindow.run(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _LIBOPENUI_H_
|
||||
|
||||
@@ -322,10 +322,7 @@ extern void (* popupFunc)(event_t event);
|
||||
extern uint8_t warningInfoFlags;
|
||||
|
||||
#define DISPLAY_WARNING(evt) (*popupFunc)(evt)
|
||||
#define POPUP_WARNING(s) (warningType = WARNING_TYPE_ASTERISK, warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
|
||||
#define POPUP_INPUT(s, func) (warningText = s, popupFunc = func)
|
||||
#define SET_WARNING_INFO(info, len, flags) (warningInfoText = info, warningInfoLength = len, warningInfoFlags = flags)
|
||||
|
||||
#define POPUP_MENU_MAX_LINES 12
|
||||
#define MENU_MAX_DISPLAY_LINES 9
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
#include "message_dialog.h"
|
||||
#include "static.h"
|
||||
|
||||
MessageDialog::MessageDialog(Window * parent, const char * title, const char * message):
|
||||
MessageDialog::MessageDialog(Window * parent, const char * title, const char * message, const char * info):
|
||||
Dialog(parent, title, {50, 73, LCD_W - 100, LCD_H - 146})
|
||||
{
|
||||
new StaticText(this, {0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT}, message, 0, CENTERED);
|
||||
messageWidget = new StaticText(this, {0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT}, message, 0, CENTERED);
|
||||
infoWidget = new StaticText(this, {0, 30 + coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT}, info, 0, CENTERED);
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
|
||||
@@ -21,10 +21,20 @@
|
||||
#define _MESSAGE_DIALOG_H_
|
||||
|
||||
#include "dialog.h"
|
||||
#include "static.h"
|
||||
|
||||
class MessageDialog: public Dialog {
|
||||
public:
|
||||
MessageDialog(Window * parent, const char * title, const char * message);
|
||||
MessageDialog(Window * parent, const char * title, const char * message, const char * info = "");
|
||||
|
||||
void setInfoText(std::string text)
|
||||
{
|
||||
infoWidget->setText(std::move(text));
|
||||
}
|
||||
|
||||
protected:
|
||||
StaticText * messageWidget;
|
||||
StaticText * infoWidget;
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "libopenui.h"
|
||||
#include "io/frsky_firmware_update.h"
|
||||
#include "io/multi_firmware_update.h"
|
||||
#include "io/bootloader_flash.h"
|
||||
|
||||
RadioSdManagerPage::RadioSdManagerPage() :
|
||||
PageTab(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, ICON_RADIO_SD_MANAGER)
|
||||
@@ -86,16 +87,22 @@ class FilePreview : public Window
|
||||
BitmapBuffer *bitmap = nullptr;
|
||||
};
|
||||
|
||||
class FlashModuleDialog: public FullScreenDialog
|
||||
template <class T>
|
||||
class FlashDialog: public FullScreenDialog
|
||||
{
|
||||
public:
|
||||
explicit FlashModuleDialog(ModuleIndex module):
|
||||
explicit FlashDialog(ModuleIndex module):
|
||||
FullScreenDialog(WARNING_TYPE_INFO, "Flash device"),
|
||||
device(module),
|
||||
progress(this, {100, 100, 100, 15})
|
||||
progress(this, {LCD_W / 2 - 50, LCD_H / 2, 100, 15})
|
||||
{
|
||||
}
|
||||
|
||||
~FlashDialog() override
|
||||
{
|
||||
progress.detach();
|
||||
}
|
||||
|
||||
void flash(const char * filename)
|
||||
{
|
||||
device.flashFirmware(filename, [=](const char * title, const char * message, int count, int total) -> void {
|
||||
@@ -107,7 +114,7 @@ class FlashModuleDialog: public FullScreenDialog
|
||||
}
|
||||
|
||||
protected:
|
||||
FrskyDeviceFirmwareUpdate device;
|
||||
T device;
|
||||
Progress progress;
|
||||
};
|
||||
|
||||
@@ -175,11 +182,13 @@ void RadioSdManagerPage::build(FormWindow * window)
|
||||
if (information.readMultiFirmwareInformation(name.data()) == nullptr) {
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
menu->addLine(STR_FLASH_INTERNAL_MULTI, [=]() {
|
||||
// TODO
|
||||
auto dialog = new FlashDialog<MultiDeviceFirmwareUpdate>(INTERNAL_MODULE);
|
||||
dialog->flash(getFullPath(name));
|
||||
});
|
||||
#endif
|
||||
menu->addLine(STR_FLASH_EXTERNAL_MULTI, [=]() {
|
||||
// TODO
|
||||
auto dialog = new FlashDialog<MultiDeviceFirmwareUpdate>(EXTERNAL_MODULE);
|
||||
dialog->flash(getFullPath(name));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -195,23 +204,24 @@ void RadioSdManagerPage::build(FormWindow * window)
|
||||
if (!READ_ONLY() && !strcasecmp(ext, FIRMWARE_EXT)) {
|
||||
if (isBootloader(name.data())) {
|
||||
menu->addLine(STR_FLASH_BOOTLOADER, [=]() {
|
||||
// TODO
|
||||
auto dialog = new FlashDialog<BootloaderDeviceFirmwareUpdate>(BOOTLOADER_MODULE);
|
||||
dialog->flash(getFullPath(name));
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (!READ_ONLY() && !strcasecmp(ext, SPORT_FIRMWARE_EXT)) {
|
||||
if (HAS_SPORT_UPDATE_CONNECTOR()) {
|
||||
menu->addLine(STR_FLASH_EXTERNAL_DEVICE, [=]() {
|
||||
auto dialog = new FlashModuleDialog(SPORT_MODULE);
|
||||
auto dialog = new FlashDialog<FrskyDeviceFirmwareUpdate>(SPORT_MODULE);
|
||||
dialog->flash(getFullPath(name));
|
||||
});
|
||||
}
|
||||
menu->addLine(STR_FLASH_INTERNAL_MODULE, [=]() {
|
||||
auto dialog = new FlashModuleDialog(INTERNAL_MODULE);
|
||||
auto dialog = new FlashDialog<FrskyDeviceFirmwareUpdate>(INTERNAL_MODULE);
|
||||
dialog->flash(getFullPath(name));
|
||||
});
|
||||
menu->addLine(STR_FLASH_EXTERNAL_MODULE, [=]() {
|
||||
auto dialog = new FlashModuleDialog(EXTERNAL_MODULE);
|
||||
auto dialog = new FlashDialog<FrskyDeviceFirmwareUpdate>(EXTERNAL_MODULE);
|
||||
dialog->flash(getFullPath(name));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ enum
|
||||
#if !defined(GUI)
|
||||
#define DISPLAY_WARNING(...)
|
||||
inline void POPUP_WAIT(const char * s) { }
|
||||
inline void POPUP_WARNING(const char * s) { }
|
||||
inline void POPUP_WARNING(const char *, const char * = nullptr) { }
|
||||
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler) { }
|
||||
inline void POPUP_INPUT(const char * s, PopupFunc func) { }
|
||||
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags) { }
|
||||
@@ -103,14 +103,23 @@ enum
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
inline void POPUP_WARNING(const char * s)
|
||||
inline void POPUP_WARNING(const char * message, const char * info = nullptr)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningText = message;
|
||||
warningInfoText = info;
|
||||
warningInfoLength = strlen(info);
|
||||
warningInfoFlags = 0;
|
||||
warningType = WARNING_TYPE_ASTERISK;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags)
|
||||
{
|
||||
warningInfoText = info;
|
||||
warningInfoLength = length;
|
||||
warningInfoFlags = flags;
|
||||
}
|
||||
|
||||
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler)
|
||||
{
|
||||
if (s != warningText) {
|
||||
@@ -131,13 +140,6 @@ enum
|
||||
popupFunc = func;
|
||||
}
|
||||
|
||||
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags)
|
||||
{
|
||||
warningInfoText = info;
|
||||
warningInfoLength = length;
|
||||
warningInfoFlags = flags;
|
||||
}
|
||||
|
||||
inline bool isEventCaughtByPopup()
|
||||
{
|
||||
if (warningText && warningType != WARNING_TYPE_WAIT)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "opentx.h"
|
||||
#include "io/frsky_firmware_update.h"
|
||||
#include "io/multi_firmware_update.h"
|
||||
#include "io/bootloader_flash.h"
|
||||
#include "libopenui/src/libopenui_file.h"
|
||||
|
||||
#define NODE_TYPE(fname) fname[SD_SCREEN_FILE_LENGTH+1]
|
||||
@@ -203,7 +204,8 @@ void onSdManagerMenu(const char * result)
|
||||
#if defined(PCBTARANIS)
|
||||
else if (result == STR_FLASH_BOOTLOADER) {
|
||||
getSelectionFullPath(lfn);
|
||||
bootloaderFlash(lfn);
|
||||
BootloaderDeviceFirmwareUpdate device(BOOTLOADER_MODULE);
|
||||
device.flashFirmware(lfn, drawProgressScreen);
|
||||
}
|
||||
else if (result == STR_FLASH_INTERNAL_MODULE) {
|
||||
getSelectionFullPath(lfn);
|
||||
@@ -225,12 +227,14 @@ void onSdManagerMenu(const char * result)
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
else if (result == STR_FLASH_INTERNAL_MULTI) {
|
||||
getSelectionFullPath(lfn);
|
||||
multiFlashFirmware(INTERNAL_MODULE, lfn);
|
||||
MultiDeviceFirmwareUpdate device(INTERNAL_MODULE);
|
||||
device.flashFirmware(lfn, drawProgressScreen);
|
||||
}
|
||||
#endif
|
||||
else if (result == STR_FLASH_EXTERNAL_MULTI) {
|
||||
getSelectionFullPath(lfn);
|
||||
multiFlashFirmware(EXTERNAL_MODULE, lfn);
|
||||
MultiDeviceFirmwareUpdate device(EXTERNAL_MODULE);
|
||||
device.flashFirmware(lfn, drawProgressScreen);
|
||||
}
|
||||
#endif
|
||||
#if defined(BLUETOOTH)
|
||||
|
||||
Reference in New Issue
Block a user