mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-15 05:47:38 +00:00
Center temperature graph in view.
This commit is contained in:
@@ -64,15 +64,17 @@ void TemperatureWidget::paint(Painter& painter) {
|
|||||||
|
|
||||||
const auto rect = screen_rect();
|
const auto rect = screen_rect();
|
||||||
|
|
||||||
|
const Dim bar_width = 1;
|
||||||
|
const Dim margin_x = (rect.width() - (logger.capacity() * bar_width)) / 2;
|
||||||
|
const Coord rightmost_x = rect.right() - margin_x;
|
||||||
|
|
||||||
const auto history = logger.history();
|
const auto history = logger.history();
|
||||||
for(size_t i=0; i<history.size(); i++) {
|
for(size_t i=0; i<history.size(); i++) {
|
||||||
const auto sample = history[i];
|
const auto sample = history[i];
|
||||||
const Dim bar_height = sample * 4;
|
const Dim bar_height = sample * 4;
|
||||||
const Rect bar_rect {
|
const Coord x = rightmost_x - (history.size() - i) * bar_width;
|
||||||
static_cast<Coord>(rect.right() - (history.size() - i) * 1),
|
const Coord y = rect.bottom() - bar_height;
|
||||||
static_cast<Coord>(rect.bottom() - bar_height),
|
const Rect bar_rect { x, y, bar_width, bar_height };
|
||||||
1, bar_height
|
|
||||||
};
|
|
||||||
painter.fill_rectangle(bar_rect, Color::green());
|
painter.fill_rectangle(bar_rect, Color::green());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user