Make UI more specific per printer type, hide settings

This commit is contained in:
suchmememanyskill
2025-01-09 22:00:53 +01:00
parent 660723d596
commit 71119e1648
8 changed files with 60 additions and 17 deletions

View File

@@ -134,7 +134,7 @@ void KlipperPrinter::parse_state(JsonDocument &in)
printer_data.print_progress = status["display_status"]["progress"];
const char *message = status["display_status"]["message"];
if (message != NULL && (printer_data.popup_message == NULL || strcmp(printer_data.popup_message, message)))
if (!global_config.disable_m117_messaging && message != NULL && (printer_data.popup_message == NULL || strcmp(printer_data.popup_message, message)))
{
printer_data.popup_message = (char *)malloc(strlen(message) + 1);
strcpy(printer_data.popup_message, message);
@@ -248,12 +248,6 @@ Macros KlipperPrinter::parse_macros(JsonDocument &in)
}
}
if (global_config.sort_macros)
{
std::sort(macros.macros, macros.macros + macros.count, [](const char *a, const char *b)
{ return strcmp(a, b) < 0; });
}
return macros;
}

View File

@@ -94,6 +94,11 @@ BasePrinter* get_printer(int idx)
return registered_printers[idx];
}
bool BasePrinter::supports_feature(PrinterFeatures feature)
{
return supported_features & feature == feature;
}
int get_current_printer_index()
{
return current_printer_index;

View File

@@ -181,6 +181,7 @@ class BasePrinter
BasePrinter(unsigned char index);
PrinterData* AnnouncePrinterData();
bool supports_feature(PrinterFeatures feature);
};
#define DATA_PRINTER_STATE 1

View File

@@ -27,6 +27,12 @@ int macros_add_macros_to_panel(lv_obj_t * root_panel, BasePrinter* printer)
return 0;
}
if (global_config.sort_macros)
{
std::sort(macros.macros, macros.macros + macros.count, [](const char *a, const char *b)
{ return strcmp(a, b) < 0; });
}
for (int i = 0; i < macros.count; i++)
{
const char* macro = macros.macros[i];

View File

@@ -79,7 +79,7 @@ void progress_panel_init(lv_obj_t* panel){
const auto button_size_mult = 1.3f;
// Emergency Stop
if (global_config.show_estop){
if (global_config.show_estop && (get_current_printer()->supports_feature(PrinterFeatureEmergencyStop))){
lv_obj_t * btn = lv_btn_create(panel);
lv_obj_add_event_cb(btn, btn_click_estop, LV_EVENT_CLICKED, NULL);

View File

@@ -189,11 +189,23 @@ void settings_section_theming(lv_obj_t* panel)
void settings_section_behaviour(lv_obj_t* panel)
{
PrinterType printer_type = get_current_printer()->printer_config->printer_type;
bool is_klipper = printer_type == PrinterTypeKlipper || printer_type == PrinterTypeKlipperSerial;
bool is_octo = printer_type == PrinterTypeOctoprint;
bool is_bambu = printer_type == PrinterTypeBambuLocal;
lv_obj_t * label = lv_label_create(panel);
lv_label_set_text(label, "\nBehaviour");
lv_create_custom_menu_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer()->printer_config->remaining_time_calc_mode, NULL, PRINTER_SPECIFIC_SETTING);
lv_create_custom_menu_dropdown("Stats in Progress Screen", panel, show_stats_on_progress_panel_dropdown, "None\nLayers\nPartial\nAll", get_current_printer()->printer_config->show_stats_on_progress_panel, NULL, PRINTER_SPECIFIC_SETTING);
if (is_klipper)
{
lv_create_custom_menu_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer()->printer_config->remaining_time_calc_mode, NULL, PRINTER_SPECIFIC_SETTING);
lv_create_custom_menu_dropdown("Stats in Progress Screen", panel, show_stats_on_progress_panel_dropdown, "None\nLayers\nPartial\nAll", get_current_printer()->printer_config->show_stats_on_progress_panel, NULL, PRINTER_SPECIFIC_SETTING);
}
else if (is_bambu)
{
lv_create_custom_menu_dropdown("Stats in Progress Screen", panel, show_stats_on_progress_panel_dropdown, "None\nLayers", get_current_printer()->printer_config->show_stats_on_progress_panel, NULL, PRINTER_SPECIFIC_SETTING);
}
#ifndef CYD_SCREEN_DISABLE_TIMEOUT
int wake_timeout_settings_index = 0;
@@ -212,17 +224,22 @@ void settings_section_behaviour(lv_obj_t* panel)
#endif
lv_create_custom_menu_switch("Multi Printer Mode", panel, multi_printer_switch, global_config.multi_printer_mode);
lv_create_custom_menu_switch("Disable M117 Messaging", panel, disable_m117_messaging_switch, global_config.disable_m117_messaging);
lv_create_custom_menu_button("Configure Printer IP", panel, reset_ip_click, "Restart");
if (is_klipper)
{
lv_create_custom_menu_switch("Disable M117 Messaging", panel, disable_m117_messaging_switch, global_config.disable_m117_messaging);
lv_create_custom_menu_switch("Custom Filament Move Macros", panel, filament_move_mode_switch, get_current_printer()->printer_config->custom_filament_move_macros, NULL,
global_config.multi_printer_mode
? "Calls FILAMENT_RETRACT and\nFILAMENT_EXTRUDE in temperature menu\nwhen enabled. Stored per printer."
: "Calls FILAMENT_RETRACT and\nFILAMENT_EXTRUDE in temperature menu\nwhen enabled");
lv_create_custom_menu_switch("Custom Filament Move Macros", panel, filament_move_mode_switch, get_current_printer()->printer_config->custom_filament_move_macros, NULL,
global_config.multi_printer_mode
? "Calls FILAMENT_RETRACT and\nFILAMENT_EXTRUDE in temperature menu\nwhen enabled. Stored per printer."
: "Calls FILAMENT_RETRACT and\nFILAMENT_EXTRUDE in temperature menu\nwhen enabled");
lv_create_custom_menu_switch("Show Emergency Stop", panel, show_estop_switch, global_config.show_estop);
}
lv_create_custom_menu_switch("Sort Macros A->Z", panel, sort_macros_switch, global_config.sort_macros);
lv_create_custom_menu_switch("Show Emergency Stop", panel, show_estop_switch, global_config.show_estop);
lv_create_custom_menu_switch("Show Full Filenames", panel, full_filenames_switch, global_config.full_filenames);
lv_create_custom_menu_button("Configure Printer Host", panel, reset_ip_click, "Restart");
}
void settings_section_device(lv_obj_t* panel)

6
test_printer/config.json Normal file
View File

@@ -0,0 +1,6 @@
{
"instancesDB": "json",
"instances": [
{ "hostname": "localhost", "port": 7125 }
]
}

View File

@@ -0,0 +1,14 @@
services:
printer:
container_name: printer
ports:
- "7125:7125"
- "8110:8110"
image: ghcr.io/mainsail-crew/virtual-klipper-printer:master
webui:
container_name: mainsail
volumes:
- ./config.json:/usr/share/nginx/html/config.json:ro
ports:
- 6969:80
image: ghcr.io/mainsail-crew/mainsail