Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(radio): Cleanup startup code. #4027

Merged
merged 5 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions radio/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ set(PCB "X9D+" CACHE STRING "Radio type, one of: ${PCB_TYPES}")
set_property(CACHE PCB PROPERTY STRINGS ${PCB_TYPES})
set(TRANSLATIONS "EN" CACHE STRING "Radio language, one of: ${RADIO_LANGUAGES}")
set_property(CACHE TRANSLATIONS PROPERTY STRINGS ${RADIO_LANGUAGES})
set(SPLASH "DEFAULT" CACHE STRING "Splash (DEFAULT/OFF/FRSKY)")
set_property(CACHE SPLASH PROPERTY STRINGS DEFAULT OFF FRSKY)
set(DEFAULT_MODE "" CACHE STRING "Default sticks mode")
set(POPUP_LEVEL 2 CACHE STRING "Popup level")

Expand Down Expand Up @@ -269,10 +267,6 @@ if(DANGEROUS_MODULE_FUNCTIONS)
add_definitions(-DDANGEROUS_MODULE_FUNCTIONS)
endif()

if(NOT SPLASH STREQUAL OFF)
add_definitions(-DSPLASH)
endif()

if(NOT DEFAULT_MODE STREQUAL "")
add_definitions(-DDEFAULT_MODE=${DEFAULT_MODE})
endif()
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/128x64/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "keys.h"
#include "common/stdlcd/menus.h"
#include "common/stdlcd/features.h"

#if defined(PCBTARANIS)
#define NAVIGATION_LINE_BY_LINE 0x40
Expand Down
11 changes: 2 additions & 9 deletions radio/src/gui/128x64/radio_diaganas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ void menuRadioDiagAnalogs(event_t event)

static int viewpage = ANAVIEW_FIRST;

// TODO enum
#if defined(TX_CAPACITY_MEASUREMENT)
#define ANAS_ITEMS_COUNT 3
#else
#define ANAS_ITEMS_COUNT 1
#endif

switch (event) {
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_BREAK(KEY_PAGEDN):
Expand Down Expand Up @@ -74,11 +67,11 @@ void menuRadioDiagAnalogs(event_t event)
switch (viewpage) {
case (ANAVIEW_CALIB):
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_CALIB,
HEADER_LINE+ANAS_ITEMS_COUNT);
HEADER_LINE+1);
break;
case (ANAVIEW_RAWLOWFPS):
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_RAWLOWFPS,
HEADER_LINE+ANAS_ITEMS_COUNT);
HEADER_LINE+1);
break;
}

Expand Down
19 changes: 1 addition & 18 deletions radio/src/gui/128x64/radio_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ const unsigned char sticks[] = {
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, nullptr, nullptr, tmp, -2, +2, attr, event); \
}

#if defined(SPLASH)
#define CASE_SPLASH_PARAM(x) x,
#else
#define CASE_SPLASH_PARAM(x)
#endif

#if defined(BATTGRAPH)
#define CASE_BATTGRAPH(x) x,
#else
Expand Down Expand Up @@ -83,7 +77,6 @@ enum {
CASE_IMU(ITEM_RADIO_SETUP_IMU_OFFSET)
ITEM_RADIO_SETUP_ALARMS_LABEL,
ITEM_RADIO_SETUP_BATTERY_WARNING,
CASE_CAPACITY(ITEM_RADIO_SETUP_CAPACITY_WARNING)
ITEM_RADIO_SETUP_INACTIVITY_ALARM,
ITEM_RADIO_SETUP_MEMORY_WARNING,
ITEM_RADIO_SETUP_ALARM_WARNING,
Expand Down Expand Up @@ -188,7 +181,7 @@ void menuRadioSetup(event_t event)
CASE_IMU(LABEL(IMU))
CASE_IMU(0)
CASE_IMU(0)
LABEL(ALARMS), 0, CASE_CAPACITY(0)
3djc marked this conversation as resolved.
Show resolved Hide resolved
LABEL(ALARMS), 0,
0, 0, 0, 0, /* ITEM_RADIO_SETUP_INACTIVITY_ALARM ITEM_RADIO_SETUP_MEMORY_WARNING ITEM_RADIO_SETUP_ALARM_WARNING ITEM_RADIO_SETUP_RSSI_POWEROFF_ALARM */
CASE_BACKLIGHT(LABEL(BACKLIGHT))
CASE_BACKLIGHT(0)
Expand Down Expand Up @@ -526,14 +519,6 @@ void menuRadioSetup(event_t event)
break;
}

