mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-21 15:25:12 +03:00
Bsongis/refactoring before x10 ui merge (#6678)
UI functions refactoring
This commit is contained in:
parent
ebb1cb7cb3
commit
f6646b0190
20 changed files with 409 additions and 256 deletions
|
@ -22,12 +22,6 @@ set(GUI_SRC
|
|||
view_statistics.cpp
|
||||
)
|
||||
|
||||
set(SRC
|
||||
${SRC}
|
||||
gui/common/widgets.cpp
|
||||
gui/common/arm/widgets.cpp
|
||||
)
|
||||
|
||||
if(FLIGHT_MODES)
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
|
|
|
@ -813,21 +813,6 @@ void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att)
|
|||
drawSwitch(x, y, mode, att);
|
||||
}
|
||||
|
||||
void drawTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
|
||||
{
|
||||
trim_t v = getRawTrimValue(fm, idx);
|
||||
uint8_t mode = v.mode;
|
||||
uint8_t p = mode >> 1;
|
||||
char s[] = "--";
|
||||
if (mode != TRIM_MODE_NONE) {
|
||||
if (mode % 2 == 0)
|
||||
s[0] = ':';
|
||||
else
|
||||
s[0] = '+';
|
||||
s[1] = '0'+p;
|
||||
}
|
||||
lcdDrawText(x, y, s, att);
|
||||
}
|
||||
void drawShortTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
|
||||
{
|
||||
trim_t v = getRawTrimValue(fm, idx);
|
||||
|
@ -841,15 +826,6 @@ void drawShortTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags a
|
|||
}
|
||||
}
|
||||
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
|
||||
{
|
||||
// convertUnit(val, unit);
|
||||
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
|
||||
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
|
||||
lcdDrawTextAtIndex(lcdLastRightPos/*+1*/, y, STR_VTELEMUNIT, unit, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void drawGPSCoord(coord_t x, coord_t y, int32_t value, const char * direction, LcdFlags att, bool seconds=true)
|
||||
{
|
||||
att &= ~RIGHT & ~BOLD;
|
||||
|
|
|
@ -130,7 +130,6 @@ void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
|
|||
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
|
||||
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
|
||||
|
||||
void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
|
||||
void drawShortTrimMode(coord_t x, coord_t y, uint8_t mode, uint8_t idx, LcdFlags att);
|
||||
|
||||
#define putsChn(x, y, idx, att) drawSource(x, y, MIXSRC_CH1+idx-1, att)
|
||||
|
|
|
@ -22,12 +22,6 @@ set(GUI_SRC
|
|||
view_statistics.cpp
|
||||
)
|
||||
|
||||
set(SRC
|
||||
${SRC}
|
||||
gui/common/widgets.cpp
|
||||
gui/common/arm/widgets.cpp
|
||||
)
|
||||
|
||||
if(FLIGHT_MODES)
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
|
|
|
@ -718,33 +718,6 @@ void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att)
|
|||
drawSwitch(x, y, mode, att);
|
||||
}
|
||||
|
||||
void drawTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att)
|
||||
{
|
||||
trim_t v = getRawTrimValue(phase, idx);
|
||||
unsigned int mode = v.mode;
|
||||
unsigned int p = mode >> 1;
|
||||
|
||||
if (mode == TRIM_MODE_NONE) {
|
||||
lcdDrawText(x, y, "--", att);
|
||||
}
|
||||
else {
|
||||
if (mode % 2 == 0)
|
||||
lcdDrawChar(x, y, ':', att|FIXEDWIDTH);
|
||||
else
|
||||
lcdDrawChar(x, y, '+', att|FIXEDWIDTH);
|
||||
lcdDrawChar(lcdNextPos, y, '0'+p, att);
|
||||
}
|
||||
}
|
||||
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
|
||||
{
|
||||
// convertUnit(val, unit);
|
||||
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
|
||||
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
|
||||
lcdDrawTextAtIndex(lcdLastRightPos/*+1*/, y, STR_VTELEMUNIT, unit, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void drawGPSCoord(coord_t x, coord_t y, int32_t value, const char * direction, LcdFlags att, bool seconds=true)
|
||||
{
|
||||
uint32_t absvalue = abs(value);
|
||||
|
|
|
@ -123,7 +123,6 @@ void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
|
|||
void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att=0);
|
||||
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
|
||||
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
|
||||
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)
|
||||
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
|
||||
|
|
|
@ -26,12 +26,6 @@ set(GUI_SRC
|
|||
view_statistics.cpp
|
||||
)
|
||||
|
||||
set(SRC
|
||||
${SRC}
|
||||
gui/common/widgets.cpp
|
||||
gui/common/arm/widgets.cpp
|
||||
)
|
||||
|
||||
if(FLIGHT_MODES)
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _WIDGETS_H_
|
||||
#define _WIDGETS_H_
|
||||
#ifndef _DRAW_FUNCTIONS_H_
|
||||
#define _DRAW_FUNCTIONS_H_
|
||||
|
||||
#include "opentx.h"
|
||||
#include <stdio.h>
|
||||
#include "common/colorlcd/draw_functions.h"
|
||||
|
||||
#define OPTION_MENU_NO_FOOTER 0x01
|
||||
#define OPTION_MENU_TITLE_BAR 0x02
|
||||
|
@ -78,4 +78,4 @@ void drawTrims(uint8_t flightMode);
|
|||
|
||||
void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags);
|
||||
|
||||
#endif // _WIDGETS_H_
|
||||
#endif // _DRAW_FUNCTIONS_H_
|
|
@ -24,7 +24,7 @@
|
|||
#include "gui_common.h"
|
||||
#include "lcd.h"
|
||||
#include "menus.h"
|
||||
#include "widgets.h"
|
||||
#include "draw_functions.h"
|
||||
#include "bitmaps.h"
|
||||
#include "theme.h"
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "opentx.h"
|
||||
|
||||
unsigned int Topbar::getZonesCount() const
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
../common/colorlcd/widgets.cpp
|
||||
../common/colorlcd/draw_functions.cpp
|
||||
)
|
||||
|
||||
if(HELI)
|
||||
|
|
|
@ -20,6 +20,155 @@
|
|||
|
||||
#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) {
|
40
radio/src/gui/common/colorlcd/draw_functions.h
Normal file
40
radio/src/gui/common/colorlcd/draw_functions.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 __COLORLCD_DRAW_FUNCTIONS__
|
||||
#define __COLORLCD_DRAW_FUNCTIONS__
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix);
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att);
|
||||
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event);
|
||||
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event);
|
||||
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
|
||||
void drawFatalErrorScreen(const char * message);
|
||||
void runFatalErrorScreen(const char * message);
|
||||
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att);
|
||||
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags);
|
||||
|
||||
#if defined(FLIGHT_MODES)
|
||||
void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att);
|
||||
#endif
|
||||
|
||||
#endif // __COLORLCD_DRAW_FUNCTIONS__
|
|
@ -1,121 +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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ add_definitions(-DGRAPHICS)
|
|||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
../common/stdlcd/menus.cpp
|
||||
../common/stdlcd/widgets.cpp
|
||||
../common/stdlcd/draw_functions.cpp
|
||||
../common/stdlcd/popups.cpp
|
||||
../common/stdlcd/model_inputs.cpp
|
||||
../common/stdlcd/model_mixes.cpp
|
||||
|
|
|
@ -33,6 +33,33 @@ void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, Lc
|
|||
}
|
||||
}
|
||||
|
||||
void drawTrimMode(coord_t x, coord_t y, uint8_t flightMode, uint8_t idx, LcdFlags att)
|
||||
{
|
||||
trim_t v = getRawTrimValue(flightMode, idx);
|
||||
unsigned int mode = v.mode;
|
||||
unsigned int p = mode >> 1;
|
||||
|
||||
if (mode == TRIM_MODE_NONE) {
|
||||
lcdDrawText(x, y, "--", att);
|
||||
}
|
||||
else {
|
||||
if (mode % 2 == 0)
|
||||
lcdDrawChar(x, y, ':', att|FIXEDWIDTH);
|
||||
else
|
||||
lcdDrawChar(x, y, '+', att|FIXEDWIDTH);
|
||||
lcdDrawChar(lcdNextPos, y, '0'+p, att);
|
||||
}
|
||||
}
|
||||
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
|
||||
{
|
||||
// convertUnit(val, unit);
|
||||
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
|
||||
if (!(att & NO_UNIT) && unit != UNIT_RAW) {
|
||||
lcdDrawTextAtIndex(lcdLastRightPos/*+1*/, y, STR_VTELEMUNIT, unit, 0);
|
||||
}
|
||||
}
|
||||
|
||||
FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModesType value, uint8_t attr)
|
||||
{
|
||||
int posHorz = menuHorizontalPosition;
|
||||
|
@ -233,3 +260,179 @@ void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverI
|
|||
lcdDrawText(x, y, "External", flags);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
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);
|
||||
}
|
|
@ -18,12 +18,13 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_DRAW_FUNCTIONS_H_
|
||||
#define _COMMON_DRAW_FUNCTIONS_H_
|
||||
#ifndef _STDLCD_DRAW_FUNCTIONS_H_
|
||||
#define _STDLCD_DRAW_FUNCTIONS_H_
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, LcdFlags att=0);
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, 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);
|
||||
|
@ -40,4 +41,7 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration);
|
|||
void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message);
|
||||
void drawSleepBitmap();
|
||||
|
||||
#endif // _COMMON_DRAW_FUNCTIONS_H_
|
||||
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags=0);
|
||||
void drawTrimMode(coord_t x, coord_t y, uint8_t flightMode, uint8_t idx, LcdFlags att=0);
|
||||
|
||||
#endif // _STDLCD_DRAW_FUNCTIONS_H_
|
||||
|
|
|
@ -1,48 +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 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
|
|
@ -72,7 +72,6 @@ bool isRssiSensorAvailable(int sensor)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool isSensorAvailable(int sensor)
|
||||
{
|
||||
if (sensor == 0)
|
||||
|
|
|
@ -95,7 +95,6 @@ void drawFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
|
|||
|
||||
swsrc_t checkIncDecMovedSwitch(swsrc_t val);
|
||||
|
||||
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags flags);
|
||||
void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags flags=0);
|
||||
void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags flags=0);
|
||||
void drawTelemScreenDate(coord_t x, coord_t y, source_t sensor, LcdFlags flags=0);
|
||||
|
@ -116,8 +115,6 @@ void drawFatalErrorScreen(const char * message);
|
|||
void runFatalErrorScreen(const char * message);
|
||||
#endif
|
||||
|
||||
void lcdDrawMMM(coord_t x, coord_t y, LcdFlags flags=0);
|
||||
|
||||
// model_setup Defines that are used in all uis in the same way
|
||||
#define INTERNAL_MODULE_CHANNELS_ROWS IF_INTERNAL_MODULE_ON((uint8_t)1)
|
||||
#define EXTERNAL_MODULE_CHANNELS_ROWS IF_EXTERNAL_MODULE_ON((isModuleDSM2(EXTERNAL_MODULE) || isModuleCrossfire(EXTERNAL_MODULE) || isModuleSBUS(EXTERNAL_MODULE) || (isModuleMultimodule(EXTERNAL_MODULE) && g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) != MODULE_SUBTYPE_MULTI_DSM2)) ? (uint8_t)0 : (uint8_t)1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue