Color overview gauges by active filament and show finish times.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -246,13 +246,13 @@ def snapshot_lines(printer, expressions, trays):
|
||||
|
||||
|
||||
def overview_slots(count):
|
||||
"""Place one steam gauge per printer. Full-size arcs match the printer pages."""
|
||||
"""Place one steam gauge per printer under the page title."""
|
||||
columns = 4 if count > 4 else max(count, 1)
|
||||
rows = (count + columns - 1) // columns
|
||||
top, bottom = 8, 400
|
||||
arc = min(154, (800 // columns) - 20, (bottom - top) // rows - 36)
|
||||
col_w = 800 // columns
|
||||
top, bottom = 46, 432
|
||||
row_h = (bottom - top) // rows
|
||||
arc = min(154, (800 // columns) - 24, row_h - 48)
|
||||
col_w = 800 // columns
|
||||
slots = []
|
||||
for index in range(count):
|
||||
row, col = divmod(index, columns)
|
||||
@@ -267,34 +267,36 @@ def overview_slots(count):
|
||||
def overview_gauge(printer, x, y, arc):
|
||||
pid = printer['id']
|
||||
scale = arc / 154
|
||||
value_font = 32 if arc >= 140 else 18
|
||||
detail_font = 14 if arc >= 140 else 12
|
||||
name_font = 14 if arc >= 140 else 12
|
||||
value_font = 32 if arc >= 130 else 18
|
||||
open_page = [{'lvgl.page.show': f'{pid}_page'}]
|
||||
inner = max(8, int(round(13 * scale)))
|
||||
inner = max(10, int(round(13 * scale)))
|
||||
inner_x = x + int(round(8 * scale))
|
||||
number_y = y + int(round(arc * 0.30))
|
||||
return [
|
||||
{'arc': {'id': f'{pid}_overview_arc', 'x': x + int(round(8 * scale)), 'y': y,
|
||||
'width': arc, 'height': arc, 'min_value': 0, 'max_value': 100, 'value': 0,
|
||||
'start_angle': 135, 'end_angle': 45, 'arc_width': inner, 'arc_color': TRACK,
|
||||
{'arc': {'id': f'{pid}_overview_arc', 'x': inner_x, 'y': y,
|
||||
'width': arc, 'height': arc, 'min_value': 0, 'max_value': 100, 'value': 100,
|
||||
'start_angle': 135, 'end_angle': 45, 'arc_width': inner, 'arc_color': GREEN,
|
||||
'indicator': {'arc_color': GREEN, 'arc_width': inner}, 'adjustable': False,
|
||||
'gesture_bubble': True, 'clickable': True, 'on_click': open_page}},
|
||||
label('--', x + int(round(14 * scale)), y + int(round(47 * scale)), int(round(142 * scale)),
|
||||
value_font, id=f'{pid}_overview_value', text_align='CENTER',
|
||||
label('--', inner_x, number_y, arc, value_font, id=f'{pid}_overview_value',
|
||||
text_align='CENTER', text_color=0xFFFFFF, clickable=True, on_click=open_page),
|
||||
label('%', inner_x, number_y + (34 if value_font >= 28 else 20), arc, 16,
|
||||
id=f'{pid}_overview_percent', text_align='CENTER', text_color=0xFFFFFF,
|
||||
clickable=True, on_click=open_page),
|
||||
label('SYNCING', x + int(round(14 * scale)), y + int(round(86 * scale)),
|
||||
int(round(142 * scale)), detail_font, id=f'{pid}_overview_detail',
|
||||
text_align='CENTER', text_color=MUTED, clickable=True, on_click=open_page),
|
||||
label(printer['name'], x, y + int(round(137 * scale)), arc + 16, name_font,
|
||||
text_align='CENTER', text_color=GREEN, clickable=True, on_click=open_page),
|
||||
label(printer['name'], x, y + arc + 2, arc + 16, 14, text_align='CENTER',
|
||||
text_color=TEXT_COLOR, clickable=True, on_click=open_page),
|
||||
label('--', x, y + arc + 22, arc + 16, 14, id=f'{pid}_overview_finish',
|
||||
text_align='CENTER', text_color=TEXT_COLOR, clickable=True, on_click=open_page),
|
||||
]
|
||||
|
||||
|
||||
def overview_page(printers):
|
||||
widgets = []
|
||||
widgets = [
|
||||
label('Print Status Overview', 16, 10, 520, 22, text_color=GREEN),
|
||||
label('--:--', 548, 12, 236, 18, id='fleet_clock', text_align='RIGHT', text_color=TEXT_COLOR),
|
||||
]
|
||||
for printer, (x, y, arc) in zip(printers, overview_slots(len(printers))):
|
||||
widgets += overview_gauge(printer, x, y, arc)
|
||||
widgets.append(label('SYNCING', 90, 404, 620, 14, id='fleet_summary',
|
||||
text_align='CENTER', text_color=MUTED))
|
||||
for direction, x, text in (('previous', 16, '<'), ('next', 720, '>')):
|
||||
widgets.append({'button': {'x': x, 'y': 446, 'width': 64, 'height': 30,
|
||||
'bg_color': TRACK, 'radius': 8, 'border_width': 0,
|
||||
@@ -316,16 +318,25 @@ def overview_page(printers):
|
||||
|
||||
|
||||
def fleet_refresh_lines(snapshots):
|
||||
lines = ['bambu_display::FleetCounts counts;']
|
||||
lines = []
|
||||
for pid, snapshot in snapshots:
|
||||
lines.append('{')
|
||||
lines.extend(snapshot)
|
||||
lines.append('bambu_display::tally(counts, data);')
|
||||
lines.append('bambu_display::render_overview(data, {' + ', '.join([
|
||||
f'id({pid}_overview_arc)', f'id({pid}_overview_value)',
|
||||
f'id({pid}_overview_detail)']) + '});')
|
||||
f'id({pid}_overview_finish)']) + '});')
|
||||
lines.append('}')
|
||||
lines.append('bambu_display::render_fleet_summary(id(fleet_summary), counts);')
|
||||
lines += [
|
||||
'{',
|
||||
'const auto clock = id(ha_time).now();',
|
||||
'std::string clock_text = "--:--";',
|
||||
'if (clock.is_valid()) {',
|
||||
' clock_text = clock.strftime("%I:%M %p");',
|
||||
' if (!clock_text.empty() && clock_text[0] == \'0\') clock_text.erase(0, 1);',
|
||||
'}',
|
||||
'bambu_display::set_text(id(fleet_clock), clock_text);',
|
||||
'}',
|
||||
]
|
||||
return lines
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user