This commit is contained in:
Sem van der Hoeven
2024-11-12 00:14:45 +01:00
parent ac2c2d6643
commit cf24296f63
6 changed files with 168 additions and 40 deletions

23
due_obd2/bars.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "bars.h"
void draw_bar_horizontal(int start_x, int start_y, int width, int height, int value, int max_value, uint color, char fill_outline, UTFT *display)
{
display->setColor(color);
int bar_width = (int)((float)value / (float)max_value * width);
if (fill_outline)
{
display->drawRect(start_x, start_y, start_x + width, start_y + height);
}
display->fillRect(start_x, start_y, start_x + bar_width, start_y + height);
}
void draw_bar_vertical(int start_x, int start_y, int width, int height, int value, int max_value, uint color, char fill_outline, UTFT *display)
{
display->setColor(color);
int bar_height = (int)((float)value / (float)max_value * height);
if (fill_outline)
{
display->drawRect(start_x, start_y, start_x + width, start_y + height);
}
display->fillRect(start_x, (start_y + height) - bar_height, start_x + width, start_y + height);
}