Skip to content

Commit

Permalink
makeDetailsMask() use ceil() (p1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Feb 11, 2024
1 parent c8f9a8e commit 0b63a7e
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0b63a7e

Please sign in to comment.