From 000836a01868a821a2519a997ad439f82ccc3286 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Thu, 15 Jul 2021 11:32:07 +0200 Subject: [PATCH] [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 */