|
|
|
@ -3375,15 +3375,20 @@ void lcd_display_float(float var, uint8_t size_number, uint8_t size_fraction, bo |
|
|
|
|
void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value, uint32_t max_value, uint8_t size, bool zeros, bool brackets, bool sign, bool init) |
|
|
|
|
{ |
|
|
|
|
float _v = float(value * LCD_cols) / (max_value - min_value); |
|
|
|
|
float _vi; |
|
|
|
|
float _vi = 0.0; |
|
|
|
|
uint8_t vf = uint8_t(modff(_v, &_vi) * 10.0 + 0.5); |
|
|
|
|
uint8_t vi = uint8_t(_vi); |
|
|
|
|
uint8_t vi = uint8_t(_vi + 0.5); |
|
|
|
|
|
|
|
|
|
Serial.println(value, DEC); |
|
|
|
|
Serial.println(_v, 5); |
|
|
|
|
Serial.println(vf, DEC); |
|
|
|
|
Serial.println(vi, DEC); |
|
|
|
|
|
|
|
|
|
if (init == true) |
|
|
|
|
{ |
|
|
|
|
// show initial title, value and bar
|
|
|
|
|
lcd.clear(); |
|
|
|
|
lcd.show(0, 0, LCD_cols, title); |
|
|
|
|
lcd.show(0, 0, LCD_cols - 1, title); |
|
|
|
|
lcd.setCursor(LCD_cols - (size + 1) + 1, 0); |
|
|
|
|
lcd_display_int(value, size, zeros, brackets, sign); |
|
|
|
|
lcd.setCursor(0, 1); |
|
|
|
@ -3413,7 +3418,7 @@ void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value, |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// show only changed value and changed part of the bar
|
|
|
|
|
uint8_t ca = max((float((LCD_cols) / float(max_value - min_value)) + 0.5), 1); |
|
|
|
|
uint8_t ca = float(LCD_cols - 1) / float(max_value - min_value) + 1; |
|
|
|
|
|
|
|
|
|
lcd.setCursor(LCD_cols - (size + 1) + 1, 0); |
|
|
|
|
lcd_display_int(value, size, zeros, brackets, sign); |
|
|
|
@ -3433,14 +3438,12 @@ void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value, |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
uint8_t b, e; |
|
|
|
|
|
|
|
|
|
b = max(0, vi - ca); |
|
|
|
|
e = min(LCD_cols - 1, vi + ca); |
|
|
|
|
uint8_t b = max(0, vi - ca); |
|
|
|
|
uint8_t e = min(LCD_cols - 1, vi + ca); |
|
|
|
|
|
|
|
|
|
lcd.setCursor(b, 1); |
|
|
|
|
for (uint8_t n = b; n <= e; n++) |
|
|
|
|
{ |
|
|
|
|
lcd.setCursor(n, 1); |
|
|
|
|
if (n < vi) |
|
|
|
|
lcd.write((uint8_t)4); // full block
|
|
|
|
|
else if (n == vi && uint8_t(vf / 2) != 0) |
|
|
|
|