[Horus] Refactoring continued
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
#define NUM_BODY_LINES (LCD_LINES-1)
|
||||
#define MENU_HEADER_HEIGHT FH
|
||||
#define MENU_INIT_VPOS 0
|
||||
|
||||
void displaySplash();
|
||||
void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
display_t displayBuf[DISPLAY_BUFFER_SIZE];
|
||||
|
||||
void lcd_clear()
|
||||
void lcdClear()
|
||||
{
|
||||
memset(displayBuf, 0, DISPLAY_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ void lcdDrawTelemetryTopBar();
|
||||
void lcd_img(coord_t x, coord_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0);
|
||||
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
void lcd_clear();
|
||||
void lcdClear();
|
||||
void lcdSetContrast();
|
||||
void lcdInit();
|
||||
#define lcdOff()
|
||||
|
||||
+12
-23
@@ -70,8 +70,6 @@ typedef void (*MenuFuncP)(uint8_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(uint8_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
extern const MenuFuncP_PROGMEM menuTabFPV[];
|
||||
extern const MenuFuncP_PROGMEM menuTabTelemetry[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
@@ -274,19 +272,11 @@ void title(const pm_char * s);
|
||||
#define MENU_CHECK(tab, menu, lines_count) \
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-1)
|
||||
|
||||
#define MENU_CHECK_FLAGS(tab, menu, flags, lines_count) \
|
||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, (lines_count)-1, flags)
|
||||
|
||||
#define MENU(title, tab, menu, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
MENU_CHECK(tab, menu, lines_count); \
|
||||
TITLE(title)
|
||||
|
||||
#define MENU_FLAGS(title, tab, menu, flags, lines_count, ...) \
|
||||
MENU_TAB(__VA_ARGS__); \
|
||||
MENU_CHECK_FLAGS(tab, menu, flags, lines_count); \
|
||||
TITLE(title)
|
||||
|
||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
|
||||
check_simple(event, menu, tab, DIM(tab), (lines_count)-1);
|
||||
|
||||
@@ -343,9 +333,9 @@ int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t
|
||||
|
||||
void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active);
|
||||
|
||||
#define WARNING_TYPE_ASTERISK 0
|
||||
#define WARNING_TYPE_CONFIRM 1
|
||||
#define WARNING_TYPE_INPUT 2
|
||||
#define WARNING_TYPE_ASTERISK 0
|
||||
#define WARNING_TYPE_CONFIRM 1
|
||||
#define WARNING_TYPE_INPUT 2
|
||||
|
||||
extern const pm_char * s_warning;
|
||||
extern const pm_char * s_warning_info;
|
||||
@@ -353,12 +343,12 @@ extern uint8_t s_warning_info_len;
|
||||
extern uint8_t s_warning_result;
|
||||
extern uint8_t s_warning_type;
|
||||
|
||||
#define MENU_X 10
|
||||
#define MENU_Y 16
|
||||
#define MENU_W LCD_W-(2*MENU_X)
|
||||
#define WARNING_LINE_LEN 20
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
#define MENU_X 10
|
||||
#define MENU_Y 16
|
||||
#define MENU_W LCD_W-(2*MENU_X)
|
||||
#define WARNING_LINE_LEN 20
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
|
||||
void displayBox();
|
||||
void displayPopup(const pm_char * pstr);
|
||||
@@ -380,9 +370,9 @@ void displayWarning(uint8_t event);
|
||||
#define WARNING_INFO_FLAGS 0
|
||||
#define SET_WARNING_INFO(...)
|
||||
#elif defined(CPUARM)
|
||||
#define DISPLAY_WARNING (*popupFunc)
|
||||
#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define DISPLAY_WARNING (*popupFunc)
|
||||
#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define POPUP_INPUT(s, func, start, min, max) (s_warning = s, s_warning_type = WARNING_TYPE_INPUT, popupFunc = func, s_warning_input_value = start, s_warning_input_min = min, s_warning_input_max = max)
|
||||
#define WARNING_INFO_FLAGS s_warning_info_flags
|
||||
#define SET_WARNING_INFO(info, len, flags) (s_warning_info = info, s_warning_info_len = len, s_warning_info_flags = flags)
|
||||
@@ -454,7 +444,6 @@ void displayWarning(uint8_t event);
|
||||
#define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE()
|
||||
#endif
|
||||
|
||||
#define POS_VERT_INIT 0
|
||||
#define POS_HORZ_INIT(posVert) 0
|
||||
#define EDIT_MODE_INIT -1
|
||||
|
||||
|
||||
@@ -474,7 +474,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
#if defined(CPUARM)
|
||||
menuEntryTime = get_tmr10ms();
|
||||
#endif
|
||||
l_posVert = POS_VERT_INIT;
|
||||
l_posVert = 0;
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
SET_SCROLLBAR_X(LCD_W-1);
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
@@ -510,8 +510,8 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
case EVT_ROTARY_LONG:
|
||||
if (s_editMode > 1) break;
|
||||
killEvents(event);
|
||||
if (l_posVert != POS_VERT_INIT) {
|
||||
l_posVert = POS_VERT_INIT;
|
||||
if (l_posVert != 0) {
|
||||
l_posVert = 0;
|
||||
s_editMode = EDIT_MODE_INIT;
|
||||
break;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
case EVT_KEY_FIRST(KEY_DOWN): //inc
|
||||
if (s_editMode>0) break;
|
||||
do {
|
||||
INC(l_posVert, POS_VERT_INIT, maxrow);
|
||||
INC(l_posVert, 0, maxrow);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
@@ -617,7 +617,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
if (s_editMode>0) break;
|
||||
|
||||
do {
|
||||
DEC(l_posVert, POS_VERT_INIT, maxrow);
|
||||
DEC(l_posVert, 0, maxrow);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
|
||||
@@ -71,7 +71,7 @@ void displayPopup(const pm_char * pstr)
|
||||
|
||||
void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG)
|
||||
{
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
lcd_img(2, 0, asterisk_lbm, 0, 0);
|
||||
|
||||
#define MESSAGE_LCD_OFFSET 6*FW
|
||||
|
||||
@@ -45,7 +45,7 @@ const pm_uchar * const splash_lbm = splashdata+4;
|
||||
|
||||
void displaySplash()
|
||||
{
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
lcd_img(0, 0, splash_lbm, 0, 0);
|
||||
|
||||
#if MENUS_LOCK == 1
|
||||
|
||||
@@ -64,10 +64,18 @@ const uint8_t LBM_CURRENT_DOT[] = {
|
||||
* Main view bitmaps
|
||||
*/
|
||||
|
||||
const uint16_t LBM_MAINVIEW_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/background.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TOPMENU_OPENTX[] = {
|
||||
#include "../../bitmaps/Horus/mask_topmenu_opentx.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TOPMENU_USB[] = {
|
||||
#include "../../bitmaps/Horus/mask_topmenu_usb.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_HTRIM_FRAME[] = {
|
||||
#include "../../bitmaps/Horus/mask_htrim_frame.lbm"
|
||||
};
|
||||
@@ -80,6 +88,14 @@ const uint8_t LBM_TRIM_SHADOW[] = {
|
||||
#include "../../bitmaps/Horus/mask_trim_shadow.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TIMER_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/mask_timer_bg.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_RSCALE[] = {
|
||||
#include "../../bitmaps/Horus/mask_rscale.lbm"
|
||||
};
|
||||
|
||||
/*
|
||||
* Radio menu bitmaps
|
||||
*/
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#define CURVE_CENTER_Y 159
|
||||
|
||||
#define MENU_TITLE_NEXT_POS (lcdNextPos + 10)
|
||||
#define MENU_INIT_VPOS -1
|
||||
|
||||
void displaySplash();
|
||||
void displayScreenIndex(uint8_t index, uint8_t count);
|
||||
@@ -82,12 +83,16 @@ extern const uint8_t LBM_CURRENT_SHADOW[];
|
||||
extern const uint8_t LBM_CURRENT_DOT[];
|
||||
|
||||
// Main view icons
|
||||
extern const uint16_t LBM_MAINVIEW_BACKGROUND[];
|
||||
extern const uint8_t LBM_TOPMENU_OPENTX[];
|
||||
extern const uint8_t LBM_TOPMENU_USB[];
|
||||
extern const uint8_t LBM_HTRIM_FRAME[];
|
||||
extern const uint8_t LBM_VTRIM_FRAME[];
|
||||
extern const uint8_t LBM_TRIM_SHADOW[];
|
||||
extern const uint8_t LBM_RADIO_ICON[];
|
||||
extern const uint8_t LBM_MODEL_ICON[];
|
||||
extern const uint8_t LBM_TIMER_BACKGROUND[];
|
||||
extern const uint8_t LBM_RSCALE[];
|
||||
|
||||
// Menu icons
|
||||
extern const uint8_t * const LBM_RADIO_ICONS[];
|
||||
|
||||
+53
-102
@@ -54,6 +54,7 @@ void lcdColorsInit()
|
||||
lcdColorTable[SCROLLBOX_COLOR_INDEX] = RED;
|
||||
lcdColorTable[MENU_TITLE_BGCOLOR_INDEX] = DARKGREY;
|
||||
lcdColorTable[MENU_TITLE_COLOR_INDEX] = WHITE;
|
||||
lcdColorTable[MENU_TITLE_DISABLE_COLOR_INDEX] = RGB(130, 1, 5);
|
||||
lcdColorTable[HEADER_COLOR_INDEX] = DARKGREY;
|
||||
lcdColorTable[ALARM_COLOR_INDEX] = RED;
|
||||
lcdColorTable[WARNING_COLOR_INDEX] = YELLOW;
|
||||
@@ -790,18 +791,18 @@ void lcdSetContrast()
|
||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||
}
|
||||
|
||||
void lcdDrawPixel(display_t * p, display_t value)
|
||||
inline void lcdDrawPixel(display_t * p, display_t value)
|
||||
{
|
||||
*p = value;
|
||||
}
|
||||
|
||||
void lcdDrawPixel(coord_t x, coord_t y, display_t value)
|
||||
inline void lcdDrawPixel(coord_t x, coord_t y, display_t value)
|
||||
{
|
||||
display_t * p = PIXEL_PTR(x, y);
|
||||
lcdDrawPixel(p, value);
|
||||
}
|
||||
|
||||
void lcdDrawTransparentPixel(coord_t x, coord_t y, uint8_t opacity, uint16_t color)
|
||||
inline void lcdDrawTransparentPixel(coord_t x, coord_t y, uint8_t opacity, uint16_t color)
|
||||
{
|
||||
display_t * p = PIXEL_PTR(x, y);
|
||||
lcdDrawTransparentPixel(p, opacity, color);
|
||||
@@ -938,56 +939,66 @@ void lcdDrawCircle(int x0, int y0, int radius)
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
void lcdDrawPie(int x0, int y0, int radius, int startAngle, int endAngle)
|
||||
bool evalSlopes(int * slopes, int startAngle, int endAngle)
|
||||
{
|
||||
int slope1s, slope1e, slope2s, slope2e;
|
||||
|
||||
if (startAngle >= 360 || endAngle <= 0)
|
||||
return;
|
||||
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
return false;
|
||||
|
||||
if (startAngle == 0) {
|
||||
slope1e = 100000;
|
||||
slope2s = -100000;
|
||||
}
|
||||
else if (startAngle >= 180) {
|
||||
slope1e = -100000;
|
||||
slope2s = cos(angle1)*100/sin(angle1);
|
||||
slopes[1] = 100000;
|
||||
slopes[2] = -100000;
|
||||
}
|
||||
else {
|
||||
slope1e = cos(angle1)*100/sin(angle1);
|
||||
slope2s = -100000;
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
if (startAngle >= 180) {
|
||||
slopes[1] = -100000;
|
||||
slopes[2] = cos(angle1) * 100 / sin(angle1);
|
||||
}
|
||||
else {
|
||||
slopes[1] = cos(angle1) * 100 / sin(angle1);
|
||||
slopes[2] = -100000;
|
||||
}
|
||||
}
|
||||
|
||||
if (endAngle == 360) {
|
||||
slope1s = -100000;
|
||||
slope2e = 100000;
|
||||
}
|
||||
else if (endAngle >= 180) {
|
||||
slope1s = -100000;
|
||||
slope2e = -cos(angle2)*100/sin(angle2);
|
||||
slopes[0] = -100000;
|
||||
slopes[3] = 100000;
|
||||
}
|
||||
else {
|
||||
slope1s = cos(angle2)*100/sin(angle2);
|
||||
slope2e = -100000;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
if (endAngle >= 180) {
|
||||
slopes[0] = -100000;
|
||||
slopes[3] = -cos(angle2) * 100 / sin(angle2);
|
||||
}
|
||||
else {
|
||||
slopes[0] = cos(angle2) * 100 / sin(angle2);
|
||||
slopes[3] = -100000;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void lcdDrawPie(int x0, int y0, int radius, int startAngle, int endAngle)
|
||||
{
|
||||
int slopes[4];
|
||||
if (!evalSlopes(slopes, startAngle, endAngle))
|
||||
return;
|
||||
|
||||
for (int y=0; y<=radius; y++) {
|
||||
for (int x=0; x<=radius; x++) {
|
||||
if (x*x+y*y <= radius*radius) {
|
||||
int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x);
|
||||
if (slope >= slope1s && slope < slope1e) {
|
||||
if (slope >= slopes[0] && slope < slopes[1]) {
|
||||
lcdDrawPixel(x0+x, y0-y, WHITE);
|
||||
}
|
||||
if (-slope >= slope1s && -slope < slope1e) {
|
||||
if (-slope >= slopes[0] && -slope < slopes[1]) {
|
||||
lcdDrawPixel(x0+x, y0+y, WHITE);
|
||||
}
|
||||
if (slope >= slope2s && slope < slope2e) {
|
||||
if (slope >= slopes[2] && slope < slopes[3]) {
|
||||
lcdDrawPixel(x0-x, y0-y, WHITE);
|
||||
}
|
||||
if (-slope >= slope2s && -slope < slope2e) {
|
||||
if (-slope >= slopes[2] && -slope < slopes[3]) {
|
||||
lcdDrawPixel(x0-x, y0+y, WHITE);
|
||||
}
|
||||
}
|
||||
@@ -1001,56 +1012,26 @@ void lcdDrawBitmapPie(int x0, int y0, const uint16_t * img, int startAngle, int
|
||||
coord_t width = *q++;
|
||||
coord_t height = *q++;
|
||||
|
||||
int slope1s, slope1e, slope2s, slope2e;
|
||||
|
||||
if (startAngle >= 360 || endAngle <= 0)
|
||||
int slopes[4];
|
||||
if (!evalSlopes(slopes, startAngle, endAngle))
|
||||
return;
|
||||
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
|
||||
if (startAngle == 0) {
|
||||
slope1e = 100000;
|
||||
slope2s = -100000;
|
||||
}
|
||||
else if (startAngle >= 180) {
|
||||
slope1e = -100000;
|
||||
slope2s = cos(angle1)*100/sin(angle1);
|
||||
}
|
||||
else {
|
||||
slope1e = cos(angle1)*100/sin(angle1);
|
||||
slope2s = -100000;
|
||||
}
|
||||
|
||||
if (endAngle == 360) {
|
||||
slope1s = -100000;
|
||||
slope2e = 100000;
|
||||
}
|
||||
else if (endAngle >= 180) {
|
||||
slope1s = -100000;
|
||||
slope2e = -cos(angle2)*100/sin(angle2);
|
||||
}
|
||||
else {
|
||||
slope1s = cos(angle2)*100/sin(angle2);
|
||||
slope2e = -100000;
|
||||
}
|
||||
|
||||
int w2 = width/2;
|
||||
int h2 = height/2;
|
||||
|
||||
for (int y=h2-1; y>=0; y--) {
|
||||
for (int x=w2-1; x>=0; x--) {
|
||||
int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x);
|
||||
if (slope >= slope1s && slope < slope1e) {
|
||||
if (slope >= slopes[0] && slope < slopes[1]) {
|
||||
displayBuf[(y0+h2-y)*LCD_W + x0+w2+x] = q[(h2-y)*width + w2+x];
|
||||
}
|
||||
if (-slope >= slope1s && -slope < slope1e) {
|
||||
if (-slope >= slopes[0] && -slope < slopes[1]) {
|
||||
displayBuf[(y0+h2+y)*LCD_W + x0+w2+x] = q[(h2+y)*width + w2+x];
|
||||
}
|
||||
if (slope >= slope2s && slope < slope2e) {
|
||||
if (slope >= slopes[2] && slope < slopes[3]) {
|
||||
displayBuf[(y0+h2-y)*LCD_W + x0+w2-x] = q[(h2-y)*width + w2-x];
|
||||
}
|
||||
if (-slope >= slope2s && -slope < slope2e) {
|
||||
if (-slope >= slopes[2] && -slope < slopes[3]) {
|
||||
displayBuf[(y0+h2+y)*LCD_W + x0+w2-x] = q[(h2+y)*width + w2-x];
|
||||
}
|
||||
}
|
||||
@@ -1063,58 +1044,28 @@ void lcdDrawBitmapPatternPie(coord_t x0, coord_t y0, const uint8_t * img, LcdFla
|
||||
coord_t height = *(((uint16_t *)img)+1);
|
||||
const uint8_t * q = img+4;
|
||||
|
||||
int slope1s, slope1e, slope2s, slope2e;
|
||||
|
||||
if (startAngle >= 360 || endAngle <= 0)
|
||||
int slopes[4];
|
||||
if (!evalSlopes(slopes, startAngle, endAngle))
|
||||
return;
|
||||
|
||||
display_t color = lcdColorTable[COLOR_IDX(flags)];
|
||||
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
|
||||
if (startAngle == 0) {
|
||||
slope1e = 100000;
|
||||
slope2s = -100000;
|
||||
}
|
||||
else if (startAngle >= 180) {
|
||||
slope1e = -100000;
|
||||
slope2s = cos(angle1)*100/sin(angle1);
|
||||
}
|
||||
else {
|
||||
slope1e = cos(angle1)*100/sin(angle1);
|
||||
slope2s = -100000;
|
||||
}
|
||||
|
||||
if (endAngle == 360) {
|
||||
slope1s = -100000;
|
||||
slope2e = 100000;
|
||||
}
|
||||
else if (endAngle >= 180) {
|
||||
slope1s = -100000;
|
||||
slope2e = -cos(angle2)*100/sin(angle2);
|
||||
}
|
||||
else {
|
||||
slope1s = cos(angle2)*100/sin(angle2);
|
||||
slope2e = -100000;
|
||||
}
|
||||
|
||||
int w2 = width/2;
|
||||
int h2 = height/2;
|
||||
|
||||
for (int y=h2-1; y>=0; y--) {
|
||||
for (int x=w2-1; x>=0; x--) {
|
||||
int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x);
|
||||
if (slope >= slope1s && slope < slope1e) {
|
||||
if (slope >= slopes[0] && slope < slopes[1]) {
|
||||
lcdDrawTransparentPixel(x0+w2+x, y0+h2-y, q[(h2-y)*width + w2+x], color);
|
||||
}
|
||||
if (-slope >= slope1s && -slope < slope1e) {
|
||||
if (-slope >= slopes[0] && -slope < slopes[1]) {
|
||||
lcdDrawTransparentPixel(x0+w2+x, y0+h2+y, q[(h2+y)*width + w2+x], color);
|
||||
}
|
||||
if (slope >= slope2s && slope < slope2e) {
|
||||
if (slope >= slopes[2] && slope < slopes[3]) {
|
||||
lcdDrawTransparentPixel(x0+w2-x, y0+h2-y, q[(h2-y)*width + w2-x], color);
|
||||
}
|
||||
if (-slope >= slope2s && -slope < slope2e) {
|
||||
if (-slope >= slopes[2] && -slope < slopes[3]) {
|
||||
lcdDrawTransparentPixel(x0+w2-x, y0+h2+y, q[(h2+y)*width + w2-x], color);
|
||||
}
|
||||
}
|
||||
|
||||
+21
-19
@@ -123,6 +123,7 @@ enum LcdColorIndex
|
||||
SCROLLBOX_COLOR_INDEX,
|
||||
MENU_TITLE_BGCOLOR_INDEX,
|
||||
MENU_TITLE_COLOR_INDEX,
|
||||
MENU_TITLE_DISABLE_COLOR_INDEX,
|
||||
HEADER_COLOR_INDEX,
|
||||
ALARM_COLOR_INDEX,
|
||||
WARNING_COLOR_INDEX,
|
||||
@@ -141,25 +142,26 @@ void lcdColorsInit();
|
||||
#define OPACITY_MAX 0x0F
|
||||
#define OPACITY(x) ((x)<<24)
|
||||
|
||||
#define COLOR(index) ((index) << 16)
|
||||
#define TEXT_COLOR COLOR(TEXT_COLOR_INDEX)
|
||||
#define TEXT_BGCOLOR COLOR(TEXT_BGCOLOR_INDEX)
|
||||
#define TEXT_INVERTED_COLOR COLOR(TEXT_INVERTED_COLOR_INDEX)
|
||||
#define TEXT_INVERTED_BGCOLOR COLOR(TEXT_INVERTED_BGCOLOR_INDEX)
|
||||
#define LINE_COLOR COLOR(LINE_COLOR_INDEX)
|
||||
#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX)
|
||||
#define HEADER_SEPARATOR_COLOR COLOR(HEADER_SEPARATOR_COLOR_INDEX)
|
||||
#define MENU_TITLE_BGCOLOR COLOR(MENU_TITLE_BGCOLOR_INDEX)
|
||||
#define MENU_TITLE_COLOR COLOR(MENU_TITLE_COLOR_INDEX)
|
||||
#define HEADER_COLOR COLOR(HEADER_COLOR_INDEX)
|
||||
#define ALARM_COLOR COLOR(ALARM_COLOR_INDEX)
|
||||
#define WARNING_COLOR COLOR(WARNING_COLOR_INDEX)
|
||||
#define TEXT_DISABLE_COLOR COLOR(TEXT_DISABLE_COLOR_INDEX)
|
||||
#define CURVE_AXIS_COLOR COLOR(CURVE_AXIS_COLOR_INDEX)
|
||||
#define CURVE_COLOR COLOR(CURVE_COLOR_INDEX)
|
||||
#define CURVE_CURSOR_COLOR COLOR(CURVE_CURSOR_COLOR_INDEX)
|
||||
#define TITLE_BGCOLOR COLOR(TITLE_BGCOLOR_INDEX)
|
||||
#define HEADER_BGCOLOR COLOR(HEADER_BGCOLOR_INDEX)
|
||||
#define COLOR(index) ((index) << 16)
|
||||
#define TEXT_COLOR COLOR(TEXT_COLOR_INDEX)
|
||||
#define TEXT_BGCOLOR COLOR(TEXT_BGCOLOR_INDEX)
|
||||
#define TEXT_INVERTED_COLOR COLOR(TEXT_INVERTED_COLOR_INDEX)
|
||||
#define TEXT_INVERTED_BGCOLOR COLOR(TEXT_INVERTED_BGCOLOR_INDEX)
|
||||
#define LINE_COLOR COLOR(LINE_COLOR_INDEX)
|
||||
#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX)
|
||||
#define HEADER_SEPARATOR_COLOR COLOR(HEADER_SEPARATOR_COLOR_INDEX)
|
||||
#define MENU_TITLE_BGCOLOR COLOR(MENU_TITLE_BGCOLOR_INDEX)
|
||||
#define MENU_TITLE_COLOR COLOR(MENU_TITLE_COLOR_INDEX)
|
||||
#define MENU_TITLE_DISABLE_COLOR COLOR(MENU_TITLE_DISABLE_COLOR_INDEX)
|
||||
#define HEADER_COLOR COLOR(HEADER_COLOR_INDEX)
|
||||
#define ALARM_COLOR COLOR(ALARM_COLOR_INDEX)
|
||||
#define WARNING_COLOR COLOR(WARNING_COLOR_INDEX)
|
||||
#define TEXT_DISABLE_COLOR COLOR(TEXT_DISABLE_COLOR_INDEX)
|
||||
#define CURVE_AXIS_COLOR COLOR(CURVE_AXIS_COLOR_INDEX)
|
||||
#define CURVE_COLOR COLOR(CURVE_COLOR_INDEX)
|
||||
#define CURVE_CURSOR_COLOR COLOR(CURVE_CURSOR_COLOR_INDEX)
|
||||
#define TITLE_BGCOLOR COLOR(TITLE_BGCOLOR_INDEX)
|
||||
#define HEADER_BGCOLOR COLOR(HEADER_BGCOLOR_INDEX)
|
||||
|
||||
#define COLOR_IDX(att) uint8_t((att) >> 16)
|
||||
|
||||
|
||||
@@ -39,6 +39,36 @@
|
||||
#define XPOT_DELTA 10
|
||||
#define XPOT_DELAY 10 /* cycles */
|
||||
|
||||
#define BAR_HEIGHT (BOX_WIDTH-9)
|
||||
#define LBOX_CENTERX (BOX_WIDTH/2 + 17)
|
||||
#define RBOX_CENTERX (LCD_W-LBOX_CENTERX)
|
||||
|
||||
void drawPotsBars()
|
||||
{
|
||||
// Optimization by Mike Blandford
|
||||
uint8_t x, i, len ; // declare temporary variables
|
||||
for (x=LCD_W/2-9, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; x+=9, i++) {
|
||||
if (IS_POT_AVAILABLE(i)) {
|
||||
len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
// TODO 220 constant
|
||||
lcdDrawSolidFilledRect(x, 220-FH-len, 5, len, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawSticksPositions()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void menuCommonCalib(evt_t event)
|
||||
{
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { // get low and high vals for sticks and trims
|
||||
@@ -172,7 +202,7 @@ void menuCommonCalib(evt_t event)
|
||||
break;
|
||||
}
|
||||
|
||||
doMainScreenGraphics();
|
||||
drawSticksPositions();
|
||||
drawPotsBars();
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -72,7 +72,6 @@ typedef void (*MenuFuncP)(evt_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(evt_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
extern const MenuFuncP_PROGMEM menuTabTelemetry[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
@@ -85,14 +84,7 @@ void chainMenu(MenuFuncP newMenu);
|
||||
void pushMenu(MenuFuncP newMenu);
|
||||
/// return to last menu in menustack
|
||||
void popMenu();
|
||||
///deliver address of last menu which was popped from
|
||||
inline MenuFuncP lastPopMenu()
|
||||
{
|
||||
return g_menuStack[g_menuStackPtr+1];
|
||||
}
|
||||
|
||||
void drawPotsBars();
|
||||
void doMainScreenGraphics();
|
||||
void menuFirstCalib(evt_t event);
|
||||
|
||||
void onMainViewMenu(const char *result);
|
||||
@@ -141,7 +133,6 @@ extern int8_t s_editMode; // global editmode
|
||||
#define TITLE_ROW ((uint8_t)-1)
|
||||
#define HIDDEN_ROW ((uint8_t)-2)
|
||||
|
||||
typedef bool (*IsValueAvailable)(int);
|
||||
struct CheckIncDecStops {
|
||||
const int count;
|
||||
const int stops[];
|
||||
@@ -345,9 +336,9 @@ void menuChannelsView(evt_t event);
|
||||
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; }
|
||||
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
|
||||
|
||||
#define POS_VERT_INIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0)
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
#define MENU_FIRST_LINE_EDIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0)
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
|
||||
typedef int (*FnFuncP) (int x);
|
||||
void DrawFunction(FnFuncP fn, int offset=0);
|
||||
|
||||
@@ -243,7 +243,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (rowcount > 0) {
|
||||
l_posVert = POS_VERT_INIT;
|
||||
l_posVert = MENU_FIRST_LINE_EDIT;
|
||||
event = 0;
|
||||
}
|
||||
break;
|
||||
@@ -347,7 +347,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_REPT(KEY_DOWN):
|
||||
do {
|
||||
INC(l_posVert, POS_VERT_INIT, rowcount-1);
|
||||
INC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
s_editMode = 0; // if we go down, we must be in this mode
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
@@ -376,7 +376,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_REPT(KEY_UP):
|
||||
do {
|
||||
DEC(l_posVert, POS_VERT_INIT, rowcount-1);
|
||||
DEC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
s_editMode = 0; // if we go up, we must be in this mode
|
||||
|
||||
@@ -36,13 +36,6 @@
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
#define BIGSIZE MIDSIZE
|
||||
#define BAR_HEIGHT (BOX_WIDTH-9)
|
||||
#define LBOX_CENTERX (BOX_WIDTH/2 + 17)
|
||||
#define RBOX_CENTERX (LCD_W-LBOX_CENTERX)
|
||||
#define BITMAP_X ((LCD_W-64)/2)
|
||||
#define BITMAP_Y (LCD_H/2)
|
||||
|
||||
#define TRIM_LH_X 90
|
||||
#define TRIM_LV_X 24
|
||||
#define TRIM_RV_X (LCD_W-35)
|
||||
@@ -51,32 +44,6 @@
|
||||
#define TRIM_H_Y 235
|
||||
#define TRIM_LEN 80
|
||||
|
||||
void drawPotsBars()
|
||||
{
|
||||
// Optimization by Mike Blandford
|
||||
uint8_t x, i, len ; // declare temporary variables
|
||||
for (x=LCD_W/2-9, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; x+=9, i++) {
|
||||
if (IS_POT_AVAILABLE(i)) {
|
||||
len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
// TODO 220 constant
|
||||
lcdDrawSolidFilledRect(x, 220-FH-len, 5, len, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void doMainScreenGraphics()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void drawTrimSquare(coord_t x, coord_t y)
|
||||
{
|
||||
lcdDrawSolidFilledRect(x-2, y, 15, 15, TITLE_BGCOLOR);
|
||||
@@ -141,7 +108,7 @@ void drawSticks()
|
||||
drawHorizontalStick(TRIM_RH_X-TRIM_LEN+1, calibratedStick[3]);
|
||||
}
|
||||
|
||||
void displayTrims(uint8_t flightMode)
|
||||
void drawTrims(uint8_t flightMode)
|
||||
{
|
||||
g_model.displayTrims = DISPLAY_TRIMS_ALWAYS;
|
||||
|
||||
@@ -191,33 +158,22 @@ void displayTrims(uint8_t flightMode)
|
||||
}
|
||||
}
|
||||
|
||||
void displayTimers()
|
||||
void drawTimer(coord_t x, coord_t y, int index)
|
||||
{
|
||||
// const int TIMERS_W = 56;
|
||||
const int TIMERS_H = 30;
|
||||
const int TIMERS_MARGIN = 16;
|
||||
const int TIMERS_PADDING = 4;
|
||||
|
||||
for (int i=0; i<TIMERS; i++) {
|
||||
if (g_model.timers[i].mode) {
|
||||
TimerState & timerState = timersStates[i];
|
||||
TimerData & timerData = g_model.timers[i];
|
||||
int y = TIMERS_MARGIN + i*(TIMERS_H+TIMERS_MARGIN);
|
||||
unsigned int len = zlen(timerData.name, LEN_TIMER_NAME);
|
||||
LcdFlags color=TEXT_COLOR, bgColor=TEXT_BGCOLOR;
|
||||
if (timerState.val < 0) {
|
||||
color = ALARM_COLOR;
|
||||
}
|
||||
// TODO lcdDrawSolidFilledRect(TIMERS_MARGIN, y, TIMERS_W, TIMERS_H, SOLID, bgColor);
|
||||
putsTimer(TIMERS_MARGIN+TIMERS_PADDING, y+12, abs(timerState.val), color|DBLSIZE|LEFT);
|
||||
if (len > 0)
|
||||
lcd_putsnAtt(TIMERS_MARGIN+TIMERS_PADDING, y+2, timerData.name, LEN_TIMER_NAME, color|ZCHAR);
|
||||
else
|
||||
putsTimerMode(TIMERS_MARGIN+TIMERS_PADDING, y+2, timerData.mode, color);
|
||||
}
|
||||
TimerData & timerData = g_model.timers[index];
|
||||
TimerState & timerState = timersStates[index];
|
||||
lcdDrawBitmapPattern(x, y, LBM_TIMER_BACKGROUND, TEXT_BGCOLOR);
|
||||
if (timerData.start) {
|
||||
lcdDrawBitmapPatternPie(x+2, y+3, LBM_RSCALE, TITLE_BGCOLOR, 0, timerState.val <= 0 ? 360 : 360*(timerData.start-timerState.val)/timerData.start);
|
||||
}
|
||||
putsTimer(x+74, y+31, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
|
||||
if (ZLEN(timerData.name) > 0) {
|
||||
lcd_putsnAtt(x+74, y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR);
|
||||
}
|
||||
putsStrIdx(x+137, y+17, "TMR", 1, SMLSIZE|TEXT_COLOR);
|
||||
}
|
||||
|
||||
|
||||
void displayMainTelemetryFields()
|
||||
{
|
||||
const int ALTITUDE_Y = 16;
|
||||
@@ -329,12 +285,6 @@ void onMainViewMenu(const char *result)
|
||||
#endif
|
||||
}
|
||||
|
||||
void displayTelemetryScreen(int index, unsigned int evt);
|
||||
|
||||
const uint16_t LBM_MAINVIEW_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/background.lbm"
|
||||
};
|
||||
|
||||
const uint16_t LBM_MAINVIEW_FLAT[] = {
|
||||
#include "../../bitmaps/Horus/mainview_flat.lbm"
|
||||
};
|
||||
@@ -343,13 +293,6 @@ const uint16_t LBM_CORSAIR[] = {
|
||||
#include "../../bitmaps/Horus/corsair.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TIMER_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/mask_timer_bg.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_RSCALE[] = {
|
||||
#include "../../bitmaps/Horus/mask_rscale.lbm"
|
||||
};
|
||||
|
||||
void menuMainView(evt_t event)
|
||||
{
|
||||
@@ -412,6 +355,16 @@ void menuMainView(evt_t event)
|
||||
lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR);
|
||||
lcdDrawBitmapPattern(4, 10, LBM_TOPMENU_OPENTX, MENU_TITLE_COLOR);
|
||||
lcdDrawTopmenuDatetime();
|
||||
if (1 || usbPlugged()) {
|
||||
lcdDrawBitmapPattern(378, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR);
|
||||
}
|
||||
const uint8_t rssiBarsValue[] = { 30, 40, 50, 60, 80 };
|
||||
const uint8_t rssiBarsHeight[] = { 5, 10, 15, 21, 31 };
|
||||
for (unsigned int i=0; i<DIM(rssiBarsHeight); i++) {
|
||||
uint8_t height = rssiBarsHeight[i];
|
||||
lcdDrawSolidFilledRect(390+i*6, 38-height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR);
|
||||
}
|
||||
|
||||
|
||||
// Flight Mode Name
|
||||
int mode = mixerCurrentFlightMode;
|
||||
@@ -426,38 +379,20 @@ void menuMainView(evt_t event)
|
||||
drawSticks();
|
||||
|
||||
// Trims
|
||||
displayTrims(mode);
|
||||
drawTrims(mode);
|
||||
|
||||
// Model panel
|
||||
lcdDrawFilledRect(248, 58, 188, 158, SOLID, TEXT_BGCOLOR | OPACITY(5));
|
||||
lcdDrawBitmapPattern(256, 62, LBM_MODEL_ICON, TITLE_BGCOLOR);
|
||||
lcd_putsnAtt(293, 68, g_model.header.name, ZCHAR|SMLSIZE, LEN_MODEL_NAME);
|
||||
lcd_putsnAtt(293, 68, g_model.header.name, LEN_MODEL_NAME, ZCHAR|SMLSIZE);
|
||||
lcdDrawSolidHorizontalLine(287, 85, 140, TITLE_BGCOLOR);
|
||||
lcdDrawBitmap(256, 104, LBM_CORSAIR);
|
||||
|
||||
// Timer 1
|
||||
if (g_model.timers[0].start) {
|
||||
TimerState & timerState = timersStates[0];
|
||||
lcdDrawBitmapPattern(58, 61, LBM_TIMER_BACKGROUND, TEXT_BGCOLOR);
|
||||
lcdDrawBitmapPatternPie(60, 64, LBM_RSCALE, TITLE_BGCOLOR, 0, 360*timerState.val/g_model.timers[0].start);
|
||||
putsTimer(125, 94, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
|
||||
if (g_model.timers[0].mode) {
|
||||
drawTimer(50, 61, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
displayMainViewIndex();
|
||||
|
||||
if (g_eeGeneral.view == VIEW_TIMERS_ALTITUDE) {
|
||||
displayTimers();
|
||||
displayMainTelemetryFields();
|
||||
}
|
||||
else if (g_eeGeneral.view == VIEW_CHANNELS) {
|
||||
menuChannelsView(event);
|
||||
}
|
||||
else {
|
||||
displayTelemetryScreen(g_eeGeneral.view - VIEW_TELEM1, event);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (s_gvar_timer > 0) {
|
||||
s_gvar_timer--;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#define DEFAULT_SCROLLBAR_X (LCD_W-1)
|
||||
#define NUM_BODY_LINES (LCD_LINES-1)
|
||||
#define MENU_HEADER_HEIGHT FH
|
||||
#define MENU_INIT_VPOS 0
|
||||
|
||||
struct MenuItem {
|
||||
const char *name;
|
||||
|
||||
@@ -50,7 +50,7 @@ inline bool lcdIsPointOutside(coord_t x, coord_t y)
|
||||
return (x<0 || x>=LCD_W || y<0 || y>=LCD_H);
|
||||
}
|
||||
|
||||
void lcd_clear()
|
||||
void lcdClear()
|
||||
{
|
||||
memset(displayBuf, 0, DISPLAY_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ void lcd_bmp(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_
|
||||
#define LCD_ICON(x, y, icon) lcd_bmp(x, y, icons, icon)
|
||||
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
void lcd_clear();
|
||||
void lcdClear();
|
||||
void lcdSetContrast();
|
||||
|
||||
#if defined(REVPLUS) && !defined(SIMU)
|
||||
|
||||
@@ -98,7 +98,7 @@ void flashBootloader(const char * filename)
|
||||
uint8_t buffer[1024];
|
||||
UINT count;
|
||||
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
displayProgressBar(STR_WRITING);
|
||||
|
||||
static uint8_t unlocked = 0;
|
||||
@@ -137,7 +137,7 @@ void flashSportDevice(ModuleIndex module, const char *filename)
|
||||
pausePulses();
|
||||
watchdogSetTimeout(60*60*100/*1h*/);
|
||||
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
displayProgressBar(STR_WRITING);
|
||||
|
||||
sportFirmwareUpdate(module, filename);
|
||||
|
||||
@@ -42,7 +42,7 @@ void backupEeprom()
|
||||
uint8_t buffer[1024];
|
||||
FIL file;
|
||||
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
displayProgressBar(STR_WRITING);
|
||||
|
||||
// reset unexpectedShutdown to prevent warning when user restores EEPROM backup
|
||||
|
||||
@@ -381,9 +381,9 @@ void menuModelSetup(uint8_t event)
|
||||
#if defined(REV9E)
|
||||
case ITEM_MODEL_TOP_LCD_TIMER:
|
||||
lcd_putsLeft(y, STR_TOPLCDTIMER);
|
||||
putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.topLcdTimer+1, attr);
|
||||
putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.toplcdTimer+1, attr);
|
||||
if (attr) {
|
||||
g_model.topLcdTimer = checkIncDec(event, g_model.topLcdTimer, 0, TIMERS-1, EE_MODEL);
|
||||
g_model.toplcdTimer = checkIncDec(event, g_model.toplcdTimer, 0, TIMERS-1, EE_MODEL);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -37,17 +37,17 @@
|
||||
#ifndef _MENUS_H_
|
||||
#define _MENUS_H_
|
||||
|
||||
#define NO_HI_LEN 25
|
||||
#define NO_HI_LEN 25
|
||||
|
||||
#if defined(TRANSLATIONS_FR)
|
||||
#define MENU_COLUMNS 1
|
||||
#define MENU_COLUMNS 1
|
||||
#else
|
||||
#define MENU_COLUMNS 2
|
||||
#define MENU_COLUMNS 2
|
||||
#endif
|
||||
|
||||
#define MENUS_SCROLLBAR_WIDTH 2
|
||||
#define MENU_COLUMN2_X (8 + LCD_W / 2)
|
||||
#define lcd_putsColumnLeft(x, y, str) lcd_puts((x > (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)) ? MENU_COLUMN2_X : 0, y, str)
|
||||
#define MENUS_SCROLLBAR_WIDTH 2
|
||||
#define MENU_COLUMN2_X (8 + LCD_W / 2)
|
||||
#define lcd_putsColumnLeft(x, y, str) lcd_puts((x > (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)) ? MENU_COLUMN2_X : 0, y, str)
|
||||
|
||||
// Menus related stuff ...
|
||||
typedef uint16_t vertpos_t;
|
||||
@@ -69,8 +69,6 @@ typedef void (*MenuFuncP)(uint8_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(uint8_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
extern const MenuFuncP_PROGMEM menuTabFPV[];
|
||||
extern const MenuFuncP_PROGMEM menuTabTelemetry[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
@@ -83,11 +81,6 @@ void chainMenu(MenuFuncP newMenu);
|
||||
void pushMenu(MenuFuncP newMenu);
|
||||
/// return to last menu in menustack
|
||||
void popMenu();
|
||||
///deliver address of last menu which was popped from
|
||||
inline MenuFuncP lastPopMenu()
|
||||
{
|
||||
return g_menuStack[g_menuStackPtr+1];
|
||||
}
|
||||
|
||||
void doMainScreenGraphics();
|
||||
void menuFirstCalib(uint8_t event);
|
||||
@@ -122,26 +115,25 @@ void menuChannelsView(uint8_t event);
|
||||
|
||||
extern int8_t checkIncDec_Ret; // global helper vars
|
||||
|
||||
#define EDIT_SELECT_MENU -1
|
||||
#define EDIT_SELECT_FIELD 0
|
||||
#define EDIT_MODIFY_FIELD 1
|
||||
#define EDIT_MODIFY_STRING 2
|
||||
extern int8_t s_editMode; // global editmode
|
||||
#define EDIT_SELECT_MENU -1
|
||||
#define EDIT_SELECT_FIELD 0
|
||||
#define EDIT_MODIFY_FIELD 1
|
||||
#define EDIT_MODIFY_STRING 2
|
||||
extern int8_t s_editMode; // global editmode
|
||||
|
||||
// checkIncDec flags
|
||||
#define EE_GENERAL 0x01
|
||||
#define EE_MODEL 0x02
|
||||
#define NO_INCDEC_MARKS 0x04
|
||||
#define INCDEC_SWITCH 0x08
|
||||
#define INCDEC_SOURCE 0x10
|
||||
#define INCDEC_REP10 0x40
|
||||
#define NO_DBLKEYS 0x80
|
||||
#define EE_GENERAL 0x01
|
||||
#define EE_MODEL 0x02
|
||||
#define NO_INCDEC_MARKS 0x04
|
||||
#define INCDEC_SWITCH 0x08
|
||||
#define INCDEC_SOURCE 0x10
|
||||
#define INCDEC_REP10 0x40
|
||||
#define NO_DBLKEYS 0x80
|
||||
|
||||
// mawrow special values
|
||||
#define TITLE_ROW ((uint8_t)-1)
|
||||
#define HIDDEN_ROW ((uint8_t)-2)
|
||||
#define TITLE_ROW ((uint8_t)-1)
|
||||
#define HIDDEN_ROW ((uint8_t)-2)
|
||||
|
||||
typedef bool (*IsValueAvailable)(int);
|
||||
struct CheckIncDecStops {
|
||||
const int count;
|
||||
const int stops[];
|
||||
@@ -274,9 +266,9 @@ swsrc_t switchMenuItem(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8
|
||||
|
||||
void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active, uint8_t attr=ZCHAR);
|
||||
|
||||
#define WARNING_TYPE_ASTERISK 0
|
||||
#define WARNING_TYPE_CONFIRM 1
|
||||
#define WARNING_TYPE_INPUT 2
|
||||
#define WARNING_TYPE_ASTERISK 0
|
||||
#define WARNING_TYPE_CONFIRM 1
|
||||
#define WARNING_TYPE_INPUT 2
|
||||
|
||||
extern const pm_char * s_warning;
|
||||
extern const pm_char * s_warning_info;
|
||||
@@ -284,12 +276,12 @@ extern uint8_t s_warning_info_len;
|
||||
extern uint8_t s_warning_result;
|
||||
extern uint8_t s_warning_type;
|
||||
|
||||
#define MENU_X 30
|
||||
#define MENU_Y 16
|
||||
#define MENU_W LCD_W-(2*MENU_X)
|
||||
#define WARNING_LINE_LEN 32
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
#define MENU_X 30
|
||||
#define MENU_Y 16
|
||||
#define MENU_W LCD_W-(2*MENU_X)
|
||||
#define WARNING_LINE_LEN 32
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
|
||||
void displayBox(const char *title);
|
||||
void displayPopup(const char *title);
|
||||
@@ -301,19 +293,19 @@ extern int16_t s_warning_input_min;
|
||||
extern int16_t s_warning_input_max;
|
||||
extern uint8_t s_warning_info_flags;
|
||||
|
||||
#define DISPLAY_WARNING (*popupFunc)
|
||||
#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define DISPLAY_WARNING (*popupFunc)
|
||||
#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning)
|
||||
#define POPUP_INPUT(s, func, start, min, max) (s_warning = s, s_warning_type = WARNING_TYPE_INPUT, popupFunc = func, s_warning_input_value = start, s_warning_input_min = min, s_warning_input_max = max)
|
||||
#define WARNING_INFO_FLAGS s_warning_info_flags
|
||||
#define WARNING_INFO_FLAGS s_warning_info_flags
|
||||
#define SET_WARNING_INFO(info, len, flags) (s_warning_info = info, s_warning_info_len = len, s_warning_info_flags = flags)
|
||||
|
||||
#define NAVIGATION_MENUS
|
||||
#define MENU_ADD_ITEM(s) do { s_menu_offset_type = MENU_OFFSET_INTERNAL; if (s_menu_count < MENU_MAX_LINES) s_menu[s_menu_count++] = s; } while (0)
|
||||
#define MENU_MAX_LINES 12
|
||||
#define MENU_MAX_DISPLAY_LINES 6
|
||||
#define MENU_ADD_SD_ITEM(s) MENU_ADD_ITEM(s)
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
|
||||
#define MENU_ADD_ITEM(s) do { s_menu_offset_type = MENU_OFFSET_INTERNAL; if (s_menu_count < MENU_MAX_LINES) s_menu[s_menu_count++] = s; } while (0)
|
||||
#define MENU_MAX_LINES 12
|
||||
#define MENU_MAX_DISPLAY_LINES 6
|
||||
#define MENU_ADD_SD_ITEM(s) MENU_ADD_ITEM(s)
|
||||
#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12)
|
||||
extern const char *s_menu[MENU_MAX_LINES];
|
||||
extern uint16_t s_menu_count;
|
||||
extern uint8_t s_menu_flags;
|
||||
@@ -326,12 +318,12 @@ extern uint8_t s_menu_offset_type;
|
||||
const char * displayMenu(uint8_t event);
|
||||
extern void (*menuHandler)(const char *result);
|
||||
|
||||
#define STATUS_LINE_LENGTH 32
|
||||
#define STATUS_LINE_LENGTH 32
|
||||
extern char statusLineMsg[STATUS_LINE_LENGTH];
|
||||
void showStatusLine();
|
||||
void drawStatusLine();
|
||||
|
||||
#define TEXT_FILENAME_MAXLEN 40
|
||||
#define TEXT_FILENAME_MAXLEN 40
|
||||
extern char s_text_file[TEXT_FILENAME_MAXLEN];
|
||||
void menuTextView(uint8_t event);
|
||||
void pushMenuTextView(const char *filename);
|
||||
@@ -343,31 +335,31 @@ void menuChannelsView(uint8_t event);
|
||||
#define LABEL(...) (uint8_t)-1
|
||||
|
||||
#if defined(REV9E) && !defined(SIMU)
|
||||
#define KEY_MOVE_UP KEY_MINUS
|
||||
#define KEY_MOVE_DOWN KEY_PLUS
|
||||
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_MINUS)
|
||||
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_PLUS)
|
||||
#define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_RIGHT
|
||||
#define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_LEFT
|
||||
#define IS_ROTARY_MOVE_RIGHT IS_ROTARY_RIGHT
|
||||
#define IS_ROTARY_MOVE_LEFT IS_ROTARY_LEFT
|
||||
#define KEY_MOVE_UP KEY_MINUS
|
||||
#define KEY_MOVE_DOWN KEY_PLUS
|
||||
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_MINUS)
|
||||
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_PLUS)
|
||||
#define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_RIGHT
|
||||
#define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_LEFT
|
||||
#define IS_ROTARY_MOVE_RIGHT IS_ROTARY_RIGHT
|
||||
#define IS_ROTARY_MOVE_LEFT IS_ROTARY_LEFT
|
||||
#else
|
||||
#define KEY_MOVE_UP KEY_PLUS
|
||||
#define KEY_MOVE_DOWN KEY_MINUS
|
||||
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_PLUS)
|
||||
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_MINUS)
|
||||
#define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_LEFT
|
||||
#define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_RIGHT
|
||||
#define IS_ROTARY_MOVE_RIGHT IS_ROTARY_LEFT
|
||||
#define IS_ROTARY_MOVE_LEFT IS_ROTARY_RIGHT
|
||||
#define KEY_MOVE_UP KEY_PLUS
|
||||
#define KEY_MOVE_DOWN KEY_MINUS
|
||||
#define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_PLUS)
|
||||
#define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_MINUS)
|
||||
#define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_LEFT
|
||||
#define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_RIGHT
|
||||
#define IS_ROTARY_MOVE_RIGHT IS_ROTARY_LEFT
|
||||
#define IS_ROTARY_MOVE_LEFT IS_ROTARY_RIGHT
|
||||
#endif
|
||||
|
||||
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; }
|
||||
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
|
||||
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; }
|
||||
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
|
||||
|
||||
#define POS_VERT_INIT (menuTab ? (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) : 0)
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
#define MENU_FIRST_LINE_EDIT (menuTab ? (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) : 0)
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
|
||||
typedef int16_t (*FnFuncP) (int16_t x);
|
||||
void DrawFunction(FnFuncP fn, uint8_t offset=0);
|
||||
|
||||
@@ -422,7 +422,7 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP
|
||||
{
|
||||
case EVT_ENTRY:
|
||||
menuEntryTime = get_tmr10ms();
|
||||
l_posVert = POS_VERT_INIT;
|
||||
l_posVert = MENU_FIRST_LINE_EDIT;
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
SET_SCROLLBAR_X(LCD_W-1);
|
||||
s_editMode = EDIT_MODE_INIT;
|
||||
@@ -462,7 +462,7 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t posVertInit = POS_VERT_INIT;
|
||||
uint8_t posVertInit = MENU_FIRST_LINE_EDIT;
|
||||
if (s_pgOfs != 0 || l_posVert != posVertInit) {
|
||||
s_pgOfs = 0;
|
||||
l_posVert = posVertInit;
|
||||
@@ -495,7 +495,7 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP
|
||||
}
|
||||
|
||||
do {
|
||||
INC(l_posVert, POS_VERT_INIT, rowcount-1);
|
||||
INC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
s_editMode = 0; // if we go down, we must be in this mode
|
||||
@@ -526,7 +526,7 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP
|
||||
}
|
||||
|
||||
do {
|
||||
DEC(l_posVert, POS_VERT_INIT, rowcount-1);
|
||||
DEC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
s_editMode = 0; // if we go up, we must be in this mode
|
||||
@@ -600,17 +600,21 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP
|
||||
lcdDrawScrollbar(scrollbar_X, MENU_HEADER_HEIGHT, LCD_H-MENU_HEADER_HEIGHT, s_pgOfs, linesCount, NUM_BODY_LINES);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
title(name);
|
||||
}
|
||||
|
||||
m_posVert = l_posVert;
|
||||
m_posHorz = l_posHorz;
|
||||
}
|
||||
|
||||
|
||||
void check_simple(const char *name, check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount)
|
||||
void check_simple(const char * name, check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount)
|
||||
{
|
||||
check(name, event, curr, menuTab, menuTabSize, 0, 0, rowcount);
|
||||
}
|
||||
|
||||
void check_submenu_simple(const char *name, check_event_t event, uint8_t rowcount)
|
||||
void check_submenu_simple(const char * name, check_event_t event, uint8_t rowcount)
|
||||
{
|
||||
check_simple(name, event, 0, 0, 0, rowcount);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void displayPopup(const char *title)
|
||||
|
||||
void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG)
|
||||
{
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
lcd_bmp(0, 0, asterisk_lbm);
|
||||
|
||||
#define MESSAGE_LCD_OFFSET 60
|
||||
|
||||
@@ -45,7 +45,7 @@ const pm_uchar * const splash_lbm = splashdata+4;
|
||||
|
||||
void displaySplash()
|
||||
{
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
lcd_bmp(0, 0, splash_lbm);
|
||||
|
||||
#if MENUS_LOCK == 1
|
||||
|
||||
@@ -268,12 +268,13 @@ void displayTopBar()
|
||||
x -= 12;
|
||||
}
|
||||
|
||||
if (TRAINER_CONNECTED() && SLAVE_MODE()) {
|
||||
LCD_NOTIF_ICON(x, ICON_TRAINEE);
|
||||
x -= 12;
|
||||
}
|
||||
else if (TRAINER_CONNECTED() && !SLAVE_MODE()) {
|
||||
LCD_NOTIF_ICON(x, ICON_TRAINER);
|
||||
if (TRAINER_CONNECTED()) {
|
||||
if (SLAVE_MODE()) {
|
||||
LCD_NOTIF_ICON(x, ICON_TRAINEE);
|
||||
}
|
||||
else {
|
||||
LCD_NOTIF_ICON(x, ICON_TRAINER);
|
||||
}
|
||||
x -= 12;
|
||||
}
|
||||
|
||||
@@ -315,7 +316,7 @@ void displayTimers()
|
||||
TimerState & timerState = timersStates[i];
|
||||
TimerData & timerData = g_model.timers[i];
|
||||
uint8_t y = TIMERS_Y + i*TIMERS_H;
|
||||
if (zlen(timerData.name, LEN_TIMER_NAME) > 0) {
|
||||
if (ZLEN(timerData.name) > 0) {
|
||||
lcd_putsnAtt(TIMERS_X, y-7, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -42,7 +42,7 @@ const pm_uchar bmp_sleep[] PROGMEM = {
|
||||
|
||||
void displaySleepBitmap()
|
||||
{
|
||||
lcd_clear();
|
||||
lcdClear();
|
||||
lcd_bmp(76, 2, bmp_sleep, 0, 60);
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user