Skip to content

Commit

Permalink
Make UI more specific per printer type, hide settings
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Jan 9, 2025
1 parent 660723d commit 71119e1
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 17 deletions.
8 changes: 1 addition & 7 deletions CYD-Klipper/src/core/klipper/klipper_printer_parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions CYD-Klipper/src/core/printer_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions CYD-Klipper/src/core/printer_integration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class BasePrinter

BasePrinter(unsigned char index);
PrinterData* AnnouncePrinterData();
bool supports_feature(PrinterFeatures feature);
};

#define DATA_PRINTER_STATE 1
Expand Down
6 changes: 6 additions & 0 deletions CYD-Klipper/src/ui/macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion CYD-Klipper/src/ui/panels/progress_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
35 changes: 26 additions & 9 deletions CYD-Klipper/src/ui/panels/settings_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions test_printer/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"instancesDB": "json",
"instances": [
{ "hostname": "localhost", "port": 7125 }
]
}
14 changes: 14 additions & 0 deletions test_printer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 71119e1

Please sign in to comment.