Progress screen refactoring

This commit is contained in:
Bertrand Songis
2019-03-25 17:27:57 +01:00
parent 5d8ed05f29
commit 0c99545b27
37 changed files with 226 additions and 215 deletions
+1 -9
View File
@@ -40,7 +40,6 @@
#define NUM_BODY_LINES (LCD_LINES-1)
#define MENU_HEADER_HEIGHT FH
#define MENU_INIT_VPOS 0
#define CURVE_SIDE_WIDTH (LCD_H/2)
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-2)
@@ -57,7 +56,6 @@ void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr);
extern int8_t checkIncDec_Ret; // global helper vars
#define EDIT_SELECT_MENU -1
#define EDIT_SELECT_FIELD 0
#define EDIT_MODIFY_FIELD 1
#define EDIT_MODIFY_STRING 2
@@ -242,12 +240,6 @@ uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint
#define WARNING_TYPE_CONFIRM 1
#define WARNING_TYPE_INFO 2
extern const char * warningText;
extern const char * warningInfoText;
extern uint8_t warningInfoLength;
extern uint8_t warningResult;
extern uint8_t warningType;
#define COPY_MODE 1
#define MOVE_MODE 2
extern uint8_t s_copyMode;
@@ -343,7 +335,7 @@ void drawStick(coord_t centrex, int16_t xval, int16_t yval);
void drawPotsBars();
void doMainScreenGraphics();
void drawProgressBar(const char * label, int num, int den);
void drawProgressScreen(const char * title, const char * message, int num, int den);
void drawSleepBitmap();
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
+1 -1
View File
@@ -1825,7 +1825,7 @@ void menuModelSetup(event_t event)
#if defined(PXX)
if (IS_RANGECHECK_ENABLE()) {
showMessageBox("RSSI: ");
lcdDrawNumber(16+4*FW, 5*FH, TELEMETRY_RSSI(), BOLD);
lcdDrawNumber(WARNING_LINE_X, 5*FH, TELEMETRY_RSSI(), BOLD);
}
#endif
+2 -15
View File
@@ -20,21 +20,6 @@
#include "opentx.h"
const char * warningText = NULL;
const char * warningInfoText;
uint8_t warningInfoLength;
uint8_t warningType;
uint8_t warningResult = 0;
uint8_t warningInfoFlags = ZCHAR;
void drawMessageBox(const char * title)
{
lcdDrawFilledRect(MENU_X, MENU_Y, MENU_W, 40, SOLID, ERASE);
lcdDrawRect(MENU_X, MENU_Y, MENU_W, 40);
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y, title, WARNING_LINE_LEN);
// could be a place for a warningInfoText
}
const unsigned char ASTERISK_BITMAP[] = {
#include "asterisk.lbm"
};
@@ -55,9 +40,11 @@ void drawAlertBox(const char * title, const char * text, const char * action)
#endif
lcdDrawSolidFilledRect(0, 0, LCD_W, 32);
if (text) {
lcdDrawTextAlignedLeft(5*FH, text);
}
if (action) {
lcdDrawTextAlignedLeft(7*FH, action);
}
+21 -30
View File
@@ -23,20 +23,18 @@
#include <keys.h>
#define MENU_X 10
#define MENU_Y 16
#define MENU_W LCD_W - 19
#define MESSAGEBOX_X 10
#define MESSAGEBOX_Y 16
#define MESSAGEBOX_W (LCD_W - 19)
#define MENU_X MESSAGEBOX_X
#define MENU_Y MESSAGEBOX_Y
#define MENU_W MESSAGEBOX_W
#define WARNING_LINE_LEN 20
#define WARNING_LINE_X 16
#define WARNING_LINE_Y 3*FH
void drawMessageBox(const char * title);
void showMessageBox(const char * title);
void runPopupWarning(event_t event);
extern void (*popupFunc)(event_t event);
extern uint8_t warningInfoFlags;
#if !defined(GUI)
#define DISPLAY_WARNING(...)
#define POPUP_WARNING(...)
@@ -60,26 +58,19 @@ extern uint8_t warningInfoFlags;
#define POPUP_MENU_ADD_SD_ITEM(s)
#endif
#define POPUP_MENU_ADD_ITEM(s) do { popupMenuOffsetType = MENU_OFFSET_INTERNAL; if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) popupMenuItems[popupMenuItemsCount++] = s; } while (0)
#define POPUP_MENU_SELECT_ITEM(s) s_menu_item = (s > 0 ? (s < popupMenuItemsCount ? s : popupMenuItemsCount) : 0)
#define POPUP_MENU_START(func) do { popupMenuHandler = (func); AUDIO_KEY_PRESS(); } while (0)
#define POPUP_MENU_MAX_LINES 12
#define MENU_MAX_DISPLAY_LINES 6
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
#define POPUP_MENU_SET_BSS_FLAG()
#define POPUP_MENU_UNSET_BSS_FLAG()
enum {
MENU_OFFSET_INTERNAL,
MENU_OFFSET_EXTERNAL
};
extern uint8_t popupMenuOffsetType;
extern uint8_t s_menu_item;
#define POPUP_MENU_ADD_ITEM(s) do { popupMenuOffsetType = MENU_OFFSET_INTERNAL; if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) popupMenuItems[popupMenuItemsCount++] = s; } while (0)
#define POPUP_MENU_SELECT_ITEM(s) s_menu_item = (s > 0 ? (s < popupMenuItemsCount ? s : popupMenuItemsCount) : 0)
#define POPUP_MENU_START(func) do { popupMenuHandler = (func); AUDIO_KEY_PRESS(); } while (0)
#define POPUP_MENU_MAX_LINES 12
#define MENU_MAX_DISPLAY_LINES 6
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
#define POPUP_MENU_SET_BSS_FLAG()
#define POPUP_MENU_UNSET_BSS_FLAG()
enum {
MENU_OFFSET_INTERNAL,
MENU_OFFSET_EXTERNAL
};
extern uint16_t popupMenuOffset;
extern const char * popupMenuItems[POPUP_MENU_MAX_LINES];
extern uint16_t popupMenuItemsCount;
const char * runPopupMenu(event_t event);
extern void (*popupMenuHandler)(const char * result);
extern const char * popupMenuTitle;
#include "../common/stdlcd/popups.h"
#endif // _POPUPS_H_
+2 -2
View File
@@ -255,14 +255,14 @@ void menuRadioVersion(event_t event)
#endif
#if defined(EEPROM_RLC)
lcdDrawText(INDENT_WIDTH, y, BUTTON(TR_EEBACKUP), menuVerticalPosition == ITEM_RADIO_BACKUP_EEPROM ? INVERS : 0);
lcdDrawText(INDENT_WIDTH, y, BUTTON(STR_EEBACKUP), menuVerticalPosition == ITEM_RADIO_BACKUP_EEPROM ? INVERS : 0);
y += FH;
if (menuVerticalPosition == ITEM_RADIO_BACKUP_EEPROM && event == EVT_KEY_BREAK(KEY_ENTER)) {
s_editMode = EDIT_SELECT_FIELD;
eepromBackup();
}
lcdDrawText(INDENT_WIDTH, y, BUTTON(TR_FACTORYRESET), menuVerticalPosition == ITEM_RADIO_FACTORY_RESET ? INVERS : 0);
lcdDrawText(INDENT_WIDTH, y, BUTTON(STR_FACTORYRESET), menuVerticalPosition == ITEM_RADIO_FACTORY_RESET ? INVERS : 0);
// y += FH;
if (menuVerticalPosition == ITEM_RADIO_FACTORY_RESET && event == EVT_KEY_BREAK(KEY_ENTER)) {
s_editMode = EDIT_SELECT_FIELD;
-16
View File
@@ -230,22 +230,6 @@ void drawStatusLine()
}
#endif
void drawProgressBar(const char * label, int num, int den)
{
lcdClear();
if (label) {
lcdDrawTextAlignedLeft(4*FH, label);
}
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();
}
const unsigned char SLEEP_BITMAP[] = {
#include "sleep.lbm"
};
-15
View File
@@ -32,7 +32,6 @@
#define DEFAULT_SCROLLBAR_X (LCD_W-1)
#define NUM_BODY_LINES (LCD_LINES-1)
#define MENU_HEADER_HEIGHT FH
#define MENU_INIT_VPOS 0
#define MODEL_BITMAP_WIDTH 64
#define MODEL_BITMAP_HEIGHT 32
@@ -55,11 +54,6 @@ inline void drawFieldLabel(coord_t x, coord_t y, const char * str)
extern uint8_t modelBitmap[MODEL_BITMAP_SIZE];
bool loadModelBitmap(char * name, uint8_t * bitmap);
struct MenuItem {
const char * name;
const MenuHandlerFunc action;
};
// Temporary no highlight
extern uint8_t noHighlightCounter;
#define NO_HIGHLIGHT() (noHighlightCounter > 0)
@@ -71,8 +65,6 @@ void drawSplash();
void drawSecondSplash();
void drawScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
void displayMenuBar(const MenuItem * menu, int index);
void drawProgressBar(const char * label, int num, int den);
void drawGauge(coord_t x, coord_t y, coord_t w, coord_t h, int32_t val, int32_t max);
void drawColumnHeader(const char * const * headers, uint8_t index);
void drawStick(coord_t centrex, int16_t xval, int16_t yval);
@@ -86,7 +78,6 @@ typedef uint16_t FlightModesType;
extern int8_t checkIncDec_Ret; // global helper vars
#define EDIT_SELECT_MENU -1
#define EDIT_SELECT_FIELD 0
#define EDIT_MODIFY_FIELD 1
#define EDIT_MODIFY_STRING 2
@@ -261,12 +252,6 @@ uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint
void copySelection(char * dst, const char * src, uint8_t size);
extern const char * warningText;
extern const char * warningInfoText;
extern uint8_t warningInfoLength;
extern uint8_t warningResult;
extern uint8_t warningType;
#define COPY_MODE 1
#define MOVE_MODE 2
extern uint8_t s_copyMode;
+1 -1
View File
@@ -1240,7 +1240,7 @@ void menuModelSetup(event_t event)
#if defined(PXX)
if (IS_RANGECHECK_ENABLE()) {
showMessageBox("RSSI: ");
lcdDrawNumber(16+4*FW, 5*FH, TELEMETRY_RSSI(), BOLD);
lcdDrawNumber(WARNING_LINE_X, 5*FH, TELEMETRY_RSSI(), BOLD | LEFT);
}
#endif
-15
View File
@@ -20,21 +20,6 @@
#include "opentx.h"
const char * warningText = NULL;
const char * warningInfoText;
uint8_t warningInfoLength;
uint8_t warningType;
uint8_t warningResult = 0;
uint8_t warningInfoFlags = ZCHAR;
void drawMessageBox(const char * title)
{
lcdDrawFilledRect(10, 16, LCD_W-20, 40, SOLID, ERASE);
lcdDrawRect(10, 16, LCD_W-20, 40);
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y, title, WARNING_LINE_LEN);
// could be a place for a warningInfoText
}
const unsigned char ASTERISK_BITMAP[] = {
#include "asterisk.lbm"
};
+9 -15
View File
@@ -21,20 +21,18 @@
#ifndef _POPUPS_H_
#define _POPUPS_H_
#define MESSAGEBOX_X 10
#define MESSAGEBOX_Y 16
#define MESSAGEBOX_W LCD_W - (2 * MESSAGEBOX_X)
#define MENU_X 30
#define MENU_Y 16
#define MENU_W LCD_W-(2*MENU_X)
#define MENU_W LCD_W - (2 * MENU_X)
#define WARNING_LINE_LEN 32
#define WARNING_LINE_X 16
#define WARNING_LINE_Y 3*FH
void drawMessageBox(const char * title);
void showMessageBox(const char * title);
void runPopupWarning(event_t event);
extern void (*popupFunc)(event_t event);
extern uint8_t warningInfoFlags;
#define DISPLAY_WARNING (*popupFunc)
#define POPUP_INFORMATION(s) (warningText = s, warningType = WARNING_TYPE_INFO, warningInfoText = 0, popupFunc = runPopupWarning)
#define POPUP_WARNING(s) (warningText = s, warningInfoText = 0, popupFunc = runPopupWarning)
@@ -51,16 +49,12 @@ extern uint8_t warningInfoFlags;
#define POPUP_MENU_ADD_SD_ITEM(s) POPUP_MENU_ADD_ITEM(s)
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
#define POPUP_MENU_SET_BSS_FLAG()
extern const char * popupMenuItems[POPUP_MENU_MAX_LINES];
extern uint16_t popupMenuItemsCount;
extern uint16_t popupMenuOffset;
enum {
MENU_OFFSET_INTERNAL,
MENU_OFFSET_EXTERNAL
};
extern uint8_t popupMenuOffsetType;
extern uint8_t s_menu_item;
const char * runPopupMenu(event_t event);
extern void (*popupMenuHandler)(const char * result);
#include "../common/stdlcd/popups.h"
#endif // _POPUPS_H_
+2 -2
View File
@@ -38,8 +38,8 @@ void menuRadioVersion(event_t event)
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+4*FH+1, "UID\037\033:");
lcdDrawText(5*FW+3, MENU_HEADER_HEIGHT+4*FH+1, id);
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+5*FH+1, STR_EEBACKUP);
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+6*FH+1, STR_FACTORYRESET);
lcdDrawText(INDENT_WIDTH, MENU_HEADER_HEIGHT+5*FH+1, "[ENTER Long] " STR_EEBACKUP);
lcdDrawText(INDENT_WIDTH, MENU_HEADER_HEIGHT+6*FH+1, "[MENU Long] " STR_FACTORYRESET);
lcdDrawFilledRect(0, MENU_HEADER_HEIGHT+5*FH, LCD_W, 2*FH+1, SOLID);
if (event == EVT_KEY_LONG(KEY_ENTER)) {
-16
View File
@@ -98,22 +98,6 @@ void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uin
lcdDrawVerticalLine(x, y + yofs, yhgt, SOLID, FORCE);
}
void drawProgressBar(const char * label, int num, int den)
{
lcdClear();
if (label) {
lcdDrawTextAlignedLeft(4*FH, label);
}
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();
}
void drawGauge(coord_t x, coord_t y, coord_t w, coord_t h, int32_t val, int32_t max)
{
lcdDrawRect(x, y, w+1, h);
-1
View File
@@ -62,7 +62,6 @@
#define DATETIME_MIDDLE (LCD_W+DATETIME_SEPARATOR_X+4)/2
#define MENU_TITLE_NEXT_POS (lcdNextPos + 10)
#define MENU_INIT_VPOS -1
#if defined(HELI) && defined(GVARS) && defined(LUA_MODEL_SCRIPTS)
#define MENU_ICONS_SPACING 31
-1
View File
@@ -265,7 +265,6 @@ typedef uint16_t FlightModesType;
extern int8_t checkIncDec_Ret; // global helper vars
#define EDIT_SELECT_MENU -1
#define EDIT_SELECT_FIELD 0
#define EDIT_MODIFY_FIELD 1
#define EDIT_MODIFY_STRING 2
+3 -3
View File
@@ -108,12 +108,12 @@ void drawHorizontalScrollbar(coord_t x, coord_t y, coord_t w, uint16_t offset, u
}
}
void drawProgressBar(const char * label, int num, int den)
void drawProgressScreen(const char * title, const char * message, int num, int den)
{
lcdClear();
lcdSetColor(WHITE);
if (label) {
lcdDrawText(MENUS_MARGIN_LEFT, LCD_H-42, label, CUSTOM_COLOR);
if (message) {
lcdDrawText(MENUS_MARGIN_LEFT, LCD_H-42, message, CUSTOM_COLOR);
}
lcdDrawRect(MENUS_MARGIN_LEFT, LCD_H-22, LCD_W-2*MENUS_MARGIN_LEFT, 15, 1, SOLID, CUSTOM_COLOR);
lcdSetColor(RED);
+1 -1
View File
@@ -49,7 +49,7 @@ void drawButton(coord_t x, coord_t y, const char * label, LcdFlags attr);
void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr);
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
void drawHorizontalScrollbar(coord_t x, coord_t y, coord_t w, uint16_t offset, uint16_t count, uint8_t visible);
void drawProgressBar(const char * label, int num, int den);
void drawProgressScreen(const char * title, const char * message, int num, int den);
void drawShadow(coord_t x, coord_t y, coord_t w, coord_t h);
void drawTrimSquare(coord_t x, coord_t y);
void drawHorizontalTrimPosition(coord_t x, coord_t y, int16_t dir);
+58 -12
View File
@@ -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();
}
+56
View File
@@ -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_