mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-16 04:31:04 +00:00
bars
This commit is contained in:
23
due_obd2/bars.cpp
Normal file
23
due_obd2/bars.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user