From 55b242c96b0162b04d8ce1796c16f335ac834541 Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 2 Nov 2012 16:53:44 +0000 Subject: [PATCH] [all] Telemetry display bug fixes [X9D] Some more work on screens --- src/main_views.cpp | 8 ++++++-- src/model_menus.cpp | 6 +++++- src/open9x.cpp | 12 ++++++++++++ src/open9x.h | 9 +++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main_views.cpp b/src/main_views.cpp index 2a460180f..c05f0f682 100644 --- a/src/main_views.cpp +++ b/src/main_views.cpp @@ -189,8 +189,12 @@ void menuMainView(uint8_t event) // Flight Phase Name uint8_t phase = s_perout_flight_phase; #if defined(PCBX9D) - lcd_putsnAtt(21*FW-1, 5, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR); - lcd_rect(21*FW-3, 5-2, lcdLastPos-20*FW, FH+3); + uint8_t len = ZLEN(g_model.phaseData[phase].name); + if (len > 0) { + uint8_t tmp = (DISPLAY_W - 6*FW - 2 - len*FW/2); + lcd_putsnAtt(tmp, 5, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR); + lcd_rect(tmp-2, 5-2, 3+FW*len, FH+3); + } #else lcd_putsnAtt(6*FW, 2*FH, g_model.phaseData[phase].name, sizeof(g_model.phaseData[phase].name), ZCHAR); #endif diff --git a/src/model_menus.cpp b/src/model_menus.cpp index af5e0c59d..57e27004b 100644 --- a/src/model_menus.cpp +++ b/src/model_menus.cpp @@ -3176,12 +3176,16 @@ void menuModelTelemetry(uint8_t event) switch (m_posHorz) { case 0: bar.source = checkIncDecModel(event, barSource, 0, g_model.frsky.usrProto ? TELEM_DISPLAY_MAX : TELEM_NOUSR_MAX); + if (checkIncDec_Ret) { + bar.barMin = 0; + bar.barMax = 255-maxTelemValue(bar.source); + } break; case 1: bar.barMin = checkIncDec(event, bar.barMin, 0, 254-bar.barMax, EE_MODEL|NO_INCDEC_MARKS); break; case 2: - bar.barMax = 255 - checkIncDec(event, 255-bar.barMax, bar.barMin+1, 255, EE_MODEL|NO_INCDEC_MARKS); + bar.barMax = 255 - checkIncDec(event, 255-bar.barMax, bar.barMin+1, maxTelemValue(barSource), EE_MODEL|NO_INCDEC_MARKS); break; } } diff --git a/src/open9x.cpp b/src/open9x.cpp index f8bd2bf89..9f4a07d2c 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -158,6 +158,18 @@ char idx2char(int8_t idx) return ' '; } +#if defined(PCBX9D) +uint8_t zlen(const char *str, uint8_t size) +{ + while (size > 0) { + if (str[size-1] != 0) + return size; + size--; + } + return size; +} +#endif + PhaseData *phaseaddress(uint8_t idx) { return &g_model.phaseData[idx]; diff --git a/src/open9x.h b/src/open9x.h index be113fa6f..e6d0d168c 100644 --- a/src/open9x.h +++ b/src/open9x.h @@ -1267,5 +1267,10 @@ void checkFlashOnBeep(); void putsTelemetryValue(uint8_t x, uint8_t y, int16_t val, uint8_t unit, uint8_t att); #endif -#endif // gruvin9x_h -/*eof*/ +#if defined(PCBX9D) +uint8_t zlen(const char *str, uint8_t size); +#define ZLEN(s) zlen(s, sizeof(s)) +#endif + +#endif +