mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-14 19:51:04 +00:00
23 lines
923 B
C++
23 lines
923 B
C++
#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);
|
|
} |