integer arithmetic is not floating point arithmetic :)

This commit is contained in:
olliw42
2021-05-23 08:21:53 +02:00
committed by Raphael Coeffic
parent 95aa02cedd
commit fbc765d0ce
+11 -10
View File
@@ -58,16 +58,17 @@ void MainView6POS::paint(BitmapBuffer * dc)
void MainViewVerticalSlider::paint(BitmapBuffer * dc) void MainViewVerticalSlider::paint(BitmapBuffer * dc)
{ {
// The ticks // The ticks
int delta = (height() - TRIM_SQUARE_SIZE) / SLIDER_TICKS_COUNT; int delta = 4;
coord_t y = TRIM_SQUARE_SIZE / 2; int sliderTicksCount = (height() - TRIM_SQUARE_SIZE) / delta;
for (uint8_t i = 0; i <= SLIDER_TICKS_COUNT; i++) { coord_t y = TRIM_SQUARE_SIZE / 2;
if (i == 0 || i == SLIDER_TICKS_COUNT / 2 || i == SLIDER_TICKS_COUNT) for (uint8_t i = 0; i <= sliderTicksCount; i++) {
dc->drawSolidHorizontalLine(2, y, 13, DEFAULT_COLOR); if (i == 0 || i == sliderTicksCount / 2 || i == sliderTicksCount)
else dc->drawSolidHorizontalLine(2, y, 13, DEFAULT_COLOR);
dc->drawSolidHorizontalLine(4, y, 9, DEFAULT_COLOR); else
y += delta; dc->drawSolidHorizontalLine(4, y, 9, DEFAULT_COLOR);
} y += delta;
}
// The square // The square
y = divRoundClosest((height() - TRIM_SQUARE_SIZE) * (-value + RESX), 2 * RESX); y = divRoundClosest((height() - TRIM_SQUARE_SIZE) * (-value + RESX), 2 * RESX);