From c1486c878061b27a072631df2bfc851f52b036d2 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 15 Jul 2021 10:45:57 +0200 Subject: [PATCH 1/3] Adjust audio announcements on trim limits --- radio/src/opentx.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index dab39d0fc..4d014785b 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1003,21 +1003,26 @@ void checkTrims() else #endif { - if (before>TRIM_MIN && after<=TRIM_MIN) { + int16_t tMax = g_model.extendedTrims ? TRIM_EXTENDED_MAX : TRIM_MAX; + int16_t tMin = g_model.extendedTrims ? TRIM_EXTENDED_MIN : TRIM_MIN; + if (before > tMin && after <= tMin) { beepTrim = true; AUDIO_TRIM_MIN(); killEvents(event); } - else if (before=TRIM_MAX) { + else if (before < tMax && after >= tMax) { beepTrim = true; AUDIO_TRIM_MAX(); killEvents(event); } - if ((beforeTRIM_MAX) || (before>after && after tMax) || // increasing over tMax + (before > after && after < tMin)) { // decreasing under tMin + after = before; } + // Clip at hard limits if (after < TRIM_EXTENDED_MIN) { after = TRIM_EXTENDED_MIN; } @@ -1586,7 +1591,8 @@ void instantTrim() } } if (addTrim && abs(delta) >= INSTANT_TRIM_MARGIN) { - int16_t trim = limit(TRIM_EXTENDED_MIN, (delta + trims[stick]) / 2, TRIM_EXTENDED_MAX); + int16_t trim = limit( + TRIM_EXTENDED_MIN, (delta + trims[stick]) / 2, TRIM_EXTENDED_MAX); setTrimValue(trimFlightMode, stick, trim); } } From cdbc62c5590663641522e741fd3b2dd381012e82 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 15 Jul 2021 10:46:44 +0200 Subject: [PATCH 2/3] [color] clip trim value displayed based on range set. Resolves #443 --- radio/src/gui/colorlcd/layouts/trims.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/layouts/trims.cpp b/radio/src/gui/colorlcd/layouts/trims.cpp index f164b6968..07cbebc07 100644 --- a/radio/src/gui/colorlcd/layouts/trims.cpp +++ b/radio/src/gui/colorlcd/layouts/trims.cpp @@ -43,6 +43,10 @@ void MainViewHorizontalTrim::paint(BitmapBuffer * dc) trimMin = TRIM_MIN; trimMax = TRIM_MAX; } + + int16_t dispVal = value; + if (dispVal < trimMin) dispVal = trimMin; + if (dispVal > trimMax) dispVal = trimMax; // Trim line dc->drawSolidFilledRect( @@ -50,7 +54,7 @@ void MainViewHorizontalTrim::paint(BitmapBuffer * dc) width() - TRIM_SQUARE_SIZE + 1, TRIM_LINE_WIDTH, DEFAULT_COLOR); // Trim square - coord_t x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (value - trimMin), + coord_t x = divRoundClosest((width() - TRIM_SQUARE_SIZE) * (dispVal - trimMin), trimMax - trimMin); drawTrimSquare(dc, x, 0, (value < TRIM_MIN || value > TRIM_MAX) From 000836a01868a821a2519a997ad439f82ccc3286 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 15 Jul 2021 11:32:07 +0200 Subject: [PATCH 3/3] [color] Fix vertical trims as well --- radio/src/gui/colorlcd/layouts/trims.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/layouts/trims.cpp b/radio/src/gui/colorlcd/layouts/trims.cpp index 07cbebc07..1336522a1 100644 --- a/radio/src/gui/colorlcd/layouts/trims.cpp +++ b/radio/src/gui/colorlcd/layouts/trims.cpp @@ -89,15 +89,20 @@ void MainViewVerticalTrim::paint(BitmapBuffer * dc) trimMax = TRIM_MAX; } + int16_t dispVal = value; + if (dispVal < trimMin) dispVal = trimMin; + if (dispVal > trimMax) dispVal = trimMax; + // Trim line dc->drawSolidFilledRect((width() - TRIM_LINE_WIDTH) / 2, TRIM_SQUARE_SIZE / 2, TRIM_LINE_WIDTH, height() - TRIM_SQUARE_SIZE + 1, DEFAULT_COLOR); // Trim square - coord_t y = height() - TRIM_SQUARE_SIZE - - divRoundClosest((height() - TRIM_SQUARE_SIZE) * (value - trimMin), - trimMax - trimMin); + coord_t y = + height() - TRIM_SQUARE_SIZE - + divRoundClosest((height() - TRIM_SQUARE_SIZE) * (dispVal - trimMin), + trimMax - trimMin); drawTrimSquare(dc, 0, y, (value < TRIM_MIN || value > TRIM_MAX) ? HIGHLIGHT_COLOR /* TODO add a color */