Progress screen refactoring
This commit is contained in:
@@ -20,16 +20,49 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
|
||||
void (*popupFunc)(event_t event) = NULL;
|
||||
const char * warningText = NULL;
|
||||
const char * warningInfoText;
|
||||
uint8_t warningInfoLength;
|
||||
uint8_t warningType;
|
||||
uint8_t warningResult = 0;
|
||||
uint8_t warningInfoFlags = ZCHAR;
|
||||
|
||||
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
|
||||
void (* popupFunc)(event_t event) = NULL;
|
||||
|
||||
const char * popupMenuItems[POPUP_MENU_MAX_LINES];
|
||||
uint8_t s_menu_item = 0;
|
||||
uint16_t popupMenuItemsCount = 0;
|
||||
uint16_t popupMenuOffset = 0;
|
||||
void (* popupMenuHandler)(const char * result);
|
||||
uint8_t s_menu_item = 0;
|
||||
uint16_t popupMenuItemsCount = 0;
|
||||
uint16_t popupMenuOffset = 0;
|
||||
void (* popupMenuHandler)(const char * result);
|
||||
const char * popupMenuTitle = nullptr;
|
||||
|
||||
void drawMessageBoxBackground(coord_t top, coord_t height)
|
||||
{
|
||||
// white background
|
||||
lcdDrawFilledRect(MESSAGEBOX_X - 1, top - 1, MESSAGEBOX_W + 2, height + 2, SOLID, ERASE);
|
||||
|
||||
// border
|
||||
lcdDrawRect(MESSAGEBOX_X, top, MESSAGEBOX_W, height, SOLID, FORCE);
|
||||
}
|
||||
|
||||
void drawMessageBox(const char * title)
|
||||
{
|
||||
// background + border
|
||||
drawMessageBoxBackground(MESSAGEBOX_Y, 40);
|
||||
|
||||
// title
|
||||
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y, title, WARNING_LINE_LEN);
|
||||
|
||||
// could be a place for a warningInfoText
|
||||
}
|
||||
|
||||
void showMessageBox(const char * title)
|
||||
{
|
||||
drawMessageBox(title);
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
const char * runPopupMenu(event_t event)
|
||||
{
|
||||
const char * result = NULL;
|
||||
@@ -175,12 +208,6 @@ void runPopupWarning(event_t event)
|
||||
}
|
||||
}
|
||||
|
||||
void showMessageBox(const char * str)
|
||||
{
|
||||
drawMessageBox(str);
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
void showAlertBox(const char * title, const char * text, const char * action , uint8_t sound)
|
||||
{
|
||||
drawAlertBox(title, text, action);
|
||||
@@ -191,3 +218,22 @@ void showAlertBox(const char * title, const char * text, const char * action , u
|
||||
backlightOn();
|
||||
checkBacklight();
|
||||
}
|
||||
|
||||
void drawProgressScreen(const char * title, const char * message, int num, int den)
|
||||
{
|
||||
lcdClear();
|
||||
if (title) {
|
||||
lcdDrawText(LCD_W / 2 - getTextWidth(title) / 2, 2*FH, title);
|
||||
}
|
||||
if (message) {
|
||||
lcdDrawText(4, 5*FH, message);
|
||||
}
|
||||
lcdDrawRect(4, 6*FH+4, LCD_W-8, 7);
|
||||
if (num > 0 && den > 0) {
|
||||
int width = ((LCD_W-12)*num)/den;
|
||||
lcdDrawSolidHorizontalLine(6, 6*FH+6, width, FORCE);
|
||||
lcdDrawSolidHorizontalLine(6, 6*FH+7, width, FORCE);
|
||||
lcdDrawSolidHorizontalLine(6, 6*FH+8, width, FORCE);
|
||||
}
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _STDLCD_POPUPS_H_
|
||||
#define _STDLCD_POPUPS_H_
|
||||
|
||||
extern const char * warningText;
|
||||
extern const char * warningInfoText;
|
||||
extern uint8_t warningInfoLength;
|
||||
extern uint8_t warningResult;
|
||||
extern uint8_t warningType;
|
||||
extern uint8_t warningInfoFlags;
|
||||
|
||||
extern void (* popupFunc)(event_t event);
|
||||
extern uint8_t popupMenuOffsetType;
|
||||
|
||||
extern uint16_t popupMenuOffset;
|
||||
extern const char * popupMenuItems[POPUP_MENU_MAX_LINES];
|
||||
extern uint16_t popupMenuItemsCount;
|
||||
extern void (* popupMenuHandler)(const char * result);
|
||||
extern const char * popupMenuTitle;
|
||||
extern uint8_t s_menu_item;
|
||||
|
||||
// Message box
|
||||
void drawMessageBoxBackground(coord_t top, coord_t height);
|
||||
void drawMessageBox(const char * title);
|
||||
void showMessageBox(const char * title);
|
||||
|
||||
// Popup menu
|
||||
const char * runPopupMenu(event_t event);
|
||||
void runPopupWarning(event_t event);
|
||||
|
||||
// Full screen with an alert
|
||||
void showAlertBox(const char * title, const char * text, const char * action , uint8_t sound);
|
||||
|
||||
// Full screen with 2 lines and a progress bar
|
||||
void drawProgressScreen(const char * title, const char * message, int num, int den);
|
||||
|
||||
#endif // _STDLCD_POPUPS_H_
|
||||
Reference in New Issue
Block a user