Startup / shutdown refactoring
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "lcd.h"
|
||||
#include "menus.h"
|
||||
#include "popups.h"
|
||||
#include "common/stdlcd/draw_functions.h"
|
||||
|
||||
#define HEADER_LINE 0
|
||||
#define HEADER_LINE_COLUMNS
|
||||
@@ -215,7 +216,6 @@ swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t e
|
||||
#define ON_OFF_MENU_ITEM(value, x, y, label, attr, event) value = editCheckBox(value, x, y, label, attr, event)
|
||||
|
||||
#if defined(GVARS)
|
||||
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);
|
||||
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);
|
||||
#define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) editGVarFieldValue(x, y, v, min, max, lcdattr, editflags, event)
|
||||
@@ -226,9 +226,6 @@ swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t e
|
||||
#define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v)
|
||||
#endif
|
||||
|
||||
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att = 0);
|
||||
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags=0);
|
||||
|
||||
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
|
||||
|
||||
extern uint8_t s_curveChan;
|
||||
|
||||
@@ -117,7 +117,6 @@ void lcdDrawHexNumber(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
|
||||
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode, uint8_t len);
|
||||
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
|
||||
|
||||
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 drawSwitch(coord_t x, coord_t y, int32_t swtch, LcdFlags att=0);
|
||||
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
|
||||
@@ -132,13 +131,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);
|
||||
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
|
||||
|
||||
@@ -163,8 +155,6 @@ inline void lcdDrawSquare(coord_t x, coord_t y, coord_t w, LcdFlags att=0)
|
||||
void lcdInvertLine(int8_t line);
|
||||
#define lcdInvertLastLine() lcdInvertLine(LCD_LINES-1)
|
||||
|
||||
void drawShutdownAnimation(uint32_t index, const char * message);
|
||||
void drawSleepBitmap();
|
||||
void drawTelemetryTopBar();
|
||||
|
||||
#define V_BAR(xx, yy, ll) \
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 ANIMATIONS_BITMAP_WIDTH 60
|
||||
#define ANIMATIONS_BITMAP_HEIGHT 60
|
||||
|
||||
const unsigned char bmp_startup[] = {
|
||||
#include "startup.lbm"
|
||||
};
|
||||
|
||||
const unsigned char bmp_lock[] = {
|
||||
#include "lock.lbm"
|
||||
};
|
||||
|
||||
const unsigned char bmp_shutdown[] = {
|
||||
#include "shutdown.lbm"
|
||||
};
|
||||
|
||||
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 / 5), 4);
|
||||
|
||||
lcdRefreshWait();
|
||||
lcdClear();
|
||||
|
||||
if (index == 0)
|
||||
lcdDrawBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_lock, 0, ANIMATIONS_BITMAP_WIDTH);
|
||||
else
|
||||
lcdDrawBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_startup, (index - 1) * ANIMATIONS_BITMAP_WIDTH, ANIMATIONS_BITMAP_WIDTH);
|
||||
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
void drawShutdownAnimation(uint32_t duration, const char * message)
|
||||
{
|
||||
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_SHUTDOWN_DELAY / 4), 3);
|
||||
|
||||
lcdRefreshWait();
|
||||
lcdClear();
|
||||
|
||||
lcdDrawBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_shutdown, (3 - index) * ANIMATIONS_BITMAP_WIDTH, ANIMATIONS_BITMAP_WIDTH);
|
||||
if (message) {
|
||||
lcdDrawText((LCD_W - getTextWidth(message)) / 2, LCD_H - 2*FH, message);
|
||||
}
|
||||
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
void drawSleepBitmap()
|
||||
{
|
||||
lcdRefreshWait();
|
||||
lcdClear();
|
||||
lcdDrawBitmap((LCD_W - ANIMATIONS_BITMAP_WIDTH) / 2, (LCD_H - ANIMATIONS_BITMAP_HEIGHT) / 2, bmp_sleep, 0);
|
||||
lcdRefresh();
|
||||
lcdRefreshWait();
|
||||
}
|
||||
@@ -59,15 +59,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++) {
|
||||
@@ -75,7 +75,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)
|
||||
|
||||
@@ -20,19 +20,6 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
const unsigned char SLEEP_BITMAP[] = {
|
||||
#include "../../bitmaps/212x64/sleep.lbm"
|
||||
};
|
||||
|
||||
#define SLEEP_BITMAP_WIDTH 60
|
||||
#define SLEEP_BITMAP_HEIGHT 60
|
||||
void drawSleepBitmap()
|
||||
{
|
||||
lcdClear();
|
||||
lcdDrawBitmap((LCD_W-SLEEP_BITMAP_WIDTH)/2, (LCD_H-SLEEP_BITMAP_HEIGHT)/2, SLEEP_BITMAP, 0, SLEEP_BITMAP_WIDTH);
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
void drawStick(coord_t centrex, int16_t xval, int16_t yval)
|
||||
{
|
||||
#define BOX_CENTERY (LCD_H-BOX_WIDTH/2-10)
|
||||
|
||||
Reference in New Issue
Block a user