adafruit / Adafruit_LED_Backpack

Adafruit LED Backpack Library for our various LED backpacks.
MIT License
301 stars 192 forks source link

Do not exclude '0' values from float padding #40

Closed dmadison closed 3 years ago

dmadison commented 6 years ago

Always prints the fractional digit(s) for a floating point number, if specified (>0).

caternuson commented 3 years ago

What's the issue here? Can you provide an example?

dmadison commented 3 years ago

This PR was poorly titled. It's actually about adding the relevant 0 padding after the decimal when the value is 0.

Minimal example:

matrix.printFloat(0.00, 2);
matrix.writeDisplay();
delay(1000);

matrix.printFloat(0.12345, 2);
matrix.writeDisplay();
delay(1000);

With the latest release of the library (0dd1ed9) this sets the display to:

    0
 0.12

With this change, the display is instead set to:

 0.00
 0.12

This respects the "fractional digit" setting and looks better when working with a range of floats that includes zero.

caternuson commented 3 years ago

Thanks. That helps explain it. Tested this and looks good.