diff --git a/Meter.c b/Meter.c index f59f9baa6..e0929cec5 100644 --- a/Meter.c +++ b/Meter.c @@ -521,24 +521,16 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre // In case of a tie, display the dot at lower position of the graph, // i.e. MSB of the "details" data. - double fraction = (rem * 8.0) - (numDots - 1.0); - assert(fraction > 0.0); - assert(fraction <= 1.0); - - double distance; - if (new->nCellsPainted > 1) { - distance = (new->nCellsPainted - new->topPoint) * 8.0 + fraction * 0.5; - } else { - distance = new->nCellsPainted * 8.0 + (fraction * 0.5 - new->topPoint * 8.0); - } - blanksAtEnd = (uint8_t)distance; + double distance = new->topPoint - (new->nCellsPainted - 1); + distance = distance - rem * 0.5; // Tiebreaking direction that may be needed in the ASCII display mode. - distance = distance - (int)distance; - assert(distance >= 0.0); - assert(distance < 1.0); - roundsUpInAscii = distance < 0.5; - roundsDownInAscii = distance > 0.5; + roundsUpInAscii = distance > 0.5; + roundsDownInAscii = distance < 0.5; + + double fraction = (uint8_t)numDots % 2 > 0 ? 0.5 : 0.0; + distance = ceil(distance * 8.0 - fraction); + blanksAtEnd = 8.0 - distance - (uint8_t)numDots / 2; } else { blanksAtEnd = 0; }