From e18e6f9c41a9cefcd52772613b6804da79db42e4 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 22 Oct 2015 17:16:21 +0200 Subject: [PATCH] [Horus] Refactoring continued --- radio/src/bitmaps/Horus/mask_rscale_p1.png | Bin 453 -> 0 bytes radio/src/bitmaps/Horus/mask_rscale_p13.png | Bin 852 -> 0 bytes radio/src/bitmaps/Horus/mask_rscale_p2.png | Bin 520 -> 0 bytes radio/src/bitmaps/Horus/mask_rscale_p3.png | Bin 318 -> 0 bytes ...pmenu_usb_ico.png => mask_topmenu_usb.png} | Bin radio/src/gui/9X/gui.h | 1 + radio/src/gui/9X/lcd.cpp | 2 +- radio/src/gui/9X/lcd.h | 2 +- radio/src/gui/9X/menus.h | 35 +-- radio/src/gui/9X/navigation.cpp | 10 +- radio/src/gui/9X/popups.cpp | 2 +- radio/src/gui/9X/splash.cpp | 2 +- radio/src/gui/Horus/bitmaps.cpp | 16 ++ radio/src/gui/Horus/gui.h | 5 + radio/src/gui/Horus/lcd.cpp | 155 ++++-------- radio/src/gui/Horus/lcd.h | 40 +-- radio/src/gui/Horus/menu_general_calib.cpp | 32 ++- radio/src/gui/Horus/menus.h | 15 +- radio/src/gui/Horus/navigation.cpp | 6 +- radio/src/gui/Horus/view_main.cpp | 119 ++------- radio/src/gui/Taranis/gui.h | 1 + radio/src/gui/Taranis/lcd.cpp | 2 +- radio/src/gui/Taranis/lcd.h | 2 +- .../gui/Taranis/menu_general_sdmanager.cpp | 4 +- .../src/gui/Taranis/menu_general_version.cpp | 2 +- radio/src/gui/Taranis/menu_model_setup.cpp | 4 +- radio/src/gui/Taranis/menus.h | 130 +++++----- radio/src/gui/Taranis/navigation.cpp | 16 +- radio/src/gui/Taranis/popups.cpp | 2 +- radio/src/gui/Taranis/splash.cpp | 2 +- radio/src/gui/Taranis/view_main.cpp | 15 +- radio/src/gui/Taranis/widgets.cpp | 2 +- radio/src/lua_api.cpp | 2 +- radio/src/main_arm.cpp | 115 ++------- radio/src/main_avr.cpp | 2 +- radio/src/myeeprom.h | 2 +- radio/src/opentx.cpp | 10 +- radio/src/storage/eeprom_conversions.cpp | 8 +- radio/src/storage/eeprom_raw.cpp | 8 +- radio/src/storage/eeprom_rlc.cpp | 12 +- radio/src/storage/sdcard_raw.cpp | 8 +- radio/src/storage/storage.h | 6 +- radio/src/storage/storage_common.cpp | 8 +- radio/src/targets/Taranis/board_taranis.cpp | 8 +- radio/src/targets/Taranis/board_taranis.h | 8 +- radio/src/targets/Taranis/bootloader/boot.cpp | 6 +- radio/src/targets/Taranis/top_lcd_driver.cpp | 16 +- radio/src/tasks_arm.cpp | 4 +- radio/src/tests/frsky.cpp | 4 +- radio/src/tests/lcd.cpp | 44 ++-- radio/util/compile.py | 234 ------------------ 51 files changed, 376 insertions(+), 753 deletions(-) delete mode 100644 radio/src/bitmaps/Horus/mask_rscale_p1.png delete mode 100644 radio/src/bitmaps/Horus/mask_rscale_p13.png delete mode 100644 radio/src/bitmaps/Horus/mask_rscale_p2.png delete mode 100644 radio/src/bitmaps/Horus/mask_rscale_p3.png rename radio/src/bitmaps/Horus/{mask_topmenu_usb_ico.png => mask_topmenu_usb.png} (100%) delete mode 100755 radio/util/compile.py diff --git a/radio/src/bitmaps/Horus/mask_rscale_p1.png b/radio/src/bitmaps/Horus/mask_rscale_p1.png deleted file mode 100644 index 852c9170fc76289d9d3c3bb0416bbd518ced7164..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmSQK*5Dp-y;YjHK@;M7UB8!3Q zuY)k7lg8`{prB-lYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&3=E7;o-U3d z5v^~p+jlhw2(W!96m;cKQK(=ER_m=0e*eI7ixB?weO6Tk1X0Wx&lO4 z`yMY?wQBmWG{!Bt+`g9`TmQ!ym`O{tF`nM^;J4i-9q0Ss zKQo?tZp`8+!SZMN)hyQ7>l2r~G;z3Wa^wB?eBSzVPm2yN(cPfa?YI2$i#pFq$MPK~ zsXVBx`|`4rlC{JD diff --git a/radio/src/bitmaps/Horus/mask_rscale_p13.png b/radio/src/bitmaps/Horus/mask_rscale_p13.png deleted file mode 100644 index 9a93beb95c371a21805f77b8919458876124ca2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 852 zcmV-a1FQUrP)b72(6&#kMMXwxPdv1r6VOc>~7GnJWtfP~Fv zGKiZy_C zT3T949<0_ictk`Zk;s1oP(?)g`ue_1YMLhf{rwV+MrCMds44&gU>L^7$c4jU#>dCm z*x2Ct`T1j9PESvA3579*KV79{WP?pR!0q^G9`5g`_fRSzJqY&Of<+8Tp{ zgQ%)nu#lRYn+v+)Du8L4jE;^H2n335MP1jc1K>Cgot>Q}*K!~b;NjuHH2_cEjEbVj zwzgd9z$X*V%*>Po5E1I?>e$`gbsxa8 zEZW-I%7SQUXdoVsy9)rYy}ex)fc!P((b18+001K+BV|K`LLp4kbQj?M{+`y>*0KPm zrltTmI5@zvEO!6^PEJnn`~5|W4-5>D%jHNWlW3YoQ&SW3^Ydgfnco8dY;JB+Q&aP0 z@o+dyI-TbA^_AY<-hy0XVn+=`B7)E7BNB;_N~OvN0NB~t z!RPZaHZ}%;ZQFErcUM&W-$*19l>q=G5(!>jUI3V$p8j!h5#jv&ymElN&d$z0y%#Et zo12@T1Hk))w70ka7~t{o@pl05?t_Jeg^~}MuOgex{vIH&OeVwf@-kgrU1b$l6a}bY z3@g$8{yq~E6LfTRd<#%tUk`u+AXU`u?XB$X?MXZym#eEQF$_Zt!w|=DB%Mx6)d9X! eE|(KkRpk#DDW^h`gqMf_00003mA^{ZE=l#+J4{g@f> zJP+Hpubx6Q8f82lYdL`*L)dIKuL4AbSS-eDHq#IAJdbQP>kAQ&$C=OPdI12F$;1~x zzJ_wST~}U&Kt;PfT^vIq zTHjti$k}2bzPmDpFj{*}D= zin#5 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) diff --git a/radio/src/gui/9X/popups.cpp b/radio/src/gui/9X/popups.cpp index 1f50cfab0..2da1eaa1a 100644 --- a/radio/src/gui/9X/popups.cpp +++ b/radio/src/gui/9X/popups.cpp @@ -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 diff --git a/radio/src/gui/9X/splash.cpp b/radio/src/gui/9X/splash.cpp index 5075df0dc..5d9fc72b7 100644 --- a/radio/src/gui/9X/splash.cpp +++ b/radio/src/gui/9X/splash.cpp @@ -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 diff --git a/radio/src/gui/Horus/bitmaps.cpp b/radio/src/gui/Horus/bitmaps.cpp index 926363f5f..0dcd39ba1 100644 --- a/radio/src/gui/Horus/bitmaps.cpp +++ b/radio/src/gui/Horus/bitmaps.cpp @@ -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 */ diff --git a/radio/src/gui/Horus/gui.h b/radio/src/gui/Horus/gui.h index a259d766d..7dd1e4036 100644 --- a/radio/src/gui/Horus/gui.h +++ b/radio/src/gui/Horus/gui.h @@ -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[]; diff --git a/radio/src/gui/Horus/lcd.cpp b/radio/src/gui/Horus/lcd.cpp index 1ebc7dc71..ac0802476 100644 --- a/radio/src/gui/Horus/lcd.cpp +++ b/radio/src/gui/Horus/lcd.cpp @@ -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); } } diff --git a/radio/src/gui/Horus/lcd.h b/radio/src/gui/Horus/lcd.h index e53092fd0..e9e8a22f6 100644 --- a/radio/src/gui/Horus/lcd.h +++ b/radio/src/gui/Horus/lcd.h @@ -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) diff --git a/radio/src/gui/Horus/menu_general_calib.cpp b/radio/src/gui/Horus/menu_general_calib.cpp index ebc3a901e..c06d4bd82 100644 --- a/radio/src/gui/Horus/menu_general_calib.cpp +++ b/radio/src/gui/Horus/menu_general_calib.cpp @@ -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 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); diff --git a/radio/src/gui/Horus/navigation.cpp b/radio/src/gui/Horus/navigation.cpp index 916c5eaf9..dda8c5029 100644 --- a/radio/src/gui/Horus/navigation.cpp +++ b/radio/src/gui/Horus/navigation.cpp @@ -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 diff --git a/radio/src/gui/Horus/view_main.cpp b/radio/src/gui/Horus/view_main.cpp index 8ba758b20..e5e2a261d 100644 --- a/radio/src/gui/Horus/view_main.cpp +++ b/radio/src/gui/Horus/view_main.cpp @@ -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 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= 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--; diff --git a/radio/src/gui/Taranis/gui.h b/radio/src/gui/Taranis/gui.h index 3b1133990..a4fd2619a 100644 --- a/radio/src/gui/Taranis/gui.h +++ b/radio/src/gui/Taranis/gui.h @@ -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; diff --git a/radio/src/gui/Taranis/lcd.cpp b/radio/src/gui/Taranis/lcd.cpp index 23326517e..88c6ebeea 100644 --- a/radio/src/gui/Taranis/lcd.cpp +++ b/radio/src/gui/Taranis/lcd.cpp @@ -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); } diff --git a/radio/src/gui/Taranis/lcd.h b/radio/src/gui/Taranis/lcd.h index 6278e7849..003f32c5e 100644 --- a/radio/src/gui/Taranis/lcd.h +++ b/radio/src/gui/Taranis/lcd.h @@ -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) diff --git a/radio/src/gui/Taranis/menu_general_sdmanager.cpp b/radio/src/gui/Taranis/menu_general_sdmanager.cpp index 330bf4895..ab12ac9fd 100644 --- a/radio/src/gui/Taranis/menu_general_sdmanager.cpp +++ b/radio/src/gui/Taranis/menu_general_sdmanager.cpp @@ -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); diff --git a/radio/src/gui/Taranis/menu_general_version.cpp b/radio/src/gui/Taranis/menu_general_version.cpp index 545267343..3151f8761 100644 --- a/radio/src/gui/Taranis/menu_general_version.cpp +++ b/radio/src/gui/Taranis/menu_general_version.cpp @@ -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 diff --git a/radio/src/gui/Taranis/menu_model_setup.cpp b/radio/src/gui/Taranis/menu_model_setup.cpp index 4db7ed90a..e52ca025d 100644 --- a/radio/src/gui/Taranis/menu_model_setup.cpp +++ b/radio/src/gui/Taranis/menu_model_setup.cpp @@ -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 diff --git a/radio/src/gui/Taranis/menus.h b/radio/src/gui/Taranis/menus.h index 0bc157359..81736caf0 100644 --- a/radio/src/gui/Taranis/menus.h +++ b/radio/src/gui/Taranis/menus.h @@ -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); diff --git a/radio/src/gui/Taranis/navigation.cpp b/radio/src/gui/Taranis/navigation.cpp index b8509711a..6724101e6 100644 --- a/radio/src/gui/Taranis/navigation.cpp +++ b/radio/src/gui/Taranis/navigation.cpp @@ -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); } diff --git a/radio/src/gui/Taranis/popups.cpp b/radio/src/gui/Taranis/popups.cpp index 37cd02783..0fd46346c 100644 --- a/radio/src/gui/Taranis/popups.cpp +++ b/radio/src/gui/Taranis/popups.cpp @@ -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 diff --git a/radio/src/gui/Taranis/splash.cpp b/radio/src/gui/Taranis/splash.cpp index 4f0e88d7d..d9045b6bf 100644 --- a/radio/src/gui/Taranis/splash.cpp +++ b/radio/src/gui/Taranis/splash.cpp @@ -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 diff --git a/radio/src/gui/Taranis/view_main.cpp b/radio/src/gui/Taranis/view_main.cpp index 7b41f1ab0..d9b91211f 100644 --- a/radio/src/gui/Taranis/view_main.cpp +++ b/radio/src/gui/Taranis/view_main.cpp @@ -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 { diff --git a/radio/src/gui/Taranis/widgets.cpp b/radio/src/gui/Taranis/widgets.cpp index 65fc53e10..b9ebd0496 100644 --- a/radio/src/gui/Taranis/widgets.cpp +++ b/radio/src/gui/Taranis/widgets.cpp @@ -42,7 +42,7 @@ const pm_uchar bmp_sleep[] PROGMEM = { void displaySleepBitmap() { - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_sleep, 0, 60); lcdRefresh(); } diff --git a/radio/src/lua_api.cpp b/radio/src/lua_api.cpp index b01e3fa0f..61915ac71 100644 --- a/radio/src/lua_api.cpp +++ b/radio/src/lua_api.cpp @@ -417,7 +417,7 @@ static int luaLcdLock(lua_State *L) static int luaLcdClear(lua_State *L) { - if (luaLcdAllowed) lcd_clear(); + if (luaLcdAllowed) lcdClear(); return 0; } diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index 443ee65e8..a0736f7d6 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -107,66 +107,7 @@ void checkEeprom() } #endif -#if defined(PCBFLAMENCO) -void guiMain(evt_t evt) -{ - lcd_clear(); - -#if defined(LUA) - uint32_t t0 = get_tmr10ms(); - static uint32_t lastLuaTime = 0; - uint16_t interval = (lastLuaTime == 0 ? 0 : (t0 - lastLuaTime)); - lastLuaTime = t0; - if (interval > maxLuaInterval) { - maxLuaInterval = interval; - } - - // run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running) - luaTask(0, RUN_MIX_SCRIPT | RUN_FUNC_SCRIPT | RUN_TELEM_BG_SCRIPT, false); - - // wait for LCD DMA to finish before continuing, because code from this point - // is allowed to change the contents of LCD buffer - // - // WARNING: make sure no code above this line does any change to the LCD display buffer! - // - - bool scriptWasRun = luaTask(evt, RUN_STNDAL_SCRIPT, true); - - t0 = get_tmr10ms() - t0; - if (t0 > maxLuaDuration) { - maxLuaDuration = t0; - } - - if (!scriptWasRun) -#endif - - { - // normal GUI from menus - const char *warn = s_warning; - uint8_t menu = s_menu_count; - // lcd_clear(); - if (menuEvent) { - m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0; - m_posHorz = 0; - evt = menuEvent; - menuEvent = 0; - AUDIO_MENUS(); - } - g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt); - if (warn) DISPLAY_WARNING(evt); - if (menu) { - const char * result = displayMenu(evt); - if (result) { - menuHandler(result); - putEvent(EVT_MENU_UP); - } - } - drawStatusLine(); - } - - lcdRefresh(); -} -#else +#if defined(GUI) void guiMain(evt_t evt) { #if defined(LUA) @@ -192,40 +133,27 @@ void guiMain(evt_t evt) // run Lua scripts that use LCD bool standaloneScriptWasRun = luaTask(evt, RUN_STNDAL_SCRIPT, true); - bool refreshScreen = true; if (!standaloneScriptWasRun) { - refreshScreen = !luaTask(evt, RUN_TELEM_FG_SCRIPT, true); + luaTask(evt, RUN_TELEM_FG_SCRIPT, true); } t0 = get_tmr10ms() - t0; if (t0 > maxLuaDuration) { maxLuaDuration = t0; } - - if (!standaloneScriptWasRun) #else lcdRefreshWait(); // WARNING: make sure no code above this line does any change to the LCD display buffer! - const bool refreshScreen = true; + const bool standaloneScriptWasRun = false; #endif - { -#if defined(PCBHORUS) - for (int i=0; i<2; i++) { + + if (!standaloneScriptWasRun) { + while (1) { +#if !defined(COLORLCD) + lcdClear(); #endif // normal GUI from menus - const char *warn = s_warning; + const char * warn = s_warning; uint8_t menu = s_menu_count; - #if !defined(COLORLCD) - if (refreshScreen) { - lcd_clear(); - } - #endif - if (menuEvent) { - m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : -1; - m_posHorz = 0; - evt = menuEvent; - menuEvent = 0; - AUDIO_MENUS(); - } g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt); if (warn) DISPLAY_WARNING(evt); if (menu) { @@ -236,11 +164,22 @@ void guiMain(evt_t evt) } } drawStatusLine(); -#if defined(PCBHORUS) - if (menuEvent != EVT_ENTRY || menuEvent != EVT_ENTRY_UP) + if (menuEvent == EVT_ENTRY) { + m_posVert = -1; + m_posHorz = 0; + evt = menuEvent; + menuEvent = 0; + } + else if (menuEvent == EVT_ENTRY_UP) { + m_posVert = g_menuPos[g_menuStackPtr]; + m_posHorz = 0; + evt = menuEvent; + menuEvent = 0; + } + else { break; + } } -#endif } lcdRefresh(); @@ -271,7 +210,7 @@ void perMain() #if defined(USB_MASS_STORAGE) if (usbPlugged()) { // disable access to menus - lcd_clear(); + lcdClear(); menuMainView(0); lcdRefresh(); return; @@ -290,13 +229,13 @@ void perMain() #endif #if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) - topLcdRefreshStart(); - setTopFirstTimer(getValue(MIXSRC_FIRST_TIMER+g_model.topLcdTimer)); + toplcdRefreshStart(); + setTopFirstTimer(getValue(MIXSRC_FIRST_TIMER+g_model.toplcdTimer)); setTopSecondTimer(g_eeGeneral.globalTimer + sessionTimer); setTopRssi(TELEMETRY_RSSI()); setTopBatteryValue(g_vbat100mV); setTopBatteryState(GET_TXBATT_BARS(), IS_TXBATT_WARNING()); - topLcdRefreshEnd(); + toplcdRefreshEnd(); #endif #if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) diff --git a/radio/src/main_avr.cpp b/radio/src/main_avr.cpp index 367b6d928..cb1738b40 100644 --- a/radio/src/main_avr.cpp +++ b/radio/src/main_avr.cpp @@ -129,7 +129,7 @@ void perMain() const char *warn = s_warning; uint8_t menu = s_menu_count; - lcd_clear(); + lcdClear(); if (menuEvent) { m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0; m_posHorz = 0; diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 346a5f2e3..df9f5dea9 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -2333,7 +2333,7 @@ PACK(typedef struct { ARM_FIELD(TelemetrySensor telemetrySensors[MAX_SENSORS]) - TARANIS_REV9E_FIELD(uint8_t topLcdTimer) + TARANIS_REV9E_FIELD(uint8_t toplcdTimer) }) ModelData; extern EEGeneral g_eeGeneral; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 80a53dca6..0fbcc8a48 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1925,7 +1925,7 @@ void opentxClose() #endif #if !defined(PCBTARANIS) - if (s_storageDirtyMsk & EE_MODEL) { + if (storageDirtyMsk & EE_MODEL) { displayPopup(STR_SAVEMODEL); } #endif @@ -2607,10 +2607,10 @@ int main(void) #if defined(CPUM2560) // Time to switch off - lcd_clear(); + lcdClear(); displayPopup(STR_SHUTDOWN); opentxClose(); - lcd_clear() ; + lcdClear() ; lcdRefresh() ; boardOff(); // Only turn power off if necessary wdt_disable(); @@ -2663,7 +2663,7 @@ uint32_t pwrCheck() #if defined(SHUTDOWN_CONFIRMATION) while (1) { lcdRefreshWait(); - lcd_clear(); + lcdClear(); POPUP_CONFIRMATION("Confirm Shutdown"); evt_t evt = getEvent(false); DISPLAY_WARNING(evt); @@ -2687,7 +2687,7 @@ uint32_t pwrCheck() else { lcdRefreshWait(); unsigned index = pwrPressedDuration() / (PWR_PRESS_SHUTDOWN / 4); - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_shutdown, index*60, 60); lcdRefresh(); return e_power_press; diff --git a/radio/src/storage/eeprom_conversions.cpp b/radio/src/storage/eeprom_conversions.cpp index 85a9232b5..1506d2fed 100644 --- a/radio/src/storage/eeprom_conversions.cpp +++ b/radio/src/storage/eeprom_conversions.cpp @@ -747,7 +747,7 @@ PACK(typedef struct { TelemetrySensor telemetrySensors[MAX_SENSORS]; - TARANIS_REV9E_FIELD(uint8_t topLcdTimer) + TARANIS_REV9E_FIELD(uint8_t toplcdTimer) }) ModelData_v217; #if defined(PCBTARANIS) @@ -1356,7 +1356,7 @@ void ConvertModel_217_to_218(ModelData & model) newModel.telemetrySensors[i] = oldModel.telemetrySensors[i]; } #if defined(PCBTARANIS) && defined(REV9E) - newModel.topLcdTimer = oldModel.topLcdTimer; + newModel.toplcdTimer = oldModel.toplcdTimer; #endif } @@ -1375,7 +1375,7 @@ void ConvertModel(int id, int version) uint8_t currModel = g_eeGeneral.currModel; g_eeGeneral.currModel = id; - s_storageDirtyMsk = EE_MODEL; + storageDirty(EE_MODEL); storageCheck(true); g_eeGeneral.currModel = currModel; } @@ -1421,7 +1421,7 @@ bool eeConvert() version = 218; ConvertGeneralSettings_217_to_218(g_eeGeneral); } - s_storageDirtyMsk = EE_GENERAL; + storageDirty(EE_GENERAL); storageCheck(true); #if defined(COLORLCD) diff --git a/radio/src/storage/eeprom_raw.cpp b/radio/src/storage/eeprom_raw.cpp index 03f664507..078b9c0ab 100644 --- a/radio/src/storage/eeprom_raw.cpp +++ b/radio/src/storage/eeprom_raw.cpp @@ -375,9 +375,9 @@ void storageCheck(bool immediately) assert(eepromWriteState == EEPROM_IDLE); - if (s_storageDirtyMsk & EE_GENERAL) { + if (storageDirtyMsk & EE_GENERAL) { TRACE("eeprom write general"); - s_storageDirtyMsk -= EE_GENERAL; + storageDirtyMsk -= EE_GENERAL; writeGeneralSettings(); if (immediately) eepromWriteWait(); @@ -385,9 +385,9 @@ void storageCheck(bool immediately) return; } - if (s_storageDirtyMsk & EE_MODEL) { + if (storageDirtyMsk & EE_MODEL) { TRACE("eeprom write model"); - s_storageDirtyMsk -= EE_MODEL; + storageDirtyMsk -= EE_MODEL; writeModel(g_eeGeneral.currModel); if (immediately) eepromWriteWait(); diff --git a/radio/src/storage/eeprom_rlc.cpp b/radio/src/storage/eeprom_rlc.cpp index 160e83a59..2cc1e6ce3 100644 --- a/radio/src/storage/eeprom_rlc.cpp +++ b/radio/src/storage/eeprom_rlc.cpp @@ -865,8 +865,8 @@ void RlcFile::flush() #if defined (EEPROM_PROGRESS_BAR) void RlcFile::DisplayProgressBar(uint8_t x) { - if (s_storageDirtyMsk || isWriting() || eeprom_buffer_size) { - uint8_t len = s_storageDirtyMsk ? 1 : limit((uint8_t)1, (uint8_t)(7 - (m_rlc_len/m_ratio)), (uint8_t)7); + if (storageDirtyMsk || isWriting() || eeprom_buffer_size) { + uint8_t len = storageDirtyMsk ? 1 : limit((uint8_t)1, (uint8_t)(7 - (m_rlc_len/m_ratio)), (uint8_t)7); drawFilledRect(x+1, 0, 5, FH, SOLID, ERASE); drawFilledRect(x+2, 7-len, 3, len); } @@ -940,16 +940,16 @@ void storageCheck(bool immediately) eeFlush(); } - if (s_storageDirtyMsk & EE_GENERAL) { + if (storageDirtyMsk & EE_GENERAL) { TRACE("eeprom write general"); - s_storageDirtyMsk -= EE_GENERAL; + storageDirtyMsk -= EE_GENERAL; theFile.writeRlc(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&g_eeGeneral, sizeof(EEGeneral), immediately); if (!immediately) return; } - if (s_storageDirtyMsk & EE_MODEL) { + if (storageDirtyMsk & EE_MODEL) { TRACE("eeprom write model"); - s_storageDirtyMsk = 0; + storageDirtyMsk = 0; theFile.writeRlc(FILE_MODEL(g_eeGeneral.currModel), FILE_TYP_MODEL, (uint8_t*)&g_model, sizeof(g_model), immediately); } } diff --git a/radio/src/storage/sdcard_raw.cpp b/radio/src/storage/sdcard_raw.cpp index 062ccc7b5..a1eca7eb0 100644 --- a/radio/src/storage/sdcard_raw.cpp +++ b/radio/src/storage/sdcard_raw.cpp @@ -165,9 +165,9 @@ void storageCheck(bool immediately) // eepromWriteWait(); // } - if (s_storageDirtyMsk & EE_GENERAL) { + if (storageDirtyMsk & EE_GENERAL) { TRACE("eeprom write general"); - s_storageDirtyMsk -= EE_GENERAL; + storageDirtyMsk -= EE_GENERAL; writeGeneralSettings(); // if (immediately) // eepromWriteWait(); @@ -175,9 +175,9 @@ void storageCheck(bool immediately) return; } - if (s_storageDirtyMsk & EE_MODEL) { + if (storageDirtyMsk & EE_MODEL) { TRACE("eeprom write model"); - s_storageDirtyMsk -= EE_MODEL; + storageDirtyMsk -= EE_MODEL; const char * error = writeModel(); if (error) { TRACE("writeModel error=%s", error); diff --git a/radio/src/storage/storage.h b/radio/src/storage/storage.h index 30f15aacc..71af54093 100644 --- a/radio/src/storage/storage.h +++ b/radio/src/storage/storage.h @@ -49,10 +49,10 @@ #define WRITE_DELAY_10MS 200 #endif -extern uint8_t s_storageDirtyMsk; -extern tmr10ms_t s_storageDirtyTime10ms; +extern uint8_t storageDirtyMsk; +extern tmr10ms_t storageDirtyTime10ms; -#define TIME_TO_WRITE() (s_storageDirtyMsk && (tmr10ms_t)(get_tmr10ms() - s_storageDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS) +#define TIME_TO_WRITE() (storageDirtyMsk && (tmr10ms_t)(get_tmr10ms() - storageDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS) void storageEraseAll(bool warn); void storageFormat(); diff --git a/radio/src/storage/storage_common.cpp b/radio/src/storage/storage_common.cpp index ee4df2e72..9dc2ab2c6 100644 --- a/radio/src/storage/storage_common.cpp +++ b/radio/src/storage/storage_common.cpp @@ -36,13 +36,13 @@ #include "../opentx.h" -uint8_t s_storageDirtyMsk; -tmr10ms_t s_storageDirtyTime10ms; +uint8_t storageDirtyMsk; +tmr10ms_t storageDirtyTime10ms; void storageDirty(uint8_t msk) { - s_storageDirtyMsk |= msk; - s_storageDirtyTime10ms = get_tmr10ms() ; + storageDirtyMsk |= msk; + storageDirtyTime10ms = get_tmr10ms() ; } void preModelLoad() diff --git a/radio/src/targets/Taranis/board_taranis.cpp b/radio/src/targets/Taranis/board_taranis.cpp index e73accc14..c78b31eee 100644 --- a/radio/src/targets/Taranis/board_taranis.cpp +++ b/radio/src/targets/Taranis/board_taranis.cpp @@ -157,7 +157,7 @@ void boardInit() #if defined(REV9E) if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) { - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_lock, 0, 60); lcdRefresh(); lcdRefreshWait(); @@ -169,7 +169,7 @@ void boardInit() duration = get_tmr10ms() - start; if (duration < PWR_PRESS_DURATION_MIN) { unsigned index = duration / (PWR_PRESS_DURATION_MIN / 4); - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_startup, index*60, 60); } else if (duration >= PWR_PRESS_DURATION_MAX) { @@ -193,7 +193,7 @@ void boardInit() else { backlightInit(); } - topLcdInit(); + toplcdInit(); #else backlightInit(); #endif @@ -203,7 +203,7 @@ void boardOff() { BACKLIGHT_OFF(); #if defined(REV9E) - topLcdOff(); + toplcdOff(); #endif #if defined(REV9E) diff --git a/radio/src/targets/Taranis/board_taranis.h b/radio/src/targets/Taranis/board_taranis.h index 89296cd5c..1be5ca851 100644 --- a/radio/src/targets/Taranis/board_taranis.h +++ b/radio/src/targets/Taranis/board_taranis.h @@ -347,10 +347,10 @@ void lcdOff(void); // Top LCD driver #if defined(REV9E) -void topLcdInit(void); -void topLcdOff(void); -void topLcdRefreshStart(void); -void topLcdRefreshEnd(void); +void toplcdInit(void); +void toplcdOff(void); +void toplcdRefreshStart(void); +void toplcdRefreshEnd(void); void setTopFirstTimer(int32_t value); void setTopSecondTimer(uint32_t value); void setTopRssi(uint32_t rssi); diff --git a/radio/src/targets/Taranis/bootloader/boot.cpp b/radio/src/targets/Taranis/bootloader/boot.cpp index 1400fc4bc..fb47cb1e6 100644 --- a/radio/src/targets/Taranis/bootloader/boot.cpp +++ b/radio/src/targets/Taranis/bootloader/boot.cpp @@ -402,7 +402,7 @@ int main() lcdInit(); backlightInit(); - lcd_clear(); + lcdClear(); lcd_putsn(0, 0, (const char *)bootloaderVersion, 0); // trick to avoid bootloaderVersion to be optimized out ... lcd_putsLeft(0, BOOTLOADER_TITLE); lcd_invert_line(0); @@ -427,7 +427,7 @@ int main() Tenms = 0; lcdRefreshWait(); - lcd_clear(); + lcdClear(); lcd_putsLeft(0, BOOTLOADER_TITLE); lcd_invert_line(0); @@ -686,7 +686,7 @@ int main() if (state == ST_REBOOT) { if (readKeys() == 0) { - lcd_clear(); + lcdClear(); lcdRefresh(); lcdRefreshWait(); RCC->CSR |= RCC_CSR_RMVF; //clear the reset flags in RCC clock control & status register diff --git a/radio/src/targets/Taranis/top_lcd_driver.cpp b/radio/src/targets/Taranis/top_lcd_driver.cpp index 938c602ee..566cd27fb 100644 --- a/radio/src/targets/Taranis/top_lcd_driver.cpp +++ b/radio/src/targets/Taranis/top_lcd_driver.cpp @@ -233,7 +233,7 @@ extern "C" void TIM8_BRK_TIM12_IRQHandler() } #endif -void topLcdInit() +void toplcdInit() { RCC_AHB1PeriphClockCmd(TOPLCD_RCC_AHB1Periph, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; @@ -254,15 +254,15 @@ void topLcdInit() ht1621SendCommand(1, 0x01); ht1621SendCommand(1, 0x29); - topLcdRefreshStart(); - topLcdRefreshEnd(); + toplcdRefreshStart(); + toplcdRefreshEnd(); } -void topLcdOff() +void toplcdOff() { BL_OFF(); - topLcdRefreshStart(); - topLcdRefreshEnd(); + toplcdRefreshStart(); + toplcdRefreshEnd(); } void setTopFirstTimer(int32_t value) @@ -419,13 +419,13 @@ void setTopSecondTimer(uint32_t value) Ht1621Data1[3] |= 0x10; // "Operation Time" } -void topLcdRefreshStart() +void toplcdRefreshStart() { memset(Ht1621Data1, 0, sizeof(Ht1621Data1)); memset(Ht1621Data2, 0, sizeof(Ht1621Data2)); } -void topLcdRefreshEnd() +void toplcdRefreshEnd() { ht1621WrAllData(0, Ht1621Data1); ht1621WrAllData(1, Ht1621Data2); diff --git a/radio/src/tasks_arm.cpp b/radio/src/tasks_arm.cpp index 523153b33..502336dc4 100644 --- a/radio/src/tasks_arm.cpp +++ b/radio/src/tasks_arm.cpp @@ -192,7 +192,7 @@ void menusTask(void * pdata) } #if defined(PCBTARANIS) && defined(REV9E) - topLcdOff(); + toplcdOff(); #endif BACKLIGHT_OFF(); @@ -201,7 +201,7 @@ void menusTask(void * pdata) #elif defined(PCBTARANIS) displaySleepBitmap(); #else - lcd_clear(); + lcdClear(); displayPopup(STR_SHUTDOWN); #endif diff --git a/radio/src/tests/frsky.cpp b/radio/src/tests/frsky.cpp index c82109319..5dd2391ad 100644 --- a/radio/src/tests/frsky.cpp +++ b/radio/src/tests/frsky.cpp @@ -341,7 +341,7 @@ TEST(FrSkySPORT, frskySetCellVoltage) EXPECT_EQ(telemetryItems[0].valueMax, 2071); //display test - lcd_clear(); + lcdClear(); g_model.frsky.voltsSource = FRSKY_VOLTS_SOURCE_A1; } @@ -416,7 +416,7 @@ TEST(FrSkySPORT, frskySetCellVoltageTwoSensors) EXPECT_EQ(telemetryItems[2].valueMax, 287); //display test - lcd_clear(); + lcdClear(); g_model.frsky.voltsSource = FRSKY_VOLTS_SOURCE_A1; } diff --git a/radio/src/tests/lcd.cpp b/radio/src/tests/lcd.cpp index 8d3521112..e1200efb5 100644 --- a/radio/src/tests/lcd.cpp +++ b/radio/src/tests/lcd.cpp @@ -114,7 +114,7 @@ bool checkScreenshot(const QString & test) TEST(outdezNAtt, test_unsigned) { - lcd_clear(); + lcdClear(); lcd_outdezNAtt(0, 0, 65530, LEFT|UNSIGN); EXPECT_TRUE(checkScreenshot("unsigned")) << "Unsigned numbers will be bad displayed"; } @@ -122,7 +122,7 @@ TEST(outdezNAtt, test_unsigned) #if defined(CPUARM) TEST(outdezNAtt, testBigNumbers) { - lcd_clear(); + lcdClear(); lcd_outdezNAtt(0, 0, 1234567, LEFT); lcd_outdezNAtt(0, FH, -1234567, LEFT); EXPECT_TRUE(checkScreenshot("big_numbers")); @@ -132,28 +132,28 @@ TEST(outdezNAtt, testBigNumbers) TEST(Lcd, Invers_0_0) { - lcd_clear(); + lcdClear(); lcd_putsAtt(0, 0, "Test", INVERS); EXPECT_TRUE(checkScreenshot("invers_0_0")); } TEST(Lcd, Invers_0_1) { - lcd_clear(); + lcdClear(); lcd_putsAtt(0, 1, "Test", INVERS); EXPECT_TRUE(checkScreenshot("invers_0_1")); } TEST(Lcd, Prec2_Left) { - lcd_clear(); + lcdClear(); lcd_outdezAtt(0, 0, 2, PREC2|LEFT); EXPECT_TRUE(checkScreenshot("prec2_left")); } TEST(Lcd, Prec2_Right) { - lcd_clear(); + lcdClear(); lcd_outdezAtt(LCD_W, LCD_H-FH, 2, PREC2); EXPECT_TRUE(checkScreenshot("prec2_right")); } @@ -161,7 +161,7 @@ TEST(Lcd, Prec2_Right) #if defined(CPUARM) TEST(Lcd, Prec1_Dblsize_Invers) { - lcd_clear(); + lcdClear(); lcd_outdezAtt(LCD_W, 10, 51, PREC1|DBLSIZE|INVERS); EXPECT_TRUE(checkScreenshot("prec1_dblsize_invers")); } @@ -169,14 +169,14 @@ TEST(Lcd, Prec1_Dblsize_Invers) TEST(Lcd, Line_Wrap) { - lcd_clear(); + lcdClear(); lcd_puts(LCD_W-10, 0, "TEST"); EXPECT_TRUE(checkScreenshot("line_wrap")); } TEST(Lcd, DblsizeBottomRight) { - lcd_clear(); + lcdClear(); lcd_putsAtt(LCD_W-20, LCD_H-16, "TEST", DBLSIZE); EXPECT_TRUE(checkScreenshot("dblsize_bottom_right")); } @@ -184,7 +184,7 @@ TEST(Lcd, DblsizeBottomRight) #if defined(CPUARM) TEST(Lcd, Smlsize_putsStrIdx) { - lcd_clear(); + lcdClear(); putsStrIdx(0, 0, "FM", 0, SMLSIZE); EXPECT_TRUE(checkScreenshot("smlsize_putsstridx")); } @@ -192,7 +192,7 @@ TEST(Lcd, Smlsize_putsStrIdx) TEST(Lcd, vline) { - lcd_clear(); + lcdClear(); for (int x=0; x<100; x+=2) { lcd_vline(x, x/2, 12); } @@ -202,7 +202,7 @@ TEST(Lcd, vline) #if defined(CPUARM) TEST(Lcd, vline_x_lt0) { - lcd_clear(); + lcdClear(); lcd_vline(50, -10, 12); lcd_vline(100, -10, 1); EXPECT_TRUE(checkScreenshot("vline_lt0")); @@ -212,7 +212,7 @@ TEST(Lcd, vline_x_lt0) #if defined(CPUARM) TEST(Lcd, Smlsize) { - lcd_clear(); + lcdClear(); lcd_putsAtt(0, 0, "TESTgy,", SMLSIZE); lcd_putsAtt(10, 22, "TESTgy,", SMLSIZE|INVERS); drawFilledRect(8, 40, 100, 20); @@ -229,7 +229,7 @@ TEST(Lcd, Smlsize) TEST(Lcd, Stdsize) { - lcd_clear(); + lcdClear(); lcd_putsAtt(0, 0, "TEST", 0); lcd_putsAtt(10, 22, "TEST", INVERS); drawFilledRect(8, 40, 100, 20); @@ -246,7 +246,7 @@ TEST(Lcd, Stdsize) TEST(Lcd, Midsize) { - lcd_clear(); + lcdClear(); lcd_putsAtt(0, 0, "TEST", MIDSIZE); lcd_putsAtt(10, 22, "TEST", MIDSIZE|INVERS); drawFilledRect(8, 40, 100, 20); @@ -263,7 +263,7 @@ TEST(Lcd, Midsize) TEST(Lcd, Dblsize) { - lcd_clear(); + lcdClear(); lcd_putsAtt(2, 10, "TST", DBLSIZE); lcd_putsAtt(42, 10, "TST", DBLSIZE|INVERS); drawFilledRect(80, 8, 46, 24); @@ -282,7 +282,7 @@ TEST(Lcd, Dblsize) #if defined(PCBTARANIS) TEST(Lcd, DrawSwitch) { - lcd_clear(); + lcdClear(); putsSwitches(0, 10, SWSRC_SA0, 0); putsSwitches(30, 10, SWSRC_SA0, SMLSIZE); // putsSwitches(60, 10, SWSRC_SA0, MIDSIZE); missing arrows in this font @@ -294,7 +294,7 @@ TEST(Lcd, DrawSwitch) #if defined(PCBTARANIS) TEST(Lcd, BMPWrapping) { - lcd_clear(); + lcdClear(); uint8_t bitmap[2+40*40/2]; bmpLoad(bitmap, "./tests/plane.bmp", 40, 40); lcd_bmp(200, 0, bitmap); @@ -308,7 +308,7 @@ TEST(Lcd, BMPWrapping) #if defined(PCBTARANIS) TEST(Lcd, lcdDrawHorizontalLine) { - lcd_clear(); + lcdClear(); lcdDrawHorizontalLine(0, 10, LCD_W, DOTTED); lcdDrawHorizontalLine(0, 20, LCD_W, SOLID); lcdDrawHorizontalLine(50, 30, LCD_W, 0xEE); //too wide @@ -321,7 +321,7 @@ TEST(Lcd, lcdDrawHorizontalLine) #if defined(PCBTARANIS) TEST(Lcd, lcdDrawVerticalLine) { - lcd_clear(); + lcdClear(); lcdDrawVerticalLine(10, 0, LCD_H, DOTTED); lcdDrawVerticalLine(20, 0, LCD_H, SOLID); lcdDrawVerticalLine(30, 30, LCD_H, 0xEE); //too high @@ -361,7 +361,7 @@ public: #if defined(PCBTARANIS) TEST(Lcd, lcd_bmpLoadAndDisplay) { - lcd_clear(); + lcdClear(); // Test proper BMP files, they should display correctly { TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(7, 32)); @@ -415,7 +415,7 @@ TEST(Lcd, lcdDrawLine) int start, length, xOffset; uint8_t pattern; - lcd_clear(); + lcdClear(); start = 5; pattern = SOLID; diff --git a/radio/util/compile.py b/radio/util/compile.py deleted file mode 100755 index c41dcfd82..000000000 --- a/radio/util/compile.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python - -import os, sys, shutil, platform, getpass, subprocess, zipfile, ftplib, httplib, threading - -BINARY_DIR = "../build/" - -options_stock = [[("", "EXT=STD"), ("frsky", "EXT=FRSKY"), ("jeti", "EXT=JETI"), ("ardupilot", "EXT=ARDUPILOT"), ("nmea", "EXT=NMEA")], - [("", "HELI=NO"), ("heli", "HELI=YES")], - [("", "TEMPLATES=NO"), ("templates", "TEMPLATES=YES")], - [("", ""), ("nosplash", "SPLASH=NO")], - [("", ""), ("nofp", "FLIGHT_PHASES=NO")], - [("", "AUDIO=NO"), ("audio", "AUDIO=YES")], - [("", "HAPTIC=NO"), ("haptic", "HAPTIC=YES")], - [("", "PXX=NO"), ("PXX", "PXX=YES")], - [("", "DSM2=NO"), ("DSM2", "DSM2=PPM")], - [("", ""), ("ppmca", "PPM_CENTER_ADJUSTABLE=YES")], - [("", "NAVIGATION=NO"), ("potscroll", "NAVIGATION=POTS")], - [("", ""), ("autoswitch", "AUTOSWITCH=YES")], - [("", ""), ("pgbar", "EEPROM_PROGRESS_BAR=YES")], - [("", "UNITS=METRIC"), ("imperial", "UNITS=IMPERIAL")], - ] - -options_v4 = [[("", "EXT=FRSKY")], - [("", "HELI=NO"), ("heli", "HELI=YES")], - [("", "TEMPLATES=NO"), ("templates", "TEMPLATES=YES")], - [("", ""), ("nofp", "FLIGHT_PHASES=NO")], - [("", "SDCARD=NO"), ("sdcard", "SDCARD=YES")], - [("", "SOMO=NO"), ("SOMO", "SOMO=YES")], - [("", ""), ("ppmca", "PPM_CENTER_ADJUSTABLE=YES")], - [("", ""), ("autoswitch", "AUTOSWITCH=YES")], - [("", ""), ("pgbar", "EEPROM_PROGRESS_BAR=YES")], - [("", "UNITS=METRIC"), ("imperial", "UNITS=IMPERIAL")], - ] - -options_arm = [[("", "EXT=FRSKY")], - [("", "HELI=NO"), ("heli", "HELI=YES")], - [("", "TEMPLATES=NO"), ("templates", "TEMPLATES=YES")], - [("", ""), ("nofp", "FLIGHT_PHASES=NO")], - [("", ""), ("autoswitch", "AUTOSWITCH=YES")], - [("", "UNITS=METRIC"), ("imperial", "UNITS=IMPERIAL")], - ] - -languages = ["en", "fr", "se"] - -#ftp_host = "ftpperso.free.fr" -#ftp_user = "open9x" -ftp_host = "open9x.freehosting.com" -ftp_user = "openxfre" -ftp_directory = "public_html/binaries/" - -def upload(binaries, ext, stamp): - if not ftp: - return - - print "Zip creation..." - zip_name = "release.zip" - zip = zipfile.ZipFile(zip_name, "w", zipfile.ZIP_DEFLATED) - for bin in binaries: - zip.write(BINARY_DIR + bin + "." + ext, bin + "." + ext) - zip.write(BINARY_DIR + stamp, stamp) - zip.close() - - print "FTP transfer..." - ftp_connection = ftplib.FTP(ftp_host, ftp_user, ftp_password) - try: - ftp_connection.delete(ftp_directory + zip_name) - except: - pass - f = open(zip_name, 'rb') - ftp_connection.storbinary('STOR ' + ftp_directory + zip_name, f) - f.close() - ftp_connection.quit() - - print "ZIP extraction...", - http_connection = httplib.HTTPConnection("open9x.freehosting.com") - http_connection.request("GET", "/binaries/uncompress.php") - response = http_connection.getresponse() - print response.status, response.reason - os.remove(zip_name) - -global_current = 0 -global_count = 0 -def generate(hex, arg, extension, options, languages, maxsize): - global global_current - global global_count - - result = [] - states = [0] * len(options) - - count = len(languages) - for option in options: - count *= len(option) - global_count += count - - while 1: - # print index, states - - for language in languages: - hex_file = hex - make_args = ["make", arg] - for i, option in enumerate(options): - state = states[len(options) - 1 - i] - if option[state][0]: - hex_file += "-" + option[state][0] - make_args.append(option[state][1]) - hex_file += "-" + language - make_args.append("TRANSLATIONS=" + language.upper()) - if mt: - cwd = language - else: - cwd = "." - - size = 0 - if compile: - subprocess.Popen(["make", "clean", arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd).wait() - p = subprocess.Popen(make_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd) - ret = p.wait() - stderr = p.stderr.read() - global_current += 1 - print "[%d/%d]" % (global_current, global_count), hex_file - if ret or "error" in stderr: - print stderr - exit() - for line in stderr.split("\n"): - if "warning" in line: - print " ", line - for line in p.stdout.readlines(): - if line.startswith("Program:"): - parts = line.split(" ") - while "" in parts: - parts.remove("") - size = int(parts[1]) - if size > maxsize: - print " ", line[:-1], "[NOT RELEASED]" - else: - print " ", line, - if line.startswith("Data:"): - print " ", line, - - if size <= maxsize: - binary_name = hex_file + "." + extension - if compile: - shutil.copyfile(cwd + "/open9x." + extension, BINARY_DIR + binary_name) - result.append(hex_file) - - for index, state in enumerate(states): - if state < len(options[len(options) - 1 - index]) - 1: - for i in range(index): - states[i] = 0 - states[index] += 1 - break - else: - break - - # stamp - stamp = "stamp-open9x-%s.txt" % hex.split("-")[1] - subprocess.Popen(["make", hex.split("-")[1] + "-stamp"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd="../src").wait() - shutil.copyfile("../src/" + stamp, BINARY_DIR + stamp) - - return result, stamp - -class GenerateThread(threading.Thread): - def __init__ (self, hex, arg, extension, options, language, maxsize): - threading.Thread.__init__(self) - self.hex = hex - self.arg = arg - self.extension = extension - self.options = options - self.language = language - self.maxsize = maxsize - - def run(self): - self.hexes, self.stamp = generate(self.hex, self.arg, self.extension, self.options, [self.language], self.maxsize) - -def multithread_generate(hex, arg, extension, options, languages, maxsize): - if mt: - result = [] - threads = [] - for language in languages: - thread = GenerateThread(hex, arg, extension, options, language, maxsize) - threads.append(thread) - thread.start() - for thread in threads: - thread.join() - result.extend(thread.hexes) - stamp = thread.stamp - return result, stamp - else: - return generate(hex, arg, extension, options, languages, maxsize) - - -def generate_c9x_list(filename, hexes, board): - f = open(filename, "w") - f.write("const char *open9x_%s_binaries[] = {\n" % board) - for hex in hexes: - f.write('"%s",\n' % hex) - f.write("0\n};\n") - -if __name__ == "__main__": - - ftp = "ftp" in sys.argv - mt = "mt" in sys.argv and platform.system() != "Windows" - compile = not "nc" in sys.argv - - if ftp: - ftp_password = getpass.getpass() - - if mt: - shutil.rmtree("util", True) - shutil.copytree("../util", "util") - for lang in languages: - print "Directory %s creation..." % lang - shutil.rmtree(lang, True) - shutil.copytree("../src", lang) - - if platform.system() == "Windows": - # arm board - hexes, stamp = generate("open9x-arm", "PCB=ARM", "bin", options_arm, languages, 262000) - generate_c9x_list("../../companion9x/src/open9x-arm-binaries.cpp", hexes, "arm") - upload(hexes, "bin", stamp) - - else: - # stock board - if not "v4" in sys.argv: - hexes, stamp = multithread_generate("open9x-stock", "PCB=STD", "hex", options_stock, languages, 65530) - generate_c9x_list("../../companion9x/src/open9x-stock-binaries.cpp", hexes, "stock") - upload(hexes, "hex", stamp) - - # v4 board - if not "stock" in sys.argv: - hexes, stamp = multithread_generate("open9x-v4", "PCB=V4", "hex", options_v4, languages, 262000) - generate_c9x_list("../../companion9x/src/open9x-v4-binaries.cpp", hexes, "v4") - upload(hexes, "hex", stamp) -