From c4272c52300c7790dbe7f90b6fa03001f685b76a Mon Sep 17 00:00:00 2001 From: finga Date: Mon, 27 Sep 2021 21:31:12 +0200 Subject: [PATCH] Improve `lcd_write_integer_page()` The procedure `lcd_write_integer_page()` is improved by increasing the possible values of the `comperator` variable and adding comments. --- firmware/src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firmware/src/main.c b/firmware/src/main.c index 9107b99..aa29b49 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -370,15 +370,18 @@ static void lcd_write_integer_page(const uint32_t integer, const bool invert) { if (digits != 0 || integer != 0) { uint8_t input_digits = 0; - uint16_t comperator = 1; + uint32_t comperator = 1; + // Get digits for (; comperator <= integer; comperator *= 10, input_digits++); + // Print leading zeroes for (int8_t i = digits - input_digits; i > 0; i--) { lcd_write_kerning(2, invert); lcd_write_digit_page(0, page, invert); } + // Print number itself for (; comperator >= 10; comperator /= 10) { lcd_write_kerning(2, invert); lcd_write_digit_page((integer % comperator) / (comperator / 10),