Add support for pwr-on and power-off speed

This commit is contained in:
Raphael Coeffic
2019-08-16 21:02:47 +02:00
parent 8d9a7c22e6
commit 995888ae41
32 changed files with 927 additions and 739 deletions
+18 -1
View File
@@ -87,6 +87,8 @@ enum {
CASE_PWM_BACKLIGHT(ITEM_RADIO_SETUP_BACKLIGHT_BRIGHTNESS_ON)
ITEM_RADIO_SETUP_FLASH_BEEP,
CASE_SPLASH_PARAM(ITEM_RADIO_SETUP_DISABLE_SPLASH)
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_ON_SPEED)
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_OFF_SPEED)
CASE_PXX2(ITEM_RADIO_SETUP_OWNER_ID)
CASE_GPS(ITEM_RADIO_SETUP_TIMEZONE)
ITEM_RADIO_SETUP_ADJUST_RTC,
@@ -155,7 +157,8 @@ void menuRadioSetup(event_t event)
CASE_PWM_BACKLIGHT(0)
0,
CASE_SPLASH_PARAM(0)
CASE_PWR_BUTTON_PRESS(0)
CASE_PWR_BUTTON_PRESS(0)
CASE_PXX2(0) /* owner registration ID */
CASE_GPS(0)
@@ -506,6 +509,20 @@ void menuRadioSetup(event_t event)
}
#endif
#if defined(PWR_BUTTON_PRESS)
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed, attr|LEFT);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, 0, 3);
break;
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed, attr|LEFT);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, 0, 3);
break;
#endif
#if defined(PXX2)
case ITEM_RADIO_SETUP_OWNER_ID:
editSingleName(RADIO_SETUP_2ND_COLUMN, y, STR_OWNER_ID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID, event, attr);
+8 -6
View File
@@ -20,8 +20,6 @@
#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
@@ -30,9 +28,11 @@ const unsigned char bmp_sleep[] = {
#include "sleep.lbm"
};
void drawStartupAnimation(uint32_t duration)
void drawStartupAnimation(uint32_t duration, uint32_t total_duration)
{
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_DURATION_MIN / 5), 4);
if (total_duration == 0) return;
uint8_t index = limit<uint8_t>(0, duration / (total_duration / 5), 4);
lcdRefreshWait();
lcdClear();
@@ -47,9 +47,11 @@ void drawStartupAnimation(uint32_t duration)
lcdRefreshWait();
}
void drawShutdownAnimation(uint32_t duration, const char * message)
void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message)
{
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_SHUTDOWN_DELAY / 5), 4);
if (total_duration == 0) return;
uint8_t index = limit<uint8_t>(0, duration / (total_duration / 5), 4);
lcdRefreshWait();
lcdClear();
+18
View File
@@ -78,6 +78,8 @@ enum MenuRadioSetupItems {
CASE_PCBX9E_PCBX9DP(ITEM_RADIO_SETUP_BACKLIGHT_COLOR)
ITEM_RADIO_SETUP_FLASH_BEEP,
CASE_SPLASH_PARAM(ITEM_RADIO_SETUP_DISABLE_SPLASH)
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_ON_SPEED)
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_OFF_SPEED)
#if defined(PXX2)
ITEM_RADIO_SETUP_OWNER_ID,
#endif
@@ -155,6 +157,8 @@ void menuRadioSetup(event_t event)
CASE_PCBX9E_PCBX9DP(0) // backlight color
0, // flash beep
CASE_SPLASH_PARAM(0) // disable splash
CASE_PWR_BUTTON_PRESS(0) // pwr on speed
CASE_PWR_BUTTON_PRESS(0) // pwr off speed
CASE_PXX2(0)
CASE_GPS(LABEL(GPS))
CASE_GPS(0) // timezone
@@ -466,6 +470,20 @@ void menuRadioSetup(event_t event)
break;
#endif
#if defined(PWR_BUTTON_PRESS)
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed, attr|LEFT);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, 0, 3);
break;
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed, attr|LEFT);
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, 0, 3);
break;
#endif
#if defined(TELEMETRY_FRSKY) && defined(GPS)
case ITEM_RADIO_SETUP_LABEL_GPS:
lcdDrawTextAlignedLeft(y, STR_GPS);
+8 -6
View File
@@ -20,8 +20,6 @@
#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
@@ -42,9 +40,11 @@ const unsigned char bmp_sleep[] = {
#include "sleep.lbm"
};
void drawStartupAnimation(uint32_t duration)
void drawStartupAnimation(uint32_t duration, uint32_t total_duration)
{
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_DURATION_MIN / 5), 4);
if (total_duration == 0) return;
uint8_t index = limit<uint8_t>(0, duration / (total_duration / 5), 4);
lcdRefreshWait();
lcdClear();
@@ -57,9 +57,11 @@ void drawStartupAnimation(uint32_t duration)
lcdRefresh();
}
void drawShutdownAnimation(uint32_t duration, const char * message)
void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message)
{
uint8_t index = limit<uint8_t>(0, duration / (PWR_PRESS_SHUTDOWN_DELAY / 4), 3);
if (total_duration == 0) return;
uint8_t index = limit<uint8_t>(0, duration / (total_duration / 4), 3);
lcdRefreshWait();
lcdClear();
+9
View File
@@ -66,6 +66,7 @@ enum menuRadioSetupItems {
ITEM_SETUP_BRIGHTNESS,
ITEM_SETUP_DIM_LEVEL,
ITEM_SETUP_FLASH_BEEP,
CASE_PWR_BUTTON_PRESS(ITEM_SETUP_PWR_OFF_SPEED)
CASE_GPS(ITEM_SETUP_LABEL_GPS)
CASE_GPS(ITEM_SETUP_TIMEZONE)
CASE_GPS(ITEM_SETUP_ADJUST_RTC)
@@ -114,6 +115,7 @@ bool menuRadioSetup(event_t event)
CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0)
LABEL(ALARMS), 0, 0, 0, 0,
LABEL(BACKLIGHT), 0, 0, 0, 0, 0,
CASE_PWR_BUTTON_PRESS(0)
CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0)
CASE_PXX1(0) 0, 0, FAI_CHOICE_ROW 0, 0, 0, 0, 1/*to force edit mode*/ }); // Country code - Voice Language - Units - Fai choice - Play delay - USB mode - Chan order - Mode (1 to 4)
@@ -380,6 +382,13 @@ bool menuRadioSetup(event_t event)
g_eeGeneral.blOffBright = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.blOffBright, BACKLIGHT_LEVEL_MIN, BACKLIGHT_LEVEL_MAX, attr);
break;
#if defined(PWR_BUTTON_PRESS)
case ITEM_SETUP_PWR_OFF_SPEED:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PWR_OFF_SPEED);
g_eeGeneral.pwrOffSpeed = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.pwrOffSpeed, 0, 3, attr);
break;
#endif
case ITEM_SETUP_LABEL_GPS:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_GPS);
break;
+5 -3
View File
@@ -391,8 +391,10 @@ void drawSleepBitmap()
}
#define SHUTDOWN_CIRCLE_DIAMETER 150
void drawShutdownAnimation(uint32_t duration, const char * message)
void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message)
{
if (total_duration == 0) return;
static uint32_t lastDuration = 0xffffffff;
static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp"));
@@ -404,7 +406,7 @@ void drawShutdownAnimation(uint32_t duration, const char * message)
}
else {
lcdRestoreBackupBuffer();
int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5);
int quarter = duration / (total_duration / 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 >= 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);
@@ -413,7 +415,7 @@ void drawShutdownAnimation(uint32_t duration, const char * message)
}
else {
lcd->clear();
int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5);
int quarter = duration / (total_duration / 5);
for (int i=1; i<=4; i++) {
if (quarter >= i) {
lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, 20, TEXT_BGCOLOR);
+1 -1
View File
@@ -69,7 +69,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=nullptr, uint32_t options=0);
void drawSplash();
void drawSleepBitmap();
void drawShutdownAnimation(uint32_t duration, const char * message);
void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message);
// Main view standard widgets
void drawTopBar();
+2 -2
View File
@@ -36,8 +36,8 @@ 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 drawStartupAnimation(uint32_t duration, uint32_t total_duration);
void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message);
void drawSleepBitmap();
#endif // _COMMON_DRAW_FUNCTIONS_H_