diff --git a/src/frsky.h b/src/frsky.h index 0cee5793d..dd2e377d4 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -95,9 +95,9 @@ struct FrskyHubData { uint16_t gpsLongitude_ap; uint16_t gpsLatitude_ap; uint16_t gpsCourse_ap; - uint32_t pilotLatitude; // 2 spares reused - uint32_t pilotLongitude; // 2 spares reused - uint16_t baroAltitude_bp; // spare reused + uint32_t pilotLatitude; // 2 spares reused + uint32_t pilotLongitude; // 2 spares reused + uint16_t baroAltitude_bp; // spare reused uint16_t gpsLongitudeEW; // East/West uint16_t gpsLatitudeNS; // North/South int16_t accelX; // 1/256th gram (-8g ~ +8g) @@ -109,7 +109,8 @@ struct FrskyHubData { // 17 spares uint16_t volts_bp; uint16_t volts_ap; - uint16_t maxGpsSpeed; // spare reused + // end of FrSky Hub data + uint16_t maxGpsSpeed; }; #elif defined(WS_HOW_HIGH) diff --git a/src/lcd.cpp b/src/lcd.cpp index c42fc6c8f..1da398dd0 100644 --- a/src/lcd.cpp +++ b/src/lcd.cpp @@ -208,9 +208,9 @@ void lcd_outdez8(uint8_t x, uint8_t y, int8_t val) lcd_outdezAtt(x, y, val); } -void lcd_outdezAtt(uint8_t x, uint8_t y, int16_t val, uint8_t mode) +void lcd_outdezAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags) { - lcd_outdezNAtt(x, y, val, mode); + lcd_outdezNAtt(x, y, val, flags); } // TODO use doxygen style comments here @@ -301,6 +301,14 @@ void lcd_outdezNAtt(uint8_t x, uint8_t y, int16_t val, uint8_t flags, uint8_t le // TODO we could change the '-' to have one pixel removed at its left if (neg) { lcd_putcAtt(x, y, '-', flags); lcd_plot(x, y+3); } + +#ifdef NAVIGATION_RE1 + if (flags & SURROUNDED) { + xn = lcd_lastPos - x + 2; + if (!neg) { x+=FW; xn-=FW; } + lcd_rect(x-1, y-1, xn, 9, BLINK_ON_PHASE ? DOTTED : ~DOTTED); + } +#endif } void lcd_mask(uint8_t *p, uint8_t mask, uint8_t att) diff --git a/src/main_views.cpp b/src/main_views.cpp index 646b2a892..0b3cb7362 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -225,6 +225,17 @@ void menuMainView(uint8_t event) instantTrimSwLock = true; trim2OfsSwLock = true; break; +#ifdef NAVIGATION_RE1 + case EVT_KEY_LONG(BTN_RE1): + if (s_inflight_value && !s_warning) { + s_warning = s_inflight_label; + break; + } + // no break + case EVT_KEY_BREAK(BTN_RE1): + s_warning = NULL; + break; +#endif } bool trimSw = isFunctionActive(FUNC_INSTANT_TRIM); @@ -575,5 +586,11 @@ void menuMainView(uint8_t event) // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s } +#ifdef NAVIGATION_RE1 + if (s_warning) { + displayBox(); + } +#endif + theFile.DisplayProgressBar(20*FW+1); } diff --git a/src/menus.cpp b/src/menus.cpp index 3f4e210d2..25b38b4ae 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -465,19 +465,39 @@ void pushMenu(MenuFuncP newMenu) (*newMenu)(EVT_ENTRY); } +const pm_char * s_warning = 0; +void displayBox() +{ + lcd_filled_rect(10, 16, 108, 40, SOLID, WHITE); + lcd_rect(10, 16, 108, 40); + lcd_puts(16, 3*FH, s_warning); + // could be a place for a s_warning_info +} + #ifdef NAVIGATION_RE1 -void * s_inflight_value; +int8_t *s_inflight_value = NULL; int16_t s_inflight_min; int16_t s_inflight_max; +int16_t s_inflight_shift; const pm_char *s_inflight_label; -uint8_t s_inflight_flags; -void checkInflightIncDec(void *value, int16_t i_min, int16_t i_max, const pm_char *label, uint8_t flags) +void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16_t i_max, int8_t i_shift, const pm_char *label) { - s_inflight_value = value; - s_inflight_min = i_min; - s_inflight_max = i_max; - s_inflight_label = label; - s_inflight_flags = flags; + *value = i_shift + checkIncDecModel(event, (*value)-i_shift, i_min, i_max); + + if (event == EVT_KEY_LONG(BTN_RE1)) { + if (value == s_inflight_value) { + s_inflight_value = NULL; + } + else { + s_inflight_value = value; + s_inflight_min = i_min; + s_inflight_max = i_max; + s_inflight_shift = i_shift; + s_inflight_label = label; + } + } } #endif + + diff --git a/src/menus.h b/src/menus.h index fb57f81cd..17b7d91f6 100644 --- a/src/menus.h +++ b/src/menus.h @@ -107,6 +107,18 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); #define CHECK_INCDEC_GENVAR( event, var, min, max) \ var = checkIncDecGen(event,var,min,max) +#ifdef NAVIGATION_RE1 +extern int8_t *s_inflight_value; +#define INFLIGHT(val) (s_inflight_value==&val ? SURROUNDED : 0) +void checkInFlightIncDecModel(uint8_t event, int8_t *value, int16_t i_min, int16_t i_max, int8_t i_shift, const pm_char *label); +#define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, imin, imax, ishift, label) \ + checkInFlightIncDecModel(event, &var, imin, imax, ishift, label) +#else +#define INFLIGHT(val) 0 +#define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, min, max, shift, label) \ + var = shift+checkIncDecModel(event,var-shift,min,max) +#endif + // Menus related stuff ... #ifdef NAVIGATION_RE1 extern int8_t m_posVert; @@ -148,4 +160,8 @@ if (!check_submenu_simple(event,lines_count-1)) return; TITLE(title); \ SIMPLE_SUBMENU_NOTITLE(lines_count) +extern const pm_char * s_warning; +// TODO macro for s_warning +void displayBox(); + #endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index d95a783af..9ebfd677b 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -99,19 +99,11 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = { #endif }; -const pm_char * s_warning = 0; -const pm_char * s_warning_info; -uint8_t s_warning_info_len; -// uint8_t s_warning_info_att not needed now -uint8_t s_confirmation = 0; -void displayBox() -{ - lcd_filled_rect(10, 16, 108, 40, SOLID, WHITE); - lcd_rect(10, 16, 108, 40); - lcd_puts(16, 3*FH, s_warning); - // could be a place for a s_warning_info -} +const pm_char * s_warning_info; +uint8_t s_warning_info_len; +// uint8_t s_warning_info_att not needed now +uint8_t s_confirmation = 0; void displayPopup(const pm_char * pstr) { @@ -1603,20 +1595,15 @@ void menuProcLimits(uint8_t event) } break; case 1: - lcd_outdezAtt( 12*FW, y, (int8_t)(ld->min-100), attr); + lcd_outdezAtt(12*FW, y, (int8_t)(ld->min-100), attr | INFLIGHT(ld->min)); if (active) { - ld->min -= 100; - CHECK_INCDEC_MODELVAR( event, ld->min, -limit, limit); - ld->min += 100; - // CHECK_INFLIGHT_INCDEC(ld->min, -125, 125, PSTR("Min Limit"), EE_MODEL); + CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->min, -limit, limit, +100, STR_MINLIMIT); } break; case 2: - lcd_outdezAtt( 17*FW, y, (int8_t)(ld->max+100), attr); + lcd_outdezAtt(17*FW, y, (int8_t)(ld->max+100), attr | INFLIGHT(ld->max)); if (active) { - ld->max += 100; - CHECK_INCDEC_MODELVAR( event, ld->max, -limit, limit); - ld->max -= 100; + CHECK_INFLIGHT_INCDEC_MODELVAR(event, ld->max, -limit, limit, -100, STR_MAXLIMIT); } break; case 3: diff --git a/src/o9xstrings.cpp b/src/o9xstrings.cpp index fe282684d..d72714b4d 100644 --- a/src/o9xstrings.cpp +++ b/src/o9xstrings.cpp @@ -273,4 +273,6 @@ const pm_char STR_SYNCMENU[] PROGMEM = TR_SYNCMENU; #if defined(NAVIGATION_RE1) const pm_char STR_BACK[] PROGMEM = TR_BACK; +const pm_char STR_MINLIMIT[] PROGMEM = TR_MINLIMIT; +const pm_char STR_MAXLIMIT[] PROGMEM = TR_MAXLIMIT; #endif diff --git a/src/o9xstrings.h b/src/o9xstrings.h index 7231fb6c0..cb49ece85 100644 --- a/src/o9xstrings.h +++ b/src/o9xstrings.h @@ -327,5 +327,6 @@ extern const pm_char STR_RXNUM[]; extern const pm_char STR_SYNCMENU[]; extern const pm_char STR_BACK[]; #define LEN_BACK PSIZE(TR_BACK) - +extern const pm_char STR_MINLIMIT[]; +extern const pm_char STR_MAXLIMIT[]; #endif diff --git a/src/translations/en.h b/src/translations/en.h index 3b47dcc5b..558e02149 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -298,3 +298,5 @@ #define TR_RXNUM "RxNum" #define TR_SYNCMENU "Sync [MENU]" #define TR_BACK "Back" +#define TR_MINLIMIT "Min Limit" +#define TR_MAXLIMIT "Max Limit" diff --git a/src/translations/fr.h b/src/translations/fr.h index b296199c1..50d4d6fe0 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -298,3 +298,5 @@ #define TR_RXNUM "RxNum" #define TR_SYNCMENU "Sync [MENU]" #define TR_BACK "Back" +#define TR_MINLIMIT "Min Limit" +#define TR_MAXLIMIT "Max Limit"