mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-23 00:05:13 +03:00
Startup / shutdown refactoring
This commit is contained in:
parent
f7a6d44d1e
commit
a611d9e10f
26 changed files with 382 additions and 268 deletions
BIN
radio/src/bitmaps/212x64/shutdown.png
Executable file
BIN
radio/src/bitmaps/212x64/shutdown.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -5,6 +5,7 @@ set(GUI_SRC
|
||||||
fonts.cpp
|
fonts.cpp
|
||||||
popups.cpp
|
popups.cpp
|
||||||
widgets.cpp
|
widgets.cpp
|
||||||
|
startup_shutdown.cpp
|
||||||
menu_model.cpp
|
menu_model.cpp
|
||||||
model_select.cpp
|
model_select.cpp
|
||||||
model_setup.cpp
|
model_setup.cpp
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "gui_common.h"
|
#include "gui_common.h"
|
||||||
#include "menus.h"
|
#include "menus.h"
|
||||||
#include "popups.h"
|
#include "popups.h"
|
||||||
|
#include "common/stdlcd/draw_functions.h"
|
||||||
|
|
||||||
#define MENUS_SCROLLBAR_WIDTH 0
|
#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)
|
#if defined(GVARS)
|
||||||
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) editGVarFieldValue(x, y, v, min, max, attr, editflags, event)
|
#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);
|
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 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);
|
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)
|
#define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0)
|
||||||
|
|
|
@ -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 lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags mode=0);
|
||||||
void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val);
|
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 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 ...
|
#if !defined(BOOT) // TODO not here ...
|
||||||
void drawSwitch(coord_t x, coord_t y, swsrc_t swtch, LcdFlags att=0);
|
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);
|
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 putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
|
||||||
void putsVBat(coord_t x, coord_t y, 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 SOLID 0xff
|
||||||
#define DOTTED 0x55
|
#define DOTTED 0x55
|
||||||
|
|
||||||
|
@ -209,8 +199,6 @@ inline display_t getPixel(uint8_t x, uint8_t y)
|
||||||
|
|
||||||
const char * writeScreenshot();
|
const char * writeScreenshot();
|
||||||
|
|
||||||
void drawShutdownAnimation(uint32_t index, const char * message);
|
|
||||||
|
|
||||||
uint8_t getTextWidth(const char * s, uint8_t len=0, LcdFlags flags=0);
|
uint8_t getTextWidth(const char * s, uint8_t len=0, LcdFlags flags=0);
|
||||||
|
|
||||||
#endif // _LCD_H_
|
#endif // _LCD_H_
|
||||||
|
|
81
radio/src/gui/128x64/startup_shutdown.cpp
Normal file
81
radio/src/gui/128x64/startup_shutdown.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,15 +65,15 @@ void menuStatisticsView(event_t event)
|
||||||
|
|
||||||
// Session and Total timers
|
// Session and Total timers
|
||||||
lcdDrawText(STATS_1ST_COLUMN, FH*1+1, "SES", BOLD);
|
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);
|
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);
|
drawTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*2+1, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0);
|
||||||
|
|
||||||
// Throttle special timers
|
// Throttle special timers
|
||||||
lcdDrawText(STATS_2ND_COLUMN, FH*0+1, "THR", BOLD);
|
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);
|
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
|
// Timers
|
||||||
for (int i=0; i<TIMERS; i++) {
|
for (int i=0; i<TIMERS; i++) {
|
||||||
|
@ -81,7 +81,7 @@ void menuStatisticsView(event_t event)
|
||||||
if (timersStates[i].val > 3600)
|
if (timersStates[i].val > 3600)
|
||||||
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0);
|
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0);
|
||||||
else
|
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)
|
#if defined(THRTRACE)
|
||||||
|
|
|
@ -235,17 +235,3 @@ void drawStatusLine()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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();
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ set(GUI_SRC
|
||||||
fonts.cpp
|
fonts.cpp
|
||||||
popups.cpp
|
popups.cpp
|
||||||
widgets.cpp
|
widgets.cpp
|
||||||
|
startup_shutdown.cpp
|
||||||
menu_model.cpp
|
menu_model.cpp
|
||||||
model_select.cpp
|
model_select.cpp
|
||||||
model_setup.cpp
|
model_setup.cpp
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "menus.h"
|
#include "menus.h"
|
||||||
#include "popups.h"
|
#include "popups.h"
|
||||||
|
#include "common/stdlcd/draw_functions.h"
|
||||||
|
|
||||||
#define HEADER_LINE 0
|
#define HEADER_LINE 0
|
||||||
#define HEADER_LINE_COLUMNS
|
#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)
|
#define ON_OFF_MENU_ITEM(value, x, y, label, attr, event) value = editCheckBox(value, x, y, label, attr, event)
|
||||||
|
|
||||||
#if defined(GVARS)
|
#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);
|
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);
|
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)
|
#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)
|
#define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v)
|
||||||
#endif
|
#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);
|
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
|
||||||
|
|
||||||
extern uint8_t s_curveChan;
|
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, uint8_t len);
|
||||||
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
|
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 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 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);
|
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 putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
|
||||||
void putsVBat(coord_t x, coord_t y, 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 SOLID 0xff
|
||||||
#define DOTTED 0x55
|
#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);
|
void lcdInvertLine(int8_t line);
|
||||||
#define lcdInvertLastLine() lcdInvertLine(LCD_LINES-1)
|
#define lcdInvertLastLine() lcdInvertLine(LCD_LINES-1)
|
||||||
|
|
||||||
void drawShutdownAnimation(uint32_t index, const char * message);
|
|
||||||
void drawSleepBitmap();
|
|
||||||
void drawTelemetryTopBar();
|
void drawTelemetryTopBar();
|
||||||
|
|
||||||
#define V_BAR(xx, yy, ll) \
|
#define V_BAR(xx, yy, ll) \
|
||||||
|
|
82
radio/src/gui/212x64/startup_shutdown.cpp
Normal file
82
radio/src/gui/212x64/startup_shutdown.cpp
Normal file
|
@ -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
|
// Session and Total timers
|
||||||
lcdDrawText(STATS_1ST_COLUMN, FH*1+1, "SES", BOLD);
|
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);
|
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);
|
drawTimer(STATS_1ST_COLUMN + STATS_LABEL_WIDTH, FH*2+1, g_eeGeneral.globalTimer + sessionTimer, TIMEHOUR, 0);
|
||||||
|
|
||||||
// Throttle special timers
|
// Throttle special timers
|
||||||
lcdDrawText(STATS_2ND_COLUMN, FH*0+1, "THR", BOLD);
|
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);
|
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
|
// Timers
|
||||||
for (int i=0; i<TIMERS; i++) {
|
for (int i=0; i<TIMERS; i++) {
|
||||||
|
@ -75,7 +75,7 @@ void menuStatisticsView(event_t event)
|
||||||
if (timersStates[i].val > 3600)
|
if (timersStates[i].val > 3600)
|
||||||
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0);
|
drawTimer(STATS_3RD_COLUMN + STATS_LABEL_WIDTH, FH*i+1, timersStates[i].val, TIMEHOUR, 0);
|
||||||
else
|
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)
|
#if defined(THRTRACE)
|
||||||
|
|
|
@ -20,19 +20,6 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#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)
|
void drawStick(coord_t centrex, int16_t xval, int16_t yval)
|
||||||
{
|
{
|
||||||
#define BOX_CENTERY (LCD_H-BOX_WIDTH/2-10)
|
#define BOX_CENTERY (LCD_H-BOX_WIDTH/2-10)
|
||||||
|
|
|
@ -142,12 +142,8 @@ 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 flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL);
|
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL);
|
||||||
|
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
|
|
||||||
#define putstime_t int32_t
|
|
||||||
|
|
||||||
void drawRtcTime(coord_t x, coord_t y, LcdFlags att=0);
|
void drawRtcTime(coord_t x, coord_t y, LcdFlags att=0);
|
||||||
void drawTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att=0);
|
void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att=0);
|
||||||
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags=0);
|
|
||||||
|
|
||||||
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
|
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
|
||||||
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
|
void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
|
||||||
|
@ -159,7 +155,6 @@ void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att
|
||||||
|
|
||||||
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
|
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
|
||||||
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
|
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
|
||||||
|
|
||||||
#endif // !BOOT
|
#endif // !BOOT
|
||||||
|
|
||||||
#define SOLID 0xff
|
#define SOLID 0xff
|
||||||
|
|
|
@ -391,20 +391,20 @@ void drawSleepBitmap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHUTDOWN_CIRCLE_DIAMETER 150
|
#define SHUTDOWN_CIRCLE_DIAMETER 150
|
||||||
void drawShutdownAnimation(uint32_t index, const char * message)
|
void drawShutdownAnimation(uint32_t duration, const char * message)
|
||||||
{
|
{
|
||||||
static uint32_t last_index = 0xffffffff;
|
static uint32_t lastDuration = 0xffffffff;
|
||||||
static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp"));
|
static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp"));
|
||||||
|
|
||||||
if (shutdown) {
|
if (shutdown) {
|
||||||
if (index < last_index) {
|
if (duration < lastDuration) {
|
||||||
theme->drawBackground();
|
theme->drawBackground();
|
||||||
lcd->drawBitmap((LCD_W-shutdown->getWidth())/2, (LCD_H-shutdown->getHeight())/2, shutdown);
|
lcd->drawBitmap((LCD_W-shutdown->getWidth())/2, (LCD_H-shutdown->getHeight())/2, shutdown);
|
||||||
lcdStoreBackupBuffer();
|
lcdStoreBackupBuffer();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lcdRestoreBackupBuffer();
|
lcdRestoreBackupBuffer();
|
||||||
int quarter = index / (PWR_PRESS_SHUTDOWN_DELAY / 5);
|
int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5);
|
||||||
if (quarter >= 1) lcdDrawBitmapPattern(LCD_W/2, (LCD_H-SHUTDOWN_CIRCLE_DIAMETER)/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, 0, SHUTDOWN_CIRCLE_DIAMETER/2);
|
if (quarter >= 1) lcdDrawBitmapPattern(LCD_W/2, (LCD_H-SHUTDOWN_CIRCLE_DIAMETER)/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, 0, SHUTDOWN_CIRCLE_DIAMETER/2);
|
||||||
if (quarter >= 2) lcdDrawBitmapPattern(LCD_W/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER/2, SHUTDOWN_CIRCLE_DIAMETER/2);
|
if (quarter >= 2) lcdDrawBitmapPattern(LCD_W/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER/2, SHUTDOWN_CIRCLE_DIAMETER/2);
|
||||||
if (quarter >= 3) lcdDrawBitmapPattern((LCD_W-SHUTDOWN_CIRCLE_DIAMETER)/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER, SHUTDOWN_CIRCLE_DIAMETER/2);
|
if (quarter >= 3) lcdDrawBitmapPattern((LCD_W-SHUTDOWN_CIRCLE_DIAMETER)/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER, SHUTDOWN_CIRCLE_DIAMETER/2);
|
||||||
|
@ -413,7 +413,7 @@ void drawShutdownAnimation(uint32_t index, const char * message)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lcd->clear();
|
lcd->clear();
|
||||||
int quarter = index / (PWR_PRESS_SHUTDOWN_DELAY / 5);
|
int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5);
|
||||||
for (int i=1; i<=4; i++) {
|
for (int i=1; i<=4; i++) {
|
||||||
if (quarter >= i) {
|
if (quarter >= i) {
|
||||||
lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, 20, TEXT_BGCOLOR);
|
lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, 20, TEXT_BGCOLOR);
|
||||||
|
@ -422,5 +422,5 @@ void drawShutdownAnimation(uint32_t index, const char * message)
|
||||||
}
|
}
|
||||||
|
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
last_index = index;
|
lastDuration = duration;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#define OPTION_MENU_TITLE_BAR 0x02
|
#define OPTION_MENU_TITLE_BAR 0x02
|
||||||
#define OPTION_MENU_NO_SCROLLBAR 0x04
|
#define OPTION_MENU_NO_SCROLLBAR 0x04
|
||||||
|
|
||||||
#define OPTION_SLIDER_INVERS INVERS
|
|
||||||
#define OPTION_SLIDER_BLINK BLINK
|
|
||||||
#define OPTION_SLIDER_VERTICAL 0x04
|
#define OPTION_SLIDER_VERTICAL 0x04
|
||||||
#define OPTION_SLIDER_EMPTY_BAR 0x08
|
#define OPTION_SLIDER_EMPTY_BAR 0x08
|
||||||
#define OPTION_SLIDER_DBL_COLOR 0x10
|
#define OPTION_SLIDER_DBL_COLOR 0x10
|
||||||
|
@ -68,10 +66,10 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Screen templates
|
// Screen templates
|
||||||
void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=NULL, uint32_t options=0);
|
void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=nullptr, uint32_t options=0);
|
||||||
void drawSplash();
|
void drawSplash();
|
||||||
void drawSleepBitmap();
|
void drawSleepBitmap();
|
||||||
void drawShutdownAnimation(uint32_t index, const char * message);
|
void drawShutdownAnimation(uint32_t duration, const char * message);
|
||||||
|
|
||||||
// Main view standard widgets
|
// Main view standard widgets
|
||||||
void drawTopBar();
|
void drawTopBar();
|
||||||
|
|
43
radio/src/gui/common/stdlcd/draw_functions.h
Normal file
43
radio/src/gui/common/stdlcd/draw_functions.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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 _COMMON_DRAW_FUNCTIONS_H_
|
||||||
|
#define _COMMON_DRAW_FUNCTIONS_H_
|
||||||
|
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
|
void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, LcdFlags att=0);
|
||||||
|
|
||||||
|
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att = 0);
|
||||||
|
void drawGVarName(coord_t x, coord_t y, int8_t index, LcdFlags flags=0);
|
||||||
|
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags=0);
|
||||||
|
|
||||||
|
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 = 0)
|
||||||
|
{
|
||||||
|
drawTimer(x, y, tme, att, att);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawStartupAnimation(uint32_t duration);
|
||||||
|
void drawShutdownAnimation(uint32_t duration, const char * message);
|
||||||
|
void drawSleepBitmap();
|
||||||
|
|
||||||
|
#endif // _COMMON_DRAW_FUNCTIONS_H_
|
|
@ -233,20 +233,3 @@ void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverI
|
||||||
lcdDrawText(x, y, "External", flags);
|
lcdDrawText(x, y, "External", flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
|
||||||
void drawShutdownAnimation(uint32_t index, const char * message)
|
|
||||||
{
|
|
||||||
lcdClear();
|
|
||||||
int quarter = index / (PWR_PRESS_SHUTDOWN_DELAY / 5);
|
|
||||||
for (int i=1; i<=4; i++) {
|
|
||||||
if (4 - quarter >= i) {
|
|
||||||
lcdDrawFilledRect(LCD_W / 2 - 28 + 10 * i, LCD_H / 2 - 3, 6, 6, SOLID, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (message) {
|
|
||||||
lcdDrawText((LCD_W - getTextWidth(message)) / 2, LCD_H-2*FH, message);
|
|
||||||
}
|
|
||||||
lcdRefresh();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1728,6 +1728,38 @@ void copyTrimsToOffset(uint8_t ch)
|
||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(STARTUP_ANIMATION)
|
||||||
|
#define PWR_PRESS_DURATION_MIN 100 // 1s
|
||||||
|
#define PWR_PRESS_DURATION_MAX 500 // 5s
|
||||||
|
|
||||||
|
void runStartupAnimation()
|
||||||
|
{
|
||||||
|
tmr10ms_t start = get_tmr10ms();
|
||||||
|
tmr10ms_t duration = 0;
|
||||||
|
bool isPowerOn = false;
|
||||||
|
|
||||||
|
while (pwrPressed()) {
|
||||||
|
duration = get_tmr10ms() - start;
|
||||||
|
if (duration < PWR_PRESS_DURATION_MIN) {
|
||||||
|
drawStartupAnimation(duration);
|
||||||
|
}
|
||||||
|
else if (duration >= PWR_PRESS_DURATION_MAX) {
|
||||||
|
drawSleepBitmap();
|
||||||
|
backlightDisable();
|
||||||
|
}
|
||||||
|
else if (!isPowerOn) {
|
||||||
|
isPowerOn = true;
|
||||||
|
pwrOn();
|
||||||
|
haptic.play(15, 3, PLAY_NOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duration < PWR_PRESS_DURATION_MIN || duration >= PWR_PRESS_DURATION_MAX) {
|
||||||
|
boardOff();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||||
{
|
{
|
||||||
int16_t zeros[MAX_OUTPUT_CHANNELS];
|
int16_t zeros[MAX_OUTPUT_CHANNELS];
|
||||||
|
@ -1783,14 +1815,23 @@ void opentxInit()
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
|
||||||
rtcInit(); // RTC must be initialized before rambackupRestore() is called
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(EEPROM)
|
#if defined(EEPROM)
|
||||||
storageReadRadioSettings();
|
storageReadRadioSettings();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BACKLIGHT_ENABLE(); // we start the backlight during the startup animation
|
||||||
|
|
||||||
|
#if defined(STARTUP_ANIMATION)
|
||||||
|
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||||
|
pwrOn();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
runStartupAnimation();
|
||||||
|
}
|
||||||
|
#else // defined(PWR_BUTTON_PRESS)
|
||||||
|
pwrOn();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Radios handle UNEXPECTED_SHUTDOWN() differently:
|
// Radios handle UNEXPECTED_SHUTDOWN() differently:
|
||||||
// * radios with WDT and EEPROM and CPU controlled power use Reset status register
|
// * radios with WDT and EEPROM and CPU controlled power use Reset status register
|
||||||
// and eeGeneral.unexpectedShutdown
|
// and eeGeneral.unexpectedShutdown
|
||||||
|
@ -1963,7 +2004,7 @@ int main()
|
||||||
stackPaint();
|
stackPaint();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SPLASH) && (defined(PCBTARANIS) || defined(PCBHORUS))
|
#if defined(SPLASH) && !defined(STARTUP_ANIMATION)
|
||||||
drawSplash();
|
drawSplash();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,7 @@ extern uint16_t adcValues[NUM_ANALOGS];
|
||||||
|
|
||||||
#if NUM_PWMSTICKS > 0
|
#if NUM_PWMSTICKS > 0
|
||||||
#define STICKS_PWM_ENABLED() (!hardwareOptions.sticksPwmDisabled)
|
#define STICKS_PWM_ENABLED() (!hardwareOptions.sticksPwmDisabled)
|
||||||
void sticksPwmInit(void);
|
void sticksPwmInit();
|
||||||
void sticksPwmRead(uint16_t * values);
|
void sticksPwmRead(uint16_t * values);
|
||||||
extern volatile uint32_t pwm_interrupt_count;
|
extern volatile uint32_t pwm_interrupt_count;
|
||||||
#else
|
#else
|
||||||
|
@ -457,13 +457,13 @@ extern "C" {
|
||||||
#define SOFT_PWR_CTRL
|
#define SOFT_PWR_CTRL
|
||||||
extern uint32_t shutdownRequest; // Stores intentional shutdown to avoid reboot loop
|
extern uint32_t shutdownRequest; // Stores intentional shutdown to avoid reboot loop
|
||||||
extern uint32_t shutdownReason; // Used for detecting unexpected reboots regardless of reason
|
extern uint32_t shutdownReason; // Used for detecting unexpected reboots regardless of reason
|
||||||
void pwrInit(void);
|
void pwrInit();
|
||||||
uint32_t pwrCheck(void);
|
uint32_t pwrCheck();
|
||||||
void pwrOn(void);
|
void pwrOn();
|
||||||
void pwrOff(void);
|
void pwrOff();
|
||||||
void pwrResetHandler(void);
|
void pwrResetHandler();
|
||||||
uint32_t pwrPressed(void);
|
bool pwrPressed();
|
||||||
uint32_t pwrPressedDuration(void);
|
uint32_t pwrPressedDuration();
|
||||||
#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN)
|
#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN)
|
||||||
#define UNEXPECTED_SHUTDOWN() (false)
|
#define UNEXPECTED_SHUTDOWN() (false)
|
||||||
#else
|
#else
|
||||||
|
@ -471,10 +471,10 @@ uint32_t pwrPressedDuration(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Led driver
|
// Led driver
|
||||||
void ledInit(void);
|
void ledInit();
|
||||||
void ledOff(void);
|
void ledOff();
|
||||||
void ledRed(void);
|
void ledRed();
|
||||||
void ledBlue(void);
|
void ledBlue();
|
||||||
#if defined(PCBX10)
|
#if defined(PCBX10)
|
||||||
void ledGreen();
|
void ledGreen();
|
||||||
#endif
|
#endif
|
||||||
|
@ -483,15 +483,15 @@ void ledBlue(void);
|
||||||
#define LCD_W 480
|
#define LCD_W 480
|
||||||
#define LCD_H 272
|
#define LCD_H 272
|
||||||
#define LCD_DEPTH 16
|
#define LCD_DEPTH 16
|
||||||
void lcdInit(void);
|
void lcdInit();
|
||||||
void lcdRefresh(void);
|
void lcdRefresh();
|
||||||
void lcdCopy(void * dest, void * src);
|
void lcdCopy(void * dest, void * src);
|
||||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
||||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
||||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
||||||
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
||||||
void lcdStoreBackupBuffer(void);
|
void lcdStoreBackupBuffer();
|
||||||
int lcdRestoreBackupBuffer(void);
|
int lcdRestoreBackupBuffer();
|
||||||
void lcdSetContrast();
|
void lcdSetContrast();
|
||||||
#define lcdOff() backlightEnable(0) /* just disable the backlight */
|
#define lcdOff() backlightEnable(0) /* just disable the backlight */
|
||||||
#define lcdSetRefVolt(...)
|
#define lcdSetRefVolt(...)
|
||||||
|
|
|
@ -96,14 +96,14 @@ void pwrOff()
|
||||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pwrPressed()
|
bool pwrPressed()
|
||||||
{
|
{
|
||||||
return GPIO_ReadInputDataBit(PWR_ON_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
return GPIO_ReadInputDataBit(PWR_ON_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwrResetHandler()
|
void pwrResetHandler()
|
||||||
{
|
{
|
||||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOJEN;
|
RCC->AHB1ENR |= PWR_RCC_AHB1Periph;
|
||||||
|
|
||||||
// these two NOPs are needed (see STM32F errata sheet) before the peripheral
|
// these two NOPs are needed (see STM32F errata sheet) before the peripheral
|
||||||
// register can be written after the peripheral clock was enabled
|
// register can be written after the peripheral clock was enabled
|
||||||
|
@ -137,9 +137,11 @@ void pwrResetHandler()
|
||||||
if (shutdownReason == DIRTY_SHUTDOWN) {
|
if (shutdownReason == DIRTY_SHUTDOWN) {
|
||||||
powerupReason = DIRTY_SHUTDOWN;
|
powerupReason = DIRTY_SHUTDOWN;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
|
||||||
#endif
|
|
||||||
pwrOn();
|
pwrOn();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||||
|
pwrOn();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,11 +458,7 @@ uint32_t pwrCheck()
|
||||||
return simu_shutdown ? e_power_off : e_power_on;
|
return simu_shutdown ? e_power_off : e_power_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwrOff()
|
bool pwrPressed()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pwrPressed()
|
|
||||||
{
|
{
|
||||||
// TODO: simulate power button
|
// TODO: simulate power button
|
||||||
#if defined(PWR_SWITCH_GPIO) // STM32
|
#if defined(PWR_SWITCH_GPIO) // STM32
|
||||||
|
@ -478,6 +474,14 @@ void pwrInit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pwrOn()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void pwrOff()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void readKeysAndTrims()
|
void readKeysAndTrims()
|
||||||
{
|
{
|
||||||
uint8_t index = 0;
|
uint8_t index = 0;
|
||||||
|
|
|
@ -76,7 +76,7 @@ void backlightInit()
|
||||||
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
|
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
|
||||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E;
|
BACKLIGHT_TIMER->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E;
|
||||||
BACKLIGHT_TIMER->CCR2 = 0;
|
BACKLIGHT_TIMER->CCR2 = 0;
|
||||||
BACKLIGHT_TIMER->CCR4 = 100;
|
BACKLIGHT_TIMER->CCR4 = 0;
|
||||||
BACKLIGHT_TIMER->EGR = 0;
|
BACKLIGHT_TIMER->EGR = 0;
|
||||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,21 +41,6 @@ void watchdogInit(unsigned int duration)
|
||||||
IWDG->KR = 0xCCCC; // start
|
IWDG->KR = 0xCCCC; // start
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
|
||||||
#define PWR_PRESS_DURATION_MIN 100 // 1s
|
|
||||||
#define PWR_PRESS_DURATION_MAX 500 // 5s
|
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
const unsigned char bmp_startup[] = {
|
|
||||||
#include "startup.lbm"
|
|
||||||
};
|
|
||||||
|
|
||||||
const unsigned char bmp_lock[] = {
|
|
||||||
#include "lock.lbm"
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SPORT_UPDATE_PWR_GPIO)
|
#if defined(SPORT_UPDATE_PWR_GPIO)
|
||||||
void sportUpdateInit()
|
void sportUpdateInit()
|
||||||
{
|
{
|
||||||
|
@ -189,63 +174,6 @@ void boardInit()
|
||||||
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
|
||||||
if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
|
||||||
lcdClear();
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
lcdDrawBitmap(76, 2, bmp_lock, 0, 60);
|
|
||||||
#else
|
|
||||||
lcdDrawFilledRect(LCD_W / 2 - 18, LCD_H / 2 - 3, 6, 6, SOLID, 0);
|
|
||||||
#endif
|
|
||||||
lcdRefresh();
|
|
||||||
lcdRefreshWait();
|
|
||||||
|
|
||||||
tmr10ms_t start = get_tmr10ms();
|
|
||||||
tmr10ms_t duration = 0;
|
|
||||||
uint8_t pwr_on = 0;
|
|
||||||
while (pwrPressed()) {
|
|
||||||
duration = get_tmr10ms() - start;
|
|
||||||
if (duration < PWR_PRESS_DURATION_MIN) {
|
|
||||||
unsigned index = duration / (PWR_PRESS_DURATION_MIN / 4);
|
|
||||||
lcdClear();
|
|
||||||
#if LCD_DEPTH > 1
|
|
||||||
lcdDrawBitmap(76, 2, bmp_startup, index*60, 60);
|
|
||||||
#else
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (duration >= PWR_PRESS_DURATION_MAX) {
|
|
||||||
drawSleepBitmap();
|
|
||||||
backlightDisable();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (pwr_on != 1) {
|
|
||||||
pwr_on = 1;
|
|
||||||
pwrOn();
|
|
||||||
backlightInit();
|
|
||||||
haptic.play(15, 3, PLAY_NOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lcdRefresh();
|
|
||||||
lcdRefreshWait();
|
|
||||||
}
|
|
||||||
if (duration < PWR_PRESS_DURATION_MIN || duration >= PWR_PRESS_DURATION_MAX) {
|
|
||||||
boardOff();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pwrOn();
|
|
||||||
backlightInit();
|
|
||||||
}
|
|
||||||
#else // defined(PWR_BUTTON_PRESS)
|
|
||||||
pwrOn();
|
|
||||||
backlightInit();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TOPLCD_GPIO)
|
#if defined(TOPLCD_GPIO)
|
||||||
toplcdInit();
|
toplcdInit();
|
||||||
#endif
|
#endif
|
||||||
|
@ -266,6 +194,12 @@ void boardInit()
|
||||||
#if defined(GYRO)
|
#if defined(GYRO)
|
||||||
gyroInit();
|
gyroInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
||||||
|
rtcInit(); // RTC must be initialized before rambackupRestore() is called
|
||||||
|
#endif
|
||||||
|
|
||||||
|
backlightInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void boardOff()
|
void boardOff()
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||||
// Rotary Encoder driver
|
// Rotary Encoder driver
|
||||||
void rotaryEncoderInit(void);
|
void rotaryEncoderInit();
|
||||||
void rotaryEncoderCheck(void);
|
void rotaryEncoderCheck();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FLASHSIZE 0x80000
|
#define FLASHSIZE 0x80000
|
||||||
|
@ -54,8 +54,8 @@ void rotaryEncoderCheck(void);
|
||||||
extern uint16_t sessionTimer;
|
extern uint16_t sessionTimer;
|
||||||
|
|
||||||
// Board driver
|
// Board driver
|
||||||
void boardInit(void);
|
void boardInit();
|
||||||
void boardOff(void);
|
void boardOff();
|
||||||
|
|
||||||
// Timers driver
|
// Timers driver
|
||||||
void init2MhzTimer();
|
void init2MhzTimer();
|
||||||
|
@ -64,8 +64,8 @@ void init5msTimer();
|
||||||
// SD driver
|
// SD driver
|
||||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||||
uint32_t sdIsHC(void);
|
uint32_t sdIsHC();
|
||||||
uint32_t sdGetSpeed(void);
|
uint32_t sdGetSpeed();
|
||||||
#define SD_IS_HC() (sdIsHC())
|
#define SD_IS_HC() (sdIsHC())
|
||||||
#define SD_GET_SPEED() (sdGetSpeed())
|
#define SD_GET_SPEED() (sdGetSpeed())
|
||||||
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
||||||
|
@ -83,18 +83,18 @@ uint32_t sdGetSpeed(void);
|
||||||
#define sdMount()
|
#define sdMount()
|
||||||
#define SD_CARD_PRESENT() true
|
#define SD_CARD_PRESENT() true
|
||||||
#else
|
#else
|
||||||
void sdInit(void);
|
void sdInit();
|
||||||
void sdMount(void);
|
void sdMount();
|
||||||
void sdDone(void);
|
void sdDone();
|
||||||
void sdPoll10ms(void);
|
void sdPoll10ms();
|
||||||
uint32_t sdMounted(void);
|
uint32_t sdMounted();
|
||||||
#define SD_CARD_PRESENT() ((SD_GPIO_PRESENT_GPIO->IDR & SD_GPIO_PRESENT_GPIO_PIN) == 0)
|
#define SD_CARD_PRESENT() ((SD_GPIO_PRESENT_GPIO->IDR & SD_GPIO_PRESENT_GPIO_PIN) == 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Flash Write driver
|
// Flash Write driver
|
||||||
#define FLASH_PAGESIZE 256
|
#define FLASH_PAGESIZE 256
|
||||||
void unlockFlash(void);
|
void unlockFlash();
|
||||||
void lockFlash(void);
|
void lockFlash();
|
||||||
void flashWrite(uint32_t * address, uint32_t * buffer);
|
void flashWrite(uint32_t * address, uint32_t * buffer);
|
||||||
uint32_t isFirmwareStart(const uint8_t * buffer);
|
uint32_t isFirmwareStart(const uint8_t * buffer);
|
||||||
uint32_t isBootloaderStart(const uint8_t * buffer);
|
uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||||
|
@ -603,15 +603,16 @@ extern "C" {
|
||||||
|
|
||||||
// Power driver
|
// Power driver
|
||||||
#define SOFT_PWR_CTRL
|
#define SOFT_PWR_CTRL
|
||||||
void pwrInit(void);
|
void pwrInit();
|
||||||
uint32_t pwrCheck(void);
|
uint32_t pwrCheck();
|
||||||
void pwrOn(void);
|
void pwrOn();
|
||||||
void pwrOff(void);
|
void pwrOff();
|
||||||
uint32_t pwrPressed(void);
|
bool pwrPressed();
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
uint32_t pwrPressedDuration(void);
|
#define STARTUP_ANIMATION
|
||||||
|
uint32_t pwrPressedDuration();
|
||||||
#endif
|
#endif
|
||||||
void pwrResetHandler(void);
|
void pwrResetHandler();
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
#define UNEXPECTED_SHUTDOWN() false
|
#define UNEXPECTED_SHUTDOWN() false
|
||||||
|
@ -620,10 +621,10 @@ void pwrResetHandler(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Backlight driver
|
// Backlight driver
|
||||||
void backlightInit(void);
|
void backlightInit();
|
||||||
void backlightDisable(void);
|
void backlightDisable();
|
||||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||||
uint8_t isBacklightEnabled(void);
|
uint8_t isBacklightEnabled();
|
||||||
#if defined(PCBX9E) || defined(PCBX9DP)
|
#if defined(PCBX9E) || defined(PCBX9DP)
|
||||||
void backlightEnable(uint8_t level, uint8_t color);
|
void backlightEnable(uint8_t level, uint8_t color);
|
||||||
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||||
|
@ -646,7 +647,7 @@ uint8_t isBacklightEnabled(void);
|
||||||
// I2C driver: EEPROM + Audio Volume
|
// I2C driver: EEPROM + Audio Volume
|
||||||
#define EEPROM_SIZE (32*1024)
|
#define EEPROM_SIZE (32*1024)
|
||||||
|
|
||||||
void i2cInit(void);
|
void i2cInit();
|
||||||
void eepromReadBlock(uint8_t * buffer, size_t address, size_t size);
|
void eepromReadBlock(uint8_t * buffer, size_t address, size_t size);
|
||||||
void eepromStartWrite(uint8_t * buffer, size_t address, size_t size);
|
void eepromStartWrite(uint8_t * buffer, size_t address, size_t size);
|
||||||
uint8_t eepromIsTransferComplete();
|
uint8_t eepromIsTransferComplete();
|
||||||
|
@ -656,8 +657,8 @@ void debugPutc(const char c);
|
||||||
|
|
||||||
// Telemetry driver
|
// Telemetry driver
|
||||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode);
|
void telemetryPortInit(uint32_t baudrate, uint8_t mode);
|
||||||
void telemetryPortSetDirectionInput(void);
|
void telemetryPortSetDirectionInput();
|
||||||
void telemetryPortSetDirectionOutput(void);
|
void telemetryPortSetDirectionOutput();
|
||||||
void sportSendByte(uint8_t byte);
|
void sportSendByte(uint8_t byte);
|
||||||
void sportSendByteLoop(uint8_t byte);
|
void sportSendByteLoop(uint8_t byte);
|
||||||
void sportStopSendByteLoop();
|
void sportStopSendByteLoop();
|
||||||
|
@ -678,9 +679,9 @@ extern uint32_t telemetryErrors;
|
||||||
|
|
||||||
// Sport update driver
|
// Sport update driver
|
||||||
#if defined(SPORT_UPDATE_PWR_GPIO)
|
#if defined(SPORT_UPDATE_PWR_GPIO)
|
||||||
void sportUpdateInit(void);
|
void sportUpdateInit();
|
||||||
void sportUpdatePowerOn(void);
|
void sportUpdatePowerOn();
|
||||||
void sportUpdatePowerOff(void);
|
void sportUpdatePowerOff();
|
||||||
#define SPORT_UPDATE_POWER_ON() sportUpdatePowerOn()
|
#define SPORT_UPDATE_POWER_ON() sportUpdatePowerOn()
|
||||||
#define SPORT_UPDATE_POWER_OFF() sportUpdatePowerOff()
|
#define SPORT_UPDATE_POWER_OFF() sportUpdatePowerOff()
|
||||||
#else
|
#else
|
||||||
|
@ -690,38 +691,38 @@ void sportUpdatePowerOff(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Audio driver
|
// Audio driver
|
||||||
void audioInit(void) ;
|
void audioInit() ;
|
||||||
void audioEnd(void) ;
|
void audioEnd() ;
|
||||||
void dacStart(void);
|
void dacStart();
|
||||||
void dacStop(void);
|
void dacStop();
|
||||||
void setSampleRate(uint32_t frequency);
|
void setSampleRate(uint32_t frequency);
|
||||||
#define VOLUME_LEVEL_MAX 23
|
#define VOLUME_LEVEL_MAX 23
|
||||||
#define VOLUME_LEVEL_DEF 12
|
#define VOLUME_LEVEL_DEF 12
|
||||||
#if !defined(SOFTWARE_VOLUME)
|
#if !defined(SOFTWARE_VOLUME)
|
||||||
void setScaledVolume(uint8_t volume);
|
void setScaledVolume(uint8_t volume);
|
||||||
void setVolume(uint8_t volume);
|
void setVolume(uint8_t volume);
|
||||||
int32_t getVolume(void);
|
int32_t getVolume();
|
||||||
#endif
|
#endif
|
||||||
#if defined(AUDIO_SPEAKER_ENABLE_GPIO)
|
#if defined(AUDIO_SPEAKER_ENABLE_GPIO)
|
||||||
void initSpeakerEnable(void);
|
void initSpeakerEnable();
|
||||||
void enableSpeaker();
|
void enableSpeaker();
|
||||||
void disableSpeaker();
|
void disableSpeaker();
|
||||||
#else
|
#else
|
||||||
static inline void initSpeakerEnable(void) { }
|
static inline void initSpeakerEnable() { }
|
||||||
static inline void enableSpeaker(void) { }
|
static inline void enableSpeaker() { }
|
||||||
static inline void disableSpeaker(void) { }
|
static inline void disableSpeaker() { }
|
||||||
#endif
|
#endif
|
||||||
#if defined(HEADPHONE_TRAINER_SWITCH_GPIO)
|
#if defined(HEADPHONE_TRAINER_SWITCH_GPIO)
|
||||||
void initHeadphoneTrainerSwitch(void);
|
void initHeadphoneTrainerSwitch();
|
||||||
void enableHeadphone(void);
|
void enableHeadphone();
|
||||||
void enableTrainer(void);
|
void enableTrainer();
|
||||||
#else
|
#else
|
||||||
static inline void initHeadphoneTrainerSwitch(void) { }
|
static inline void initHeadphoneTrainerSwitch() { }
|
||||||
static inline void enableHeadphone(void) { }
|
static inline void enableHeadphone() { }
|
||||||
static inline void enableTrainer(void) { }
|
static inline void enableTrainer() { }
|
||||||
#endif
|
#endif
|
||||||
#if defined(JACK_DETECT_GPIO)
|
#if defined(JACK_DETECT_GPIO)
|
||||||
void initJackDetect(void);
|
void initJackDetect();
|
||||||
bool isJackPlugged();
|
bool isJackPlugged();
|
||||||
#endif
|
#endif
|
||||||
void audioConsumeCurrentBuffer();
|
void audioConsumeCurrentBuffer();
|
||||||
|
@ -729,12 +730,12 @@ void audioConsumeCurrentBuffer();
|
||||||
#define audioEnableIrq() __enable_irq()
|
#define audioEnableIrq() __enable_irq()
|
||||||
|
|
||||||
// Haptic driver
|
// Haptic driver
|
||||||
void hapticInit(void);
|
void hapticInit();
|
||||||
void hapticOff(void);
|
void hapticOff();
|
||||||
#if defined(HAPTIC_PWM)
|
#if defined(HAPTIC_PWM)
|
||||||
void hapticOn(uint32_t pwmPercent);
|
void hapticOn(uint32_t pwmPercent);
|
||||||
#else
|
#else
|
||||||
void hapticOn(void);
|
void hapticOn();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Second serial port driver
|
// Second serial port driver
|
||||||
|
@ -745,8 +746,8 @@ extern uint8_t auxSerialMode;
|
||||||
void auxSerialInit(unsigned int mode, unsigned int protocol);
|
void auxSerialInit(unsigned int mode, unsigned int protocol);
|
||||||
void auxSerialPutc(char c);
|
void auxSerialPutc(char c);
|
||||||
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
|
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
|
||||||
void auxSerialSbusInit(void);
|
void auxSerialSbusInit();
|
||||||
void auxSerialStop(void);
|
void auxSerialStop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BT driver
|
// BT driver
|
||||||
|
@ -760,9 +761,9 @@ void auxSerialStop(void);
|
||||||
#define BT_TX_FIFO_SIZE 64
|
#define BT_TX_FIFO_SIZE 64
|
||||||
#define BT_RX_FIFO_SIZE 128
|
#define BT_RX_FIFO_SIZE 128
|
||||||
void bluetoothInit(uint32_t baudrate, bool enable);
|
void bluetoothInit(uint32_t baudrate, bool enable);
|
||||||
void bluetoothWriteWakeup(void);
|
void bluetoothWriteWakeup();
|
||||||
uint8_t bluetoothIsWriting(void);
|
uint8_t bluetoothIsWriting();
|
||||||
void bluetoothDisable(void);
|
void bluetoothDisable();
|
||||||
#if defined(PCBX9LITE)
|
#if defined(PCBX9LITE)
|
||||||
#define IS_BLUETOOTH_CHIP_PRESENT() (false)
|
#define IS_BLUETOOTH_CHIP_PRESENT() (false)
|
||||||
#elif (defined(PCBX7) || defined(PCBXLITE)) && !defined(SIMU)
|
#elif (defined(PCBX7) || defined(PCBXLITE)) && !defined(SIMU)
|
||||||
|
@ -773,11 +774,11 @@ void bluetoothDisable(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// LED driver
|
// LED driver
|
||||||
void ledInit(void);
|
void ledInit();
|
||||||
void ledOff(void);
|
void ledOff();
|
||||||
void ledRed(void);
|
void ledRed();
|
||||||
void ledGreen(void);
|
void ledGreen();
|
||||||
void ledBlue(void);
|
void ledBlue();
|
||||||
|
|
||||||
// LCD driver
|
// LCD driver
|
||||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E)
|
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E)
|
||||||
|
@ -803,9 +804,9 @@ void ledBlue(void);
|
||||||
#define IS_LCD_RESET_NEEDED() true
|
#define IS_LCD_RESET_NEEDED() true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void lcdInit(void);
|
void lcdInit();
|
||||||
void lcdInitFinish(void);
|
void lcdInitFinish();
|
||||||
void lcdOff(void);
|
void lcdOff();
|
||||||
|
|
||||||
// TODO lcdRefreshWait() stub in simpgmspace and remove LCD_DUAL_BUFFER
|
// TODO lcdRefreshWait() stub in simpgmspace and remove LCD_DUAL_BUFFER
|
||||||
#if defined(LCD_DMA) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU)
|
#if defined(LCD_DMA) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU)
|
||||||
|
@ -814,19 +815,19 @@ void lcdRefreshWait();
|
||||||
#define lcdRefreshWait()
|
#define lcdRefreshWait()
|
||||||
#endif
|
#endif
|
||||||
#if defined(PCBX9D) || defined(SIMU) || !defined(__cplusplus)
|
#if defined(PCBX9D) || defined(SIMU) || !defined(__cplusplus)
|
||||||
void lcdRefresh(void);
|
void lcdRefresh();
|
||||||
#else
|
#else
|
||||||
void lcdRefresh(bool wait=true); // TODO uint8_t wait to simplify this
|
void lcdRefresh(bool wait=true); // TODO uint8_t wait to simplify this
|
||||||
#endif
|
#endif
|
||||||
void lcdSetRefVolt(unsigned char val);
|
void lcdSetRefVolt(unsigned char val);
|
||||||
void lcdSetContrast(void);
|
void lcdSetContrast();
|
||||||
|
|
||||||
// Top LCD driver
|
// Top LCD driver
|
||||||
#if defined(TOPLCD_GPIO)
|
#if defined(TOPLCD_GPIO)
|
||||||
void toplcdInit(void);
|
void toplcdInit();
|
||||||
void toplcdOff(void);
|
void toplcdOff();
|
||||||
void toplcdRefreshStart(void);
|
void toplcdRefreshStart();
|
||||||
void toplcdRefreshEnd(void);
|
void toplcdRefreshEnd();
|
||||||
void setTopFirstTimer(int32_t value);
|
void setTopFirstTimer(int32_t value);
|
||||||
void setTopSecondTimer(uint32_t value);
|
void setTopSecondTimer(uint32_t value);
|
||||||
void setTopRssi(uint32_t rssi);
|
void setTopRssi(uint32_t rssi);
|
||||||
|
|
|
@ -83,14 +83,14 @@ void pwrOff()
|
||||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pwrPressed()
|
bool pwrPressed()
|
||||||
{
|
{
|
||||||
return GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
return GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwrResetHandler()
|
void pwrResetHandler()
|
||||||
{
|
{
|
||||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN;
|
RCC->AHB1ENR |= PWR_RCC_AHB1Periph;
|
||||||
|
|
||||||
// these two NOPs are needed (see STM32F errata sheet) before the peripheral
|
// these two NOPs are needed (see STM32F errata sheet) before the peripheral
|
||||||
// register can be written after the peripheral clock was enabled
|
// register can be written after the peripheral clock was enabled
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue