Use only first 3 digits of display

This commit is contained in:
nedko 2024-05-18 14:44:56 +03:00
parent d504ace44a
commit 8b2c36a260

View File

@ -5,8 +5,8 @@
#include <stdint.h> #include <stdint.h>
#define VALUE_MIN -99999 #define VALUE_MIN -99
#define VALUE_MAX 999999 #define VALUE_MAX 999
#define PIN_BTN_DEC PINB3 #define PIN_BTN_DEC PINB3
#define PIN_BTN_INC PINB4 #define PIN_BTN_INC PINB4
@ -237,10 +237,9 @@ void display_show_value(uint8_t dots)
for (i = 0; i < DISPLAY_SIZE; ++i) for (i = 0; i < DISPLAY_SIZE; ++i)
{ {
display_buffer[i] = 0; display_buffer[i] = 0;
div_val *= 10;
} }
div_val /= 10; div_val = 100;
if (counter_value < 0) if (counter_value < 0)
{ {
@ -255,8 +254,13 @@ void display_show_value(uint8_t dots)
txt = 0; txt = 0;
for (i = 0; i < DISPLAY_SIZE; ++i) for (i = 0; i < DISPLAY_SIZE; ++i)
{ {
if (div_val == 0)
{
break;
}
digit = counter_copy / div_val; digit = counter_copy / div_val;
if ((0 != txt) || (0 != digit) || (DISPLAY_SIZE - 1 == i)) if ((0 != txt) || (0 != digit) || (div_val == 1))
{ {
txt = 1; txt = 1;
display_buffer[i] = seg_table[digit]; display_buffer[i] = seg_table[digit];