Color overview gauges by active filament and show finish times.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Joshua King
2026-10-20 19:22:04 -04:00
co-authored by Cursor
parent 360e86e46a
commit c5b7408b18
7 changed files with 380 additions and 235 deletions
+16 -7
View File
@@ -226,6 +226,15 @@ struct Snapshot {
return progress_text + " " + finish_time + " " + time_line;
return progress_text + " " + time_line;
}
// Active tray is the spool the printer loaded most recently. Without one, keep green.
uint32_t active_filament_color() const {
for (const auto &tray : trays)
if (is_on(tray.active)) {
const uint32_t color = filament_color(tray.color);
if (color != TRACK) return color;
}
return GREEN;
}
uint32_t status_color() const {
if (!live()) return MUTED;
const auto state = lower(status);
@@ -290,7 +299,7 @@ struct Widgets {
lv_obj_t *elapsed = nullptr;
};
struct OverviewWidgets {
lv_obj_t *arc, *value, *detail;
lv_obj_t *arc, *value, *finish;
};
inline void set_text(lv_obj_t *label, const std::string &text) {
@@ -361,15 +370,15 @@ inline void render(const Snapshot &data, const Widgets &widgets) {
inline void render_overview(const Snapshot &data, const OverviewWidgets &widgets) {
const bool live = data.live();
const uint32_t color = data.status_color();
const uint32_t filament = data.active_filament_color();
const float shown = live && std::isfinite(data.progress)
? std::clamp(data.progress, 0.0f, 100.0f) : NAN;
lv_arc_set_value(widgets.arc, live ? gauge_value(data.progress, 100) : 0);
lv_obj_set_style_arc_color(widgets.arc, lv_color_hex(color), LV_PART_INDICATOR);
lv_obj_set_style_arc_color(widgets.arc, lv_color_hex(filament), LV_PART_MAIN);
lv_obj_set_style_arc_color(widgets.arc, lv_color_hex(filament), LV_PART_INDICATOR);
lv_arc_set_value(widgets.arc, 100);
set_text(widgets.value, number(shown));
lv_obj_set_style_text_color(widgets.value, lv_color_hex(live ? color : MUTED), 0);
set_text(widgets.detail, data.status_text());
lv_obj_set_style_text_color(widgets.detail, lv_color_hex(color), 0);
lv_obj_set_style_text_color(widgets.value, lv_color_hex(0xFFFFFF), 0);
set_text(widgets.finish, live && !data.finish_time.empty() ? data.finish_time : "--");
}
inline void render_fleet_summary(lv_obj_t *label, const FleetCounts &counts) {