diff --git a/src/frsky.cpp b/src/frsky.cpp index 37b0317a1..217fda60f 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -52,7 +52,7 @@ uint8_t frskyRxBuffer[FRSKY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE]; // Ditto for transmit buffer uint8_t frskyTxBufferCount = 0; uint8_t FrskyRxBufferReady = 0; -uint8_t frskyStreaming = 0; +int8_t frskyStreaming = -1; uint8_t frskyUsrStreaming = 0; FrskyData frskyTelemetry[2]; diff --git a/src/frsky.h b/src/frsky.h index dd2e377d4..5c6a582d6 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -128,7 +128,7 @@ extern uint8_t barsThresholds[BAR_MAX-3]; #endif // Global Fr-Sky telemetry data variables -extern uint8_t frskyStreaming; // >0 (true) == data is streaming in. 0 = nodata detected for some time +extern int8_t frskyStreaming; // >0 (true) == data is streaming in. 0 = nodata detected for some time extern uint8_t frskyUsrStreaming; #define SEND_MODEL_ALARMS 6 diff --git a/src/main_views.cpp b/src/main_views.cpp index 27ab219bb..d2ec0d779 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -197,6 +197,11 @@ void menuMainView(uint8_t event) if(s_timerState[0]==TMR_BEEPING) { s_timerState[0] = TMR_STOPPED; } +#ifdef NAVIGATION_RE1 + else if (s_warning) { + s_warning = NULL; + } +#endif else if (view == e_timer2) { resetTimer(1); } @@ -227,8 +232,10 @@ void menuMainView(uint8_t event) break; #ifdef NAVIGATION_RE1 case EVT_KEY_LONG(BTN_RE1): + killEvents(event); if (s_inflight_value && !s_warning) { s_warning = s_inflight_label; + s_editMode = 1; break; } // no break @@ -247,7 +254,7 @@ void menuMainView(uint8_t event) trim2OfsSwLock = trimSw; #ifdef FRSKY - if (view_base == e_telemetry && frskyStreaming && view > ALTERNATE_VIEW) { + if (view_base == e_telemetry && frskyStreaming >= 0 && view > ALTERNATE_VIEW) { putsModelName(0, 0, g_model.name, g_eeGeneral.currModel, 0); uint8_t att = (g_vbat100mV < g_eeGeneral.vBatWarn ? BLINK : 0); putsVBat(14*FW,0,att); @@ -381,7 +388,7 @@ void menuMainView(uint8_t event) } #if defined(FRSKY) else if (view_base == e_telemetry) { - if (frskyStreaming) { + if (frskyStreaming >= 0) { uint8_t y0, x0, blink; if (view == e_telemetry+ALTERNATE_VIEW) { @@ -587,8 +594,13 @@ void menuMainView(uint8_t event) } #ifdef NAVIGATION_RE1 + check_rotary_encoder(); if (s_warning) { + if (p1valdiff) { + *s_inflight_value = s_inflight_shift + checkIncDecModel(event, (*s_inflight_value)-s_inflight_shift, s_inflight_min, s_inflight_max); + } displayBox(); + lcd_outdezAtt(16, 4*FH, (int8_t)(*s_inflight_value-s_inflight_shift), LEFT); } #endif diff --git a/src/menus.cpp b/src/menus.cpp index 25b38b4ae..040c892a3 100644 --- a/src/menus.cpp +++ b/src/menus.cpp @@ -150,6 +150,23 @@ bool check_submenu_simple(uint8_t event, uint8_t maxrow) return check_simple(event, 0, 0, 0, maxrow); } +#ifdef NAVIGATION_RE1 +void check_rotary_encoder() +{ + // check rotary encoder 1 if changed -> cursor down/up + static int16_t re1valprev; + p1valdiff = 0; + scrollRE = re1valprev - g_rotenc[0]; + if (scrollRE) { + re1valprev = g_rotenc[0]; + if (s_editMode > 0) { + p1valdiff = -scrollRE; + scrollRE = 0; + } + } +} +#endif + #define SCROLL_TH 64 #define SCROLL_POT1_TH 32 @@ -165,17 +182,7 @@ bool check(uint8_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTa int8_t maxcol = MAXCOL(m_posVert); #ifdef NAVIGATION_RE1 - // check rotary encoder 1 if changed -> cursor down/up - static int16_t re1valprev; - p1valdiff = 0; - scrollRE = re1valprev - g_rotenc[0]; - if (scrollRE) { - re1valprev = g_rotenc[0]; - if (s_editMode > 0) { - p1valdiff = -scrollRE; - scrollRE = 0; - } - } + check_rotary_encoder(); if (m_posVert < 0 && (event==EVT_KEY_FIRST(BTN_RE1) || event==EVT_KEY_FIRST(KEY_MENU))) { popMenu(); killEvents(event); @@ -444,6 +451,9 @@ void popMenu() void chainMenu(MenuFuncP newMenu) { +#ifdef NAVIGATION_RE1 + s_warning = NULL; +#endif g_menuStack[g_menuStackPtr] = newMenu; (*newMenu)(EVT_ENTRY); AUDIO_MENUS(); @@ -451,6 +461,10 @@ void chainMenu(MenuFuncP newMenu) void pushMenu(MenuFuncP newMenu) { +#ifdef NAVIGATION_RE1 + s_warning = NULL; +#endif + g_menuPos[g_menuStackPtr] = m_posVert; g_menuStackPtr++; diff --git a/src/menus.h b/src/menus.h index d26938af5..07481bf22 100644 --- a/src/menus.h +++ b/src/menus.h @@ -109,10 +109,12 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max); #ifdef NAVIGATION_RE1 extern int8_t *s_inflight_value; +extern const pm_char *s_inflight_label; #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) +void check_rotary_encoder(); #else #define INFLIGHT(val) 0 #define CHECK_INFLIGHT_INCDEC_MODELVAR(event, var, min, max, shift, label) \