New UI merged

This commit is contained in:
Bertrand Songis
2019-08-28 20:50:14 +02:00
parent 1f41076b0e
commit f4f8893ae9
806 changed files with 30836 additions and 11704 deletions
+75 -19
View File
@@ -21,6 +21,12 @@
#include <io/frsky_firmware_update.h>
#include "opentx.h"
#if defined(LIBOPENUI)
// #include "shutdown_animation.h"
// #include "radio_calibration.h"
#include "view_main.h"
#endif
RadioData g_eeGeneral;
ModelData g_model;
@@ -119,7 +125,11 @@ void per10ms()
#if defined(GUI)
if (lightOffCounter) lightOffCounter--;
if (flashCounter) flashCounter--;
#if defined(LIBOPENUI)
#warning "TODO remove noHighlightCounter on LIBOPENUI"
#else
if (noHighlightCounter) noHighlightCounter--;
#endif
#endif
if (trimsCheckTimer) trimsCheckTimer--;
@@ -530,17 +540,18 @@ void modelDefault(uint8_t id)
g_model.header.name[6] = '\033' + id%10;
#endif
#if defined(PCBHORUS)
#if defined(COLORLCD)
#warning "Initialization missing"
extern const LayoutFactory * defaultLayout;
delete customScreens[0];
customScreens[0] = defaultLayout->create(&g_model.screenData[0].layoutData);
strcpy(g_model.screenData[0].layoutName, "Layout2P1");
extern const WidgetFactory * defaultWidget;
customScreens[0]->createWidget(0, defaultWidget);
// enable switch warnings
for (int i=0; i<NUM_SWITCHES; i++) {
g_model.switchWarningState |= (1 << (3*i));
}
// delete customScreens[0];
// customScreens[0] = defaultLayout->create(&g_model.screenData[0].layoutData);
// strcpy(g_model.screenData[0].layoutName, "Layout2P1");
// extern const WidgetFactory * defaultWidget;
// customScreens[0]->createWidget(0, defaultWidget);
// // enable switch warnings
// for (int i=0; i<NUM_SWITCHES; i++) {
// g_model.switchWarningState |= (1 << (3*i));
// }
#endif
}
@@ -780,7 +791,8 @@ void doSplash()
getADC();
if (keyDown() || inputsMoved()) return;
if (getEvent() || inputsMoved())
return;
#if defined(PWR_BUTTON_PRESS)
uint32_t pwr_check = pwrCheck();
@@ -866,7 +878,7 @@ static void checkRTCBattery()
}
#endif
#if defined(PCBTARANIS) || defined(PCBHORUS)
#if defined(PCBFRSKY) || defined(PCBFLYSKY)
void checkFailsafe()
{
for (int i=0; i<NUM_MODULES; i++) {
@@ -913,9 +925,13 @@ void checkAll()
checkRTCBattery();
#endif
#if defined(COLORLCD)
#warning "Model notes missing"
#else
if (g_model.displayChecklist && modelHasNotes()) {
readModelNotes();
}
#endif
if (!waitKeysReleased()) {
showMessageBox(STR_KEYSTUCK);
@@ -963,6 +979,19 @@ bool isThrottleWarningAlertNeeded()
return v > THRCHK_DEADBAND - 1024;
}
#if defined(COLORLCD)
void checkThrottleStick()
{
if (isThrottleWarningAlertNeeded()) {
AUDIO_ERROR_MESSAGE(AU_THROTTLE_ALERT);
auto dialog = new FullScreenDialog(WARNING_TYPE_ALERT, STR_THROTTLEWARN, STR_THROTTLENOTIDLE);
dialog->setCloseCondition([]() {
return !isThrottleWarningAlertNeeded();
});
dialog->runForever();
}
}
#else
void checkThrottleStick()
{
if (!isThrottleWarningAlertNeeded()) {
@@ -1009,6 +1038,7 @@ void checkThrottleStick()
LED_ERROR_END();
}
#endif
void checkAlarm() // added by Gohst
{
@@ -1036,7 +1066,7 @@ void alert(const char * title, const char * msg , uint8_t sound)
while (1) {
RTOS_WAIT_MS(10);
if (keyDown()) // wait for key release
if (getEvent()) // wait for key release
break;
doLoopCommonActions();
@@ -1221,7 +1251,16 @@ void getADC()
DEBUG_TIMER_STOP(debugTimerAdcRead);
for (uint8_t x=0; x<NUM_ANALOGS; x++) {
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
uint16_t v;
#if defined(FLYSKY_HALL_STICKS)
if (x < 4)
v = get_hall_adc_value(x) >> (1 - ANALOG_SCALE);
else
v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
#else
v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
#endif
// Jitter filter:
// * pass trough any big change directly
@@ -1556,7 +1595,12 @@ void opentxStart(const uint8_t startOptions = OPENTX_START_DEFAULT_ARGS)
#if defined(GUI)
if (calibration_needed) {
#if defined(LIBOPENUI)
#warning "TODO add a startCalibration function"
// startCalibration();
#else
chainMenu(menuFirstCalib);
#endif
}
else if (!(startOptions & OPENTX_START_NO_CHECKS)) {
checkAlarm();
@@ -1624,14 +1668,16 @@ void opentxResume()
{
TRACE("opentxResume");
#if !defined(LIBOPENUI)
menuHandlers[0] = menuMainView;
#endif
sdMount();
storageReadAll();
#if defined(COLORLCD)
#warning "TODO call loadTheme (not sure, it has been removed in some earlier commit)"
loadTheme();
loadFontCache();
#endif
// removed to avoid the double warnings (throttle, switch, etc.)
@@ -1809,7 +1855,10 @@ void opentxInit()
{
TRACE("opentxInit");
#if defined(GUI)
#if defined(LIBOPENUI)
new ViewMain();
#elif defined(GUI)
// TODO add a function for this (duplicated)
menuHandlers[0] = menuMainView;
#if MENUS_LOCK != 2/*no menus*/
menuHandlers[1] = menuModelSelect;
@@ -1886,7 +1935,9 @@ void opentxInit()
// g_model.topbarData is still zero here (because it was not yet read from SDCARD),
// but we only remember the pointer to in in constructor.
// The storageReadAll() needs topbar object, so it must be created here
topbar = new Topbar(&g_model.topbarData);
// TODO topbar removed from new UI for now
// topbar = new Topbar(&g_model.topbarData);
// lua widget state must also be prepared before the call to storageReadAll()
LUA_INIT_THEMES_AND_WIDGETS();
@@ -1944,7 +1995,6 @@ void opentxInit()
#if defined(COLORLCD)
loadTheme();
loadFontCache();
#endif
if (g_eeGeneral.backlightMode != e_backlight_mode_off) {
@@ -2085,9 +2135,10 @@ uint32_t pwrCheck()
#else
while ((TELEMETRY_STREAMING() && !g_eeGeneral.disableRssiPoweroffAlarm)) {
#endif
#if !defined(COLORLCD)
lcdRefreshWait();
lcdClear();
POPUP_CONFIRMATION(STR_MODEL_SHUTDOWN, nullptr);
SET_WARNING_INFO(STR_MODEL_STILL_POWERED, sizeof(TR_MODEL_STILL_POWERED), 0);
event_t evt = getEvent(false);
@@ -2103,6 +2154,7 @@ uint32_t pwrCheck()
pwr_check_state = PWR_CHECK_PAUSED;
return e_power_on;
}
#endif
}
haptic.play(15, 3, PLAY_NOW);
pwr_check_state = PWR_CHECK_OFF;
@@ -2115,6 +2167,10 @@ uint32_t pwrCheck()
}
}
else {
#if defined(COLORLCD)
if (pwr_press_time != 0)
mainWindow.invalidate();
#endif
pwr_check_state = PWR_CHECK_ON;
pwr_press_time = 0;
}