Skip to content

Commit

Permalink
makeDetailsMask() blanksAtEnd (q21a)
Browse files Browse the repository at this point in the history
  • Loading branch information
Explorer09 committed Feb 15, 2024
1 parent 88a94c7 commit 234f9bc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,13 @@ static uint16_t GraphMeterMode_makeDetailsMask(const GraphColorComputeState* pre
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);
if (8.0 - distance - (uint8_t)numDots / 2 > 0) {
blanksAtEnd = 8.0 - distance - (uint8_t)numDots / 2;
distance *= 8.0;
if ((uint8_t)numDots % 2 == 0) {
distance -= 0.5;
}
unsigned int dotPosition = (unsigned int)(int) ceil(distance) + (unsigned int)(int)numDots / 2;
if (dotPosition < 8) {
blanksAtEnd = (uint8_t)(8 - dotPosition);
} else {
blanksAtEnd = 0;
}
Expand Down

0 comments on commit 234f9bc

Please sign in to comment.