#if defined(TX_CAPACITY_MEASUREMENT)
case ITEM_RADIO_SETUP_CAPACITY_WARNING:
lcdDrawTextAlignedLeft(y, STR_CAPAWARNING);
drawValueWithUnit(LCD_W-2, y, g_eeGeneral.mAhWarn*50, UNIT_MAH, attr|RIGHT) ;
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.mAhWarn, 0, 100);
break;
#endif

case ITEM_RADIO_SETUP_INACTIVITY_ALARM:
lcdDrawText(INDENT_WIDTH, y, STR_INACTIVITYALARM);
lcdDrawNumber(LCD_W-7, y, g_eeGeneral.inactivityTimer, attr|RIGHT);
Expand Down Expand Up @@ -588,7 +573,6 @@ void menuRadioSetup(event_t event)
break;
#endif

#if defined(SPLASH)
case ITEM_RADIO_SETUP_DISABLE_SPLASH:
{
lcdDrawTextAlignedLeft(y, STR_SPLASHSCREEN);
Expand All @@ -602,7 +586,6 @@ void menuRadioSetup(event_t event)
if (attr) g_eeGeneral.splashMode = -checkIncDecGen(event, -g_eeGeneral.splashMode, -3, 4);
break;
}
#endif

case ITEM_RADIO_SETUP_START_SOUND:
lcdDrawTextAlignedLeft(y, STR_PLAY_HELLO);
Expand Down
2 changes: 0 additions & 2 deletions radio/src/gui/128x64/splash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "opentx.h"

#if defined(SPLASH)
const unsigned char splashdata[] = {
'S','P','S',0,
#include "bitmaps/128x64/splash.lbm"
Expand All @@ -35,4 +34,3 @@ void drawSplash()
lcdDraw1bitBitmap(0, 0, splash_lbm, 0, 0);
lcdRefresh();
}
#endif
17 changes: 0 additions & 17 deletions radio/src/gui/128x64/view_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,25 +169,8 @@ void menuStatisticsDebug(event_t event)
break;
}


uint8_t y = FH + 1;

#if defined(TX_CAPACITY_MEASUREMENT)
// current
lcdDrawTextAlignedLeft(y, STR_CPU_CURRENT);
drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, getCurrent(), UNIT_MILLIAMPS, LEFT);
uint32_t current_scale = 488 + g_eeGeneral.txCurrentCalibration;
lcdDrawChar(MENU_DEBUG_COL2_OFS, y, '>');
drawValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, y, Current_max*10*current_scale/8192, UNIT_RAW, LEFT);
y += FH;

// consumption
lcdDrawTextAlignedLeft(y, STR_CPU_MAH);
drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1);
y += FH;
#endif


lcdDrawTextAlignedLeft(y, STR_FREE_MEM_LABEL);
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, availableMemory(), LEFT);
lcdDrawText(lcdLastRightPos+FW, y, STR_BYTES);
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/212x64/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "keys.h"
#include "common/stdlcd/menus.h"
#include "common/stdlcd/features.h"

inline bool isRadioMenuDisplayed()
{
Expand Down
8 changes: 0 additions & 8 deletions radio/src/gui/212x64/radio_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ const unsigned char sticks[] = {
value = editChoice(RADIO_SETUP_2ND_COLUMN, y, nullptr, nullptr, tmp, -2, +2, attr, event); \
}

#if defined(SPLASH)
#define CASE_SPLASH_PARAM(x) x,
#else
#define CASE_SPLASH_PARAM(x)
#endif

enum MenuRadioSetupItems {
CASE_RTCLOCK(ITEM_RADIO_SETUP_DATE)
CASE_RTCLOCK(ITEM_RADIO_SETUP_TIME)
Expand Down Expand Up @@ -535,7 +529,6 @@ void menuRadioSetup(event_t event)
break;
#endif

#if defined(SPLASH)
case ITEM_RADIO_SETUP_DISABLE_SPLASH:
lcdDrawTextAlignedLeft(y, STR_SPLASHSCREEN);
if (SPLASH_NEEDED()) {
Expand All @@ -547,7 +540,6 @@ void menuRadioSetup(event_t event)
}
if (attr) g_eeGeneral.splashMode = -checkIncDecGen(event, -g_eeGeneral.splashMode, -3, 4);
break;
#endif

case ITEM_RADIO_SETUP_START_SOUND:
lcdDrawTextAlignedLeft(y, STR_PLAY_HELLO);
Expand Down
2 changes: 0 additions & 2 deletions radio/src/gui/212x64/splash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "opentx.h"

#if defined(SPLASH)
#define MAXIMUM_SPLASH_IMAGE_SIZE 3072
const struct {
const uint8_t __magic_prefix[4] = { 'S','P','S',0 };
Expand All @@ -39,4 +38,3 @@ void drawSplash()
lcdDrawRleBitmap(0, 0, splash_lbm);
lcdRefresh();
}
#endif
88 changes: 48 additions & 40 deletions radio/src/gui/colorlcd/fullscreen_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,62 +49,70 @@ FullScreenDialog::FullScreenDialog(

bringToTop();

init();
build();

lv_obj_add_event_cb(lvobj, FullScreenDialog::long_pressed, LV_EVENT_LONG_PRESSED, nullptr);
lv_obj_add_event_cb(lvobj, FullScreenDialog::on_draw, LV_EVENT_DRAW_MAIN_BEGIN, nullptr);
}

void FullScreenDialog::init()
void FullScreenDialog::on_draw(lv_event_t* e)
{
if (!loaded) {
loaded = true;
auto dlg = (FullScreenDialog*)lv_obj_get_user_data(lv_event_get_target(e));
if (dlg) {
if (!dlg->loaded) {
dlg->loaded = true;
dlg->delayedInit();
}
}
}

std::string t;
if (type == WARNING_TYPE_ALERT) {
void FullScreenDialog::build()
{
std::string t;
if (type == WARNING_TYPE_ALERT) {
#if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ)
t = std::string(STR_WARNING) + "\n" + title;
t = std::string(STR_WARNING) + "\n" + title;
#else
t = title + "\n" + STR_WARNING;
t = title + "\n" + STR_WARNING;
#endif
} else if (!title.empty()) {
t = title;
}
new StaticText(this,
rect_t{ALERT_TITLE_LEFT, ALERT_TITLE_TOP, LCD_W - ALERT_TITLE_LEFT - PAGE_PADDING, LCD_H - ALERT_TITLE_TOP - PAGE_PADDING},
t.c_str(), 0, COLOR_THEME_WARNING | FONT(XL));

messageLabel = new StaticText(this,
rect_t{ALERT_MESSAGE_LEFT, ALERT_MESSAGE_TOP, LCD_W - ALERT_MESSAGE_LEFT - PAGE_PADDING, LCD_H - ALERT_MESSAGE_TOP - PAGE_PADDING},
message.c_str(), 0, COLOR_THEME_PRIMARY1 | FONT(BOLD));

if (!action.empty()) {
auto btn = new TextButton(this, { (LCD_W - 280) / 2, LCD_H - 48, 280, 40 }, action.c_str(),
} else if (!title.empty()) {
t = title;
}
new StaticText(this,
rect_t{ALERT_TITLE_LEFT, ALERT_TITLE_TOP, LCD_W - ALERT_TITLE_LEFT - PAGE_PADDING, LCD_H - ALERT_TITLE_TOP - PAGE_PADDING},
t.c_str(), 0, COLOR_THEME_WARNING | FONT(XL));

messageLabel = new StaticText(this,
rect_t{ALERT_MESSAGE_LEFT, ALERT_MESSAGE_TOP, LCD_W - ALERT_MESSAGE_LEFT - PAGE_PADDING, LCD_H - ALERT_MESSAGE_TOP - PAGE_PADDING},
message.c_str(), 0, COLOR_THEME_PRIMARY1 | FONT(BOLD));

if (!action.empty()) {
auto btn = new TextButton(this, { (LCD_W - 280) / 2, LCD_H - 48, 280, 40 }, action.c_str(),
[=]() {
closeDialog();
return 0;
}, COLOR_THEME_PRIMARY1 | FONT(BOLD));
lv_obj_set_style_bg_color(btn->getLvObj(), makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_style_bg_opa(btn->getLvObj(), LV_OPA_COVER, 0);
lv_obj_set_style_text_color(btn->getLvObj(), makeLvColor(COLOR_THEME_PRIMARY1), 0);
} else {
if (type == WARNING_TYPE_CONFIRM) {
auto btn = new TextButton(this, { LCD_W / 3 - 50, LCD_H - 48, 100, 40 }, STR_EXIT,
[=]() {
deleteLater();
return 0;
}, COLOR_THEME_PRIMARY1 | FONT(BOLD));
lv_obj_set_style_bg_color(btn->getLvObj(), makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_style_bg_opa(btn->getLvObj(), LV_OPA_COVER, 0);
lv_obj_set_style_text_color(btn->getLvObj(), makeLvColor(COLOR_THEME_PRIMARY1), 0);
btn = new TextButton(this, { LCD_W * 2 / 3 - 50, LCD_H - 48, 100, 40 }, STR_OK,
[=]() {
closeDialog();
return 0;
}, COLOR_THEME_PRIMARY1 | FONT(BOLD));
lv_obj_set_style_bg_color(btn->getLvObj(), makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_style_bg_opa(btn->getLvObj(), LV_OPA_COVER, 0);
lv_obj_set_style_text_color(btn->getLvObj(), makeLvColor(COLOR_THEME_PRIMARY1), 0);
} else {
if (type == WARNING_TYPE_CONFIRM) {
auto btn = new TextButton(this, { LCD_W / 3 - 50, LCD_H - 48, 100, 40 }, STR_EXIT,
[=]() {
deleteLater();
return 0;
}, COLOR_THEME_PRIMARY1 | FONT(BOLD));
lv_obj_set_style_bg_color(btn->getLvObj(), makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_style_bg_opa(btn->getLvObj(), LV_OPA_COVER, 0);
lv_obj_set_style_text_color(btn->getLvObj(), makeLvColor(COLOR_THEME_PRIMARY1), 0);
btn = new TextButton(this, { LCD_W * 2 / 3 - 50, LCD_H - 48, 100, 40 }, STR_OK,
[=]() {
closeDialog();
return 0;
}, COLOR_THEME_PRIMARY1 | FONT(BOLD));
lv_obj_set_style_bg_color(btn->getLvObj(), makeLvColor(COLOR_THEME_SECONDARY3), 0);
lv_obj_set_style_bg_opa(btn->getLvObj(), LV_OPA_COVER, 0);
lv_obj_set_style_text_color(btn->getLvObj(), makeLvColor(COLOR_THEME_PRIMARY1), 0);
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion radio/src/gui/colorlcd/fullscreen_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ class FullScreenDialog : public Window
bool loaded = false;
StaticText* messageLabel;

virtual void init();
virtual void delayedInit() {}
void build();

static void long_pressed(lv_event_t* e);
static void on_draw(lv_event_t* e);
};

#endif // _FULLSCREEN_DIALOG_H_
53 changes: 51 additions & 2 deletions radio/src/gui/colorlcd/splash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
* GNU General Public License for more details.
*/

#if defined(SPLASH)
#include "opentx.h"
#include "inactivity_timer.h"
#include "stamp.h"

extern void checkSpeakerVolume();

#include "opentx.h"
#include "stamp.h"
Expand Down Expand Up @@ -125,4 +129,49 @@ void drawSplash()

MainWindow::instance()->setActiveScreen();
}
#endif

static tmr10ms_t splashStartTime = 0;

void startSplash()
{
if (!UNEXPECTED_SHUTDOWN()) {
splashStartTime = get_tmr10ms();
drawSplash();
}
}

void waitSplash()
{
// Handle color splash screen
if (splashStartTime) {

#if defined(SIMU)
// Simulator - inputsMoved() returns true immediately without this!
RTOS_WAIT_TICKS(30);
#endif // defined(SIMU)

splashStartTime += SPLASH_TIMEOUT;
while (splashStartTime > get_tmr10ms()) {
WDG_RESET();
checkSpeakerVolume();
checkBacklight();
RTOS_WAIT_TICKS(10);
auto evt = getEvent();
if (evt || inactivityCheckInputs()) {
if (evt)
killEvents(evt);
break;
}
#if defined(SIMU)
// Allow simulator to exit if closed while splash showing
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
break;
}
#endif // defined(SIMU)
}

// Reset timer so special/global functions set to !1x don't get triggered
START_SILENCE_PERIOD();
}
}
Loading