Startup / shutdown refactoring

This commit is contained in:
Bertrand Songis
2019-08-16 16:12:34 +02:00
parent f7a6d44d1e
commit a611d9e10f
26 changed files with 382 additions and 268 deletions
+1
View File
@@ -5,6 +5,7 @@ set(GUI_SRC
fonts.cpp
popups.cpp
widgets.cpp
startup_shutdown.cpp
menu_model.cpp
model_select.cpp
model_setup.cpp
+1 -1
View File
@@ -24,6 +24,7 @@
#include "gui_common.h"
#include "menus.h"
#include "popups.h"
#include "common/stdlcd/draw_functions.h"
#define MENUS_SCROLLBAR_WIDTH 0
@@ -192,7 +193,6 @@ swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t e
#if defined(GVARS)
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) editGVarFieldValue(x, y, v, min, max, attr, editflags, event)
int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, event_t event);
void drawGVarName(coord_t x, coord_t y, int8_t index, LcdFlags flags=0);
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags=0);
void editGVarValue(coord_t x, coord_t y, event_t event, uint8_t gvar, uint8_t flightMode, LcdFlags flags);
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
-12
View File
@@ -122,9 +122,7 @@ void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags mode, uint8_t len);
void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags mode=0);
void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val);
void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, LcdFlags att=0);
void putsModelName(coord_t x, coord_t y, char * name, uint8_t id, LcdFlags att);
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att = 0);
#if !defined(BOOT) // TODO not here ...
void drawSwitch(coord_t x, coord_t y, swsrc_t swtch, LcdFlags att=0);
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
@@ -141,14 +139,6 @@ void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
void putsVBat(coord_t x, coord_t y, LcdFlags att);
void drawRtcTime(coord_t x, coord_t y, LcdFlags att);
void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att, LcdFlags att2);
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags=0);
inline void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att)
{
drawTimer(x, y, tme, att, att);
}
#define SOLID 0xff
#define DOTTED 0x55
@@ -209,8 +199,6 @@ inline display_t getPixel(uint8_t x, uint8_t y)
const char * writeScreenshot();
void drawShutdownAnimation(uint32_t index, const char * message);
uint8_t getTextWidth(const char * s, uint8_t len=0, LcdFlags flags=0);
#endif // _LCD_H_
+81
View File
@@ -0,0 +1,81 @@
/*
* 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.
*/
#include "opentx.h"
#define PWR_PRESS_DURATION_MIN 100 // 1s
#define PWR_PRESS_DURATION_MAX 500 // 5s
#define SLEEP_BITMAP_WIDTH 60
#define SLEEP_BITMAP_HEIGHT 60
const unsigned char bmp_sleep[] = {
#include "sleep.lbm"
};
void drawStartupAnimation(uint32_t duration)
{
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_DURATION_MIN / 4), 3);
lcdRefreshWait();
lcdClear();
for (uint8_t i = 0; i < 4; i++) {
if (index >= i) {
lcdDrawFilledRect(LCD_W / 2 - 18 + 10 * i, LCD_H / 2 - 3, 6, 6, SOLID, 0);
}
}
lcdRefresh();
lcdRefreshWait();
}
void drawShutdownAnimation(uint32_t duration, const char * message)
{
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_SHUTDOWN_DELAY / 5), 4);
lcdRefreshWait();
lcdClear();
for (uint8_t i = 0; i < 4; i++) {
if (3 - index >= i) {
lcdDrawFilledRect(LCD_W / 2 - 18 + 10 * i, LCD_H / 2 - 3, 6, 6, SOLID, 0);
}
}
if (message) {
lcdDrawText((LCD_W - getTextWidth(message)) / 2, LCD_H-2*FH, message);
}
lcdRefresh();
lcdRefreshWait();
}
void drawSleepBitmap()
{
lcdRefreshWait();
lcdClear();
lcdDraw1bitBitmap((LCD_W - SLEEP_BITMAP_WIDTH) / 2, (LCD_H - SLEEP_BITMAP_HEIGHT) / 2, bmp_sleep, 0);
lcdRefresh();
lcdRefreshWait();
}
+4 -4
View File
@@ -65,15 +65,15 @@ void menuStatisticsView(event_t event)
// Session and Total timers
lcdDrawText(STATS_1ST_COLUMN, FH*1+1, "SES", BOLD);
drawTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*1+1, sessionTimer, 0, 0);
drawTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*1+1, sessionTimer);
lcdDrawText(STATS_1ST_COLUMN, FH*2+1, "TOT", BOLD);
drawTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*2+1, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0);
// Throttle special timers
lcdDrawText(STATS_2ND_COLUMN, FH*0+1, "THR", BOLD);
drawTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*0+1, s_timeCumThr, 0, 0);
drawTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*0+1, s_timeCumThr);
lcdDrawText(STATS_2ND_COLUMN, FH*1+1, "TH%", BOLD);
drawTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*1+1, s_timeCum16ThrP/16, 0, 0);
drawTimer(STATS_2ND_COLUMN + STATS_LABEL_WIDTH, FH*1+1, s_timeCum16ThrP/16);
// Timers
for (int i=0; i<TIMERS; i++) {
@@ -81,7 +81,7 @@ void menuStatisticsView(event_t event)
if (timersStates[i].val > 3600)
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0);
else
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, 0, 0);
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val);
}
#if defined(THRTRACE)
-14
View File
@@ -235,17 +235,3 @@ void drawStatusLine()
}
}
#endif
const unsigned char SLEEP_BITMAP[] = {
#include "sleep.lbm"
};
#define SLEEP_BITMAP_WIDTH 60
#define SLEEP_BITMAP_HEIGHT 60
void drawSleepBitmap()
{
lcdClear();
lcdDraw1bitBitmap((LCD_W-SLEEP_BITMAP_WIDTH)/2, (LCD_H-SLEEP_BITMAP_HEIGHT)/2, SLEEP_BITMAP, 0);
lcdRefresh();
}