diff --git a/config/main_menu.conf b/config/main_menu.conf index ec599d39..ad9a637d 100644 --- a/config/main_menu.conf +++ b/config/main_menu.conf @@ -106,6 +106,11 @@ name: {{ gettext('More') }} icon: more-settings panel: settings +[menu __main more advanced] +name: {{ gettext('Advanced') }} +icon: advanced_setting +panel: advanced + [menu __main more network] name: {{ gettext('Network') }} icon: network diff --git a/ks_includes/KlippyGcodes.py b/ks_includes/KlippyGcodes.py index b66bcc06..98f22cc7 100644 --- a/ks_includes/KlippyGcodes.py +++ b/ks_includes/KlippyGcodes.py @@ -47,3 +47,9 @@ class KlippyGcodes: f'RED={color[0]} GREEN={color[1]} BLUE={color[2]} WHITE={color[3]} ' f'SYNC=0 TRANSMIT=1' ) + + @staticmethod + def set_save_variables(name, value): + if isinstance(value, str): + value = f"'{value}'" + return f'SAVE_VARIABLE VARIABLE={name} VALUE=\"{value}\"' diff --git a/ks_includes/widgets/keyboard.py b/ks_includes/widgets/keyboard.py index e9b72cf2..0e1f1428 100644 --- a/ks_includes/widgets/keyboard.py +++ b/ks_includes/widgets/keyboard.py @@ -93,14 +93,14 @@ class Keyboard(Gtk.Box): ], [ ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"], - ["@", "#", "$", "_", "&", "-", "+", "(", ")", "/"], - ["↑", "*", '"', "'", ":", ";", "!", "?", "Ç", "⌫"], + [".", "#", "$", "_", "&", "-", "+", "(", ")", "/"], + ["↑", "*", '"', "@", ":", ";", "!", "?", "Ç", "⌫"], ["abc", " ", "↓"], ], [ ["[", "]", "{", "}", "#", "%", "^", "*", "+", "="], ["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "•"], - ["↑", ".", ",", "?", "!", "'", "º", "ç", "abc", "⌫"], + ["↑", "'", ",", "?", "!", "'", "º", "ç", "abc", "⌫"], ["ABC", " ", "↓"], ] ] diff --git a/panels/advanced.py b/panels/advanced.py new file mode 100644 index 00000000..903a9c02 --- /dev/null +++ b/panels/advanced.py @@ -0,0 +1,54 @@ +import logging +import gi + +gi.require_version("Gtk", "3.0") +from gi.repository import Gtk +from ks_includes.KlippyGcodes import KlippyGcodes +from ks_includes.screen_panel import ScreenPanel + +class Panel(ScreenPanel): + def __init__(self, screen, title): + title = title or _("Advanced") + super().__init__(screen, title) + self.advanced = {} + self.menu_list ={} + self.advanced_options = [ + {"adaptive_leveling": {"section": "main", "name": _("Adaptive Bed Leveling"), "type": "binary", + "tooltip": _("Leveling Only in the Actual Print Area"), + "value": "True", "callback": self.set_adaptive_leveling}}, + {"power_loss_recovery": {"section": "main", "name": _("Power Loss Recovery"), "type": "binary", + "tooltip": _("Restores your print job after a power outage"), + "value": "True", "callback": self.set_power_loss_recovery}}, + ] + options = self.advanced_options + self.labels['advanced_menu'] = self._gtk.ScrolledWindow() + self.labels['advanced'] = Gtk.Grid() + self.labels['advanced_menu'].add(self.labels['advanced']) + for option in options: + name = list(option)[0] + res = self.add_option('advanced', self.advanced, name, option[name]) + self.menu_list.update(res) + self.content.add(self.labels['advanced_menu']) + + def set_adaptive_leveling(self, *args): + self.set_configuration_feature("adaptive_meshing", *args) + + def set_power_loss_recovery(self, *args): + self.set_configuration_feature("power_loss_recovery", *args) + + def set_configuration_feature(self, feature_name, *args): + enable_feature = any(args) + script_value = True if enable_feature else False + script = KlippyGcodes.set_save_variables(feature_name, script_value) + self._screen._send_action(None, "printer.gcode.script", {"script": script}) + logging.info(f"Set {feature_name}: {script_value}") + + def process_update(self, action, data): + if action != "notify_status_update": + return + if 'save_variables' in data and 'variables' in data['save_variables']: + variables = data['save_variables']['variables'] + if 'adaptive_meshing' in variables: + self.menu_list['adaptive_leveling'].set_active(variables['adaptive_meshing']) + if 'power_loss_recovery' in variables: + self.menu_list['power_loss_recovery'].set_active(variables['power_loss_recovery']) diff --git a/panels/extrude.py b/panels/extrude.py index 20c6d14c..f4cec2ac 100644 --- a/panels/extrude.py +++ b/panels/extrude.py @@ -247,6 +247,9 @@ class Panel(ScreenPanel): def change_extruder(self, widget, extruder): logging.info(f"Changing extruder to {extruder}") + if self.labels[extruder].get_style_context().has_class("button_active"): + self.menu_item_clicked(None, {"panel": "numpad", 'extra': f"{extruder}"}) + return for tool in self._printer.get_tools(): self.labels[tool].get_style_context().remove_class("button_active") self.labels[extruder].get_style_context().add_class("button_active") diff --git a/panels/fine_tune.py b/panels/fine_tune.py index 52485663..61a7e8d8 100644 --- a/panels/fine_tune.py +++ b/panels/fine_tune.py @@ -13,7 +13,7 @@ class Panel(ScreenPanel): z_delta = z_deltas[-1] speed_deltas = ['5', '25'] s_delta = speed_deltas[-1] - extrude_deltas = ['1', '2'] + extrude_deltas = ['1', '2', '10', '50'] e_delta = extrude_deltas[-1] speed = extrusion = 100 z_offset = 0.0 diff --git a/screen.py b/screen.py index 2f92113a..7e1ce1a4 100755 --- a/screen.py +++ b/screen.py @@ -273,6 +273,7 @@ class KlipperScreen(Gtk.Window): "exclude_object": ["current_object", "objects", "excluded_objects"], "manual_probe": ['is_active'], "screws_tilt_adjust": ['results', 'error'], + "save_variables": ['variables'], } } for extruder in self.printer.get_tools(): @@ -1072,6 +1073,7 @@ class KlipperScreen(Gtk.Window): 'firmware_retraction', 'exclude_object', 'manual_probe', + 'save_variables', *self.printer.get_tools(), *self.printer.get_heaters(), *self.printer.get_temp_sensors(), diff --git a/styles/dark/images/advanced_setting.svg b/styles/dark/images/advanced_setting.svg new file mode 100644 index 00000000..9eba0be0 --- /dev/null +++ b/styles/dark/images/advanced_setting.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/styles/light/images/advanced_setting.svg b/styles/light/images/advanced_setting.svg new file mode 100644 index 00000000..534e46d4 --- /dev/null +++ b/styles/light/images/advanced_setting.svg @@ -0,0 +1,9 @@ + + + + + + + + +