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
@@ -1,9 +0,0 @@
set(GUI_SRC
${GUI_SRC}
../common/colorlcd/draw_functions.cpp
)
if(HELI)
set(GUI_SRC ${GUI_SRC} ../common/colorlcd/model_heli.cpp)
endif()
@@ -1,319 +0,0 @@
/*
* 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"
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix)
{
char s[64];
char * tmp = (prefix ? strAppend(s, prefix) : s);
tmp = strAppend(tmp, str);
tmp = strAppendUnsigned(tmp, abs(idx));
if (suffix)
strAppend(tmp, suffix);
lcdDrawText(x, y, s, flags);
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
char unitStr[8];
strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]);
lcdDrawNumber(x, y, val, att, 0, NULL, unitStr);
}
else {
lcdDrawNumber(x, y, val, att);
}
}
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event)
{
if (attr & INVERS) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
return value;
}
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event )
{
value = editChoice(x, y, NULL, value, 0, 1, attr, event);
drawCheckBox(x, y, value, attr);
return value;
}
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event)
{
if (attr & INVERS) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes);
drawSwitch(x, y, value, attr);
return value;
}
void drawFatalErrorScreen(const char * message)
{
lcdClear();
lcdDrawText(LCD_W/2, LCD_H/2-20, message, DBLSIZE|CENTERED|TEXT_BGCOLOR);
lcdRefresh();
}
void runFatalErrorScreen(const char * message)
{
while (1) {
drawFatalErrorScreen(message);
backlightEnable(100);
uint8_t refresh = false;
while (1) {
uint32_t pwr_check = pwrCheck();
if (pwr_check == e_power_off) {
boardOff();
return; // only happens in SIMU, required for proper shutdown
}
else if (pwr_check == e_power_press) {
refresh = true;
}
else if (pwr_check == e_power_on && refresh) {
break;
}
}
}
}
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att)
{
float power_W_PREC1 = pow(10.0, (dBm - 30.0) / 10.0) * 10;
if (dBm >= 30) {
lcdDrawNumber(x, y, power_W_PREC1, PREC1 | att);
lcdDrawText(lcdNextPos, y, "W", att);
}
else if (dBm < 10) {
uint16_t power_MW_PREC1 = round(power_W_PREC1 * 1000);
lcdDrawNumber(x, y, power_MW_PREC1, PREC1 | att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
else {
uint16_t power_MW = round(power_W_PREC1 * 100);
if (power_MW >= 50) {
power_MW = (power_MW / 5) * 5;
lcdDrawNumber(x, y, power_MW, att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
else {
lcdDrawNumber(x, y, power_MW, att);
lcdDrawText(lcdNextPos, y, "mW", att);
}
}
}
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags)
{
lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, flags);
}
#if defined(FLIGHT_MODES)
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
{
if (idx==0) {
lcdDrawMMM(x, y, att);
return;
}
// TODO this code was not included in Taranis! and used with abs(...) on Horus
if (idx < 0) {
lcdDrawChar(x-2, y, '!', att);
idx = -idx;
}
#if defined(CONDENSED)
if (att & CONDENSED) {
lcdDrawNumber(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
return;
}
#endif
drawStringWithIndex(x, y, STR_FM, idx-1, att);
}
#endif
/*
* 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"
void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags att)
{
if (curve.value != 0) {
switch (curve.type) {
case CURVE_REF_DIFF:
lcdDrawText(x, y, "D", att);
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
break;
case CURVE_REF_EXPO:
lcdDrawText(x, y, "E", att);
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
break;
case CURVE_REF_FUNC:
lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, curve.value, att);
break;
case CURVE_REF_CUSTOM:
drawCurveName(x, y, curve.value, att);
break;
}
}
}
void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, int32_t value, LcdFlags flags)
{
if (sensor >= MAX_TELEMETRY_SENSORS) {
// Lua luaLcdDrawChannel() can call us with a bad value
return;
}
TelemetryItem & telemetryItem = telemetryItems[sensor];
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[sensor];
if (telemetrySensor.unit == UNIT_DATETIME) {
drawDate(x, y, telemetryItem, flags);
}
else if (telemetrySensor.unit == UNIT_GPS) {
drawGPSSensorValue(x, y, telemetryItem, flags);
}
else if (telemetrySensor.unit == UNIT_BITFIELD) {
if (IS_FRSKY_SPORT_PROTOCOL()) {
if (telemetrySensor.id >= RBOX_STATE_FIRST_ID && telemetrySensor.id <= RBOX_STATE_LAST_ID) {
if (telemetrySensor.subId == 0) {
if (value == 0) {
lcdDrawText(x, y, "OK", flags);
}
else {
for (uint8_t i=0; i<16; i++) {
if (value & (1 << i)) {
char s[] = "CH__ KO";
strAppendUnsigned(&s[2], i+1, 2);
lcdDrawText(x, flags & DBLSIZE ? y+1 : y, s, flags & ~DBLSIZE);
break;
}
}
}
}
else {
if (value == 0) {
lcdDrawText(x, flags & DBLSIZE ? y+1 : y, "Rx OK", flags & ~DBLSIZE);
}
else {
static const char * const RXS_STATUS[] = {
"Rx1 Ovl",
"Rx2 Ovl",
"SBUS Ovl",
"Rx1 FS",
"Rx1 LF",
"Rx2 FS",
"Rx2 LF",
"Rx1 Lost",
"Rx2 Lost",
"Rx1 NS",
"Rx2 NS",
};
for (uint8_t i=0; i<DIM(RXS_STATUS); i++) {
if (value & (1<<i)) {
lcdDrawText(x, flags & DBLSIZE ? y+1 : y, RXS_STATUS[i], flags & ~DBLSIZE);
break;
}
}
}
}
}
}
}
else if (telemetrySensor.unit == UNIT_TEXT) {
lcdDrawSizedText(x, flags & DBLSIZE ? y+1 : y, telemetryItem.text, sizeof(telemetryItem.text), flags & ~DBLSIZE);
}
else {
if (telemetrySensor.prec > 0) {
flags |= (telemetrySensor.prec==1 ? PREC1 : PREC2);
}
drawValueWithUnit(x, y, value, telemetrySensor.unit == UNIT_CELLS ? UNIT_VOLTS : telemetrySensor.unit, flags);
}
}
void drawSourceCustomValue(coord_t x, coord_t y, source_t source, int32_t value, LcdFlags flags)
{
if (source >= MIXSRC_FIRST_TELEM) {
source = (source-MIXSRC_FIRST_TELEM) / 3;
drawSensorCustomValue(x, y, source, value, flags);
}
else if (source >= MIXSRC_FIRST_TIMER || source == MIXSRC_TX_TIME) {
if (value < 0) flags |= BLINK|INVERS;
drawTimer(x, y, value, flags);
}
else if (source == MIXSRC_TX_VOLTAGE) {
lcdDrawNumber(x, y, value, flags|PREC1);
}
#if defined(INTERNAL_GPS)
else if (source == MIXSRC_TX_GPS) {
if (gpsData.fix) {
drawGPSPosition(x, y, gpsData.longitude, gpsData.latitude, flags);
}
else {
lcdDrawText(x, y, "sats: ", flags);
lcdDrawNumber(lcdNextPos, y, gpsData.numSat, flags);
}
}
#endif
#if defined(GVARS)
else if (source >= MIXSRC_FIRST_GVAR && source <= MIXSRC_LAST_GVAR) {
drawGVarValue(x, y, source - MIXSRC_FIRST_GVAR, value, flags);
}
#endif
else if (source < MIXSRC_FIRST_CH) {
lcdDrawNumber(x, y, calcRESXto100(value), flags);
}
else if (source <= MIXSRC_LAST_CH) {
#if defined(PPM_UNIT_PERCENT_PREC1)
lcdDrawNumber(x, y, calcRESXto1000(value), flags|PREC1);
#else
lcdDrawNumber(x, y, calcRESXto100(value), flags);
#endif
}
else {
lcdDrawNumber(x, y, value, flags);
}
}
void drawSourceValue(coord_t x, coord_t y, source_t source, LcdFlags flags)
{
getvalue_t value = getValue(source);
drawSourceCustomValue(x, y, source, value, flags);
}
@@ -1,101 +0,0 @@
/*
* 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"
enum MenuModelHeliItems {
ITEM_HELI_SWASHTYPE,
ITEM_HELI_SWASHRING,
ITEM_HELI_ELE,
ITEM_HELI_ELE_WEIGHT,
ITEM_HELI_AIL,
ITEM_HELI_AIL_WEIGHT,
ITEM_HELI_COL,
ITEM_HELI_COL_WEIGHT,
ITEM_HELI_MAX
};
#define MODEL_HELI_2ND_COLUMN (230)
bool menuModelHeli(event_t event)
{
SIMPLE_MENU(STR_MENUHELISETUP, MODEL_ICONS, menuTabModel, MENU_MODEL_HELI, ITEM_HELI_MAX);
uint8_t sub = menuVerticalPosition;
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_CONTENT_TOP + i*FH;
int k = i+menuVerticalOffset;
LcdFlags blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
LcdFlags attr = (sub == k ? blink : 0);
switch (k) {
case ITEM_HELI_SWASHTYPE:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWASHTYPE);
g_model.swashR.type = editChoice(MODEL_HELI_2ND_COLUMN, y, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_MAX, attr, event);
break;
case ITEM_HELI_SWASHRING:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWASHRING);
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.value, LEFT|attr);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.swashR.value, 100);
break;
case ITEM_HELI_ELE:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ELEVATOR);
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorSource, attr);
if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.elevatorSource, 0, MIXSRC_LAST_CH);
break;
case ITEM_HELI_ELE_WEIGHT:
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorWeight, LEFT|attr);
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.elevatorWeight, -100, 100);
break;
case ITEM_HELI_AIL:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_AILERON);
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronSource, attr);
if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.aileronSource, 0, MIXSRC_LAST_CH);
break;
case ITEM_HELI_AIL_WEIGHT:
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronWeight, LEFT|attr);
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.aileronWeight, -100, 100);
break;
case ITEM_HELI_COL:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_COLLECTIVE);
drawSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveSource, attr);
if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.collectiveSource, 0, MIXSRC_LAST_CH);
break;
case ITEM_HELI_COL_WEIGHT:
lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT);
lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr);
if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100);
break;
}
}
return true;
}
@@ -217,6 +217,23 @@ void drawGVarName(coord_t x, coord_t y, int8_t idx, LcdFlags flags)
lcdDrawText(x, y, s, flags);
}
void editStickHardwareSettings(coord_t x, coord_t y, int idx, event_t event, LcdFlags flags)
{
lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, idx+1, 0);
if (ZEXIST(g_eeGeneral.anaNames[idx]) || (flags && s_editMode > 0))
editName(x, y, g_eeGeneral.anaNames[idx], LEN_ANA_NAME, event, flags);
else
lcdDrawMMM(x, y, flags);
}
bool isSwitchAvailableInCustomFunctions(int swtch)
{
if (menuHandlers[menuLevel] == menuModelSpecialFunctions)
return isSwitchAvailable(swtch, ModelCustomFunctionsContext);
else
return isSwitchAvailable(swtch, GeneralCustomFunctionsContext);
}
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att)
{
float power_W_PREC1 = pow(10.0, (dBm - 30.0) / 10.0) * 10;
@@ -37,6 +37,8 @@ inline void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att = 0)
drawTimer(x, y, tme, att, att);
}
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att = 0);
void drawStartupAnimation(uint32_t duration, uint32_t totalDuration);
void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message);
void drawSleepBitmap();
+1 -1
View File
@@ -183,7 +183,7 @@ void runPopupWarning(event_t event)
break;
case WARNING_TYPE_ASTERISK:
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, STR_EXIT);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, BUTTON(TR_EXIT));
break;
default:
+2
View File
@@ -23,6 +23,7 @@
#include <inttypes.h>
#include "audio.h"
#include "lcd.h"
extern const char * warningText;
extern const char * warningInfoText;
@@ -57,6 +58,7 @@ void showAlertBox(const char * title, const char * text, const char * action , u
// Full screen with 2 lines and a progress bar
void drawProgressScreen(const char * title, const char * message, int num, int den);
typedef void (* ProgressHandler)(const char *, const char *, int, int);
enum
{
@@ -91,7 +91,7 @@ void onUpdateConfirmation(const char * result)
if (result == STR_OK) {
OtaUpdateInformation * destination = moduleState[EXTERNAL_MODULE].otaUpdateInformation;
Pxx2OtaUpdate otaUpdate(EXTERNAL_MODULE, destination->candidateReceiversNames[destination->selectedReceiverIndex]);
otaUpdate.flashFirmware(destination->filename);
otaUpdate.flashFirmware(destination->filename, drawProgressScreen);
}
else {
moduleState[EXTERNAL_MODULE].mode = MODULE_MODE_NORMAL;
@@ -202,30 +202,30 @@ void onSdManagerMenu(const char * result)
else if (result == STR_FLASH_INTERNAL_MODULE) {
getSelectionFullPath(lfn);
FrskyDeviceFirmwareUpdate device(INTERNAL_MODULE);
device.flashFirmware(lfn);
device.flashFirmware(lfn, drawProgressScreen);
}
else if (result == STR_FLASH_EXTERNAL_MODULE) {
// needed on X-Lite (as the R9M needs 2S while the external device flashing port only provides 5V)
getSelectionFullPath(lfn);
FrskyDeviceFirmwareUpdate device(EXTERNAL_MODULE);
device.flashFirmware(lfn);
device.flashFirmware(lfn, drawProgressScreen);
}
else if (result == STR_FLASH_EXTERNAL_DEVICE) {
getSelectionFullPath(lfn);
FrskyDeviceFirmwareUpdate device(SPORT_MODULE);
device.flashFirmware(lfn);
device.flashFirmware(lfn, drawProgressScreen);
}
#if defined(BLUETOOTH)
else if (result == STR_FLASH_BLUETOOTH_MODULE) {
getSelectionFullPath(lfn);
bluetooth.flashFirmware(lfn);
bluetooth.flashFirmware(lfn, drawProgressScreen);
}
#endif
#if defined(HARDWARE_POWER_MANAGEMENT_UNIT)
else if (result == STR_FLASH_POWER_MANAGEMENT_UNIT) {
getSelectionFullPath(lfn);
FrskyChipFirmwareUpdate device;
device.flashFirmware(lfn);
device.flashFirmware(lfn, drawProgressScreen);
}
#endif
#if defined(PXX2)