Add Elegoo printers to ESPHome fleet display
This commit is contained in:
@@ -22,11 +22,12 @@ def main():
|
||||
demo_values = {'progress': 67, 'nozzle': 218, 'nozzle_target': 220, 'bed': 60,
|
||||
'bed_target': 60, 'time_left': 1.75, 'layer': 134, 'total_layers': 200,
|
||||
'fan': 80, 'aux_fan': 45, 'exhaust_fan': 30, 'left_nozzle': 219, 'left_target': 220,
|
||||
'right_nozzle': 37, 'right_target': 0}
|
||||
'right_nozzle': 37, 'right_target': 0, 'uv': 42, 'elapsed': 30}
|
||||
demo_text = {'status': 'running', 'task': 'Workshop organizer - plate 2',
|
||||
'stage': 'printing', 'online': 'on', 'print_error': 'off', 'hms_error': 'off',
|
||||
'hms_count': '0', 'print_error_message': '', 'print_error_code': '',
|
||||
'remaining_unit': 'h', 'nozzle_unit': '°C', 'bed_unit': '°C'}
|
||||
'remaining_unit': 'h', 'nozzle_unit': '°C', 'bed_unit': '°C',
|
||||
'uv_unit': '°C', 'elapsed_unit': 'min', 'print_error_reason': 'ok'}
|
||||
colors = ['#60DE9AFF', '#F4C96BFF', '#74A9E8FF', '#F8F4ECFF',
|
||||
'#DF8BBFFF', '#FA936BFF', '#8E79CAFF', '#4CC9C1FF']
|
||||
for printer in printers:
|
||||
@@ -38,6 +39,8 @@ def main():
|
||||
key = entry['id'][len(prefix):]
|
||||
if section == 'sensor':
|
||||
value = str(demo_values[key])
|
||||
if key == 'time_left' and printer.get('profile', '').startswith('elegoo_'):
|
||||
value = '105'
|
||||
else:
|
||||
if key.startswith('tray_'):
|
||||
_, index, attribute = key.split('_')
|
||||
@@ -47,6 +50,9 @@ def main():
|
||||
text = ''
|
||||
else:
|
||||
text = demo_text[key]
|
||||
if printer.get('profile', '').startswith('elegoo_'):
|
||||
text = {'status': 'printing', 'print_error': 'none',
|
||||
'remaining_unit': 'min'}.get(key, text)
|
||||
value = 'std::string(' + json.dumps(text, ensure_ascii=False) + ')'
|
||||
entry.clear()
|
||||
entry.update({'platform': 'template', 'id': prefix + key, 'internal': True,
|
||||
@@ -86,6 +92,25 @@ inline void setup() {
|
||||
steps += [{'lvgl.page.show': printer['id'] + '_page'},
|
||||
{'script.execute': printer['id'] + '_refresh'}, {'delay': '300ms'},
|
||||
{'snapshot.take': {'id': 'panel_display', 'filename': printer['id'] + '.bmp'}}]
|
||||
if printer.get('profile', '').startswith('elegoo_'):
|
||||
pid = printer['id']
|
||||
checks = {f'{pid}_status_label': 'PRINTING', f'{pid}_progress_detail': '1h 45m'}
|
||||
if printer['profile'] == 'elegoo_resin':
|
||||
checks.update({f'{pid}_uv_label': '42', f'{pid}_layer_label': '134',
|
||||
f'{pid}_elapsed_label': 'Elapsed: 0h 30m'})
|
||||
for widget, expected in checks.items():
|
||||
steps.append({'lambda': Lambda(f'if (std::string(lv_label_get_text(id({widget}))) != {json.dumps(expected)}) {{ ESP_LOGE("preview", "Elegoo telemetry render failed: {widget}"); exit(4); }}')})
|
||||
steps += [
|
||||
{'text_sensor.template.publish': {'id': f'{pid}_print_error_reason', 'state': 'filament_runout'}},
|
||||
{'script.execute': f'{pid}_refresh'},
|
||||
{'lambda': Lambda(f'if (std::string(lv_label_get_text(id({pid}_status_label))) != "PRINT ERROR" || std::string(lv_label_get_text(id({pid}_health_details))).find("Filament runout") == std::string::npos) {{ ESP_LOGE("preview", "Elegoo error render failed"); exit(5); }}')},
|
||||
{'text_sensor.template.publish': {'id': f'{pid}_online', 'state': 'off'}},
|
||||
{'script.execute': f'{pid}_refresh'},
|
||||
{'lambda': Lambda(f'if (std::string(lv_label_get_text(id({pid}_status_label))) != "PRINTER OFFLINE" || std::string(lv_label_get_text(id({pid}_progress_label))) != "--") {{ ESP_LOGE("preview", "Elegoo offline render failed"); exit(6); }}')},
|
||||
{'text_sensor.template.publish': {'id': f'{pid}_print_error_reason', 'state': 'ok'}},
|
||||
{'text_sensor.template.publish': {'id': f'{pid}_online', 'state': 'on'}},
|
||||
{'script.execute': f'{pid}_refresh'},
|
||||
]
|
||||
steps += [{'lvgl.page.show': 'color_test_page'}, {'delay': '300ms'},
|
||||
{'snapshot.take': {'id': 'panel_display', 'filename': 'color_test.bmp'}}]
|
||||
demo_printer = printers[0]['id']
|
||||
@@ -147,6 +172,7 @@ inline void setup() {
|
||||
print(f'Saved {len(printers)} demo screenshots to {args.output}')
|
||||
print('Passed LVGL pointer swipe tests, including wraparound and button gesture consumption.')
|
||||
print('Passed status-tap health panel open and Close-button tests.')
|
||||
print('Passed Elegoo telemetry, text-error and offline rendering checks.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user