move and settings: Update settings panel to include configurable movement speed
This allows the user to set the speed in mm/s for the move panel Completes #95
This commit is contained in:
parent
6fd25994d4
commit
d61e5983da
@ -34,6 +34,9 @@ class KlipperScreenConfig:
|
||||
{"invert_x": {"section": "main", "name": _("Invert X"), "type": "binary", "value": "False"}},
|
||||
{"invert_y": {"section": "main", "name": _("Invert Y"), "type": "binary", "value": "False"}},
|
||||
{"invert_z": {"section": "main", "name": _("Invert Z"), "type": "binary", "value": "False"}},
|
||||
{"move_speed": {"section": "main", "name": _("Move Speed (mm/s)"), "type": "scale", "value": "20",
|
||||
"range": [5,100], "step": 1
|
||||
}},
|
||||
{"print_sort_dir": {"section": "main", "type": None, "value": "name_asc"}},
|
||||
{"print_estimate_method": {"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
|
||||
"value": "file","options":[
|
||||
|
@ -125,10 +125,9 @@ class MovePanel(ScreenPanel):
|
||||
dir = "-" if dir == "+" else "+"
|
||||
|
||||
dist = str(self.distance) if dir == "+" else "-" + str(self.distance)
|
||||
logging.info("# Moving " + axis + " " + dist + "mm")
|
||||
|
||||
print("%s\n%s %s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist))
|
||||
speed = self._config.get_config()['main'].getint("move_speed", 20)
|
||||
speed = min(max(1,speed),200) # Cap movement speed between 1-200mm/s
|
||||
self._screen._ws.klippy.gcode_script(
|
||||
"%s\n%s %s%s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist,
|
||||
"%s\n%s %s%s F%s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed*60,
|
||||
"\nG90" if self._printer.get_stat("gcode_move", "absolute_coordinates") == True else "")
|
||||
)
|
||||
|
@ -159,6 +159,14 @@ class SettingsPanel(ScreenPanel):
|
||||
dropdown.set_entry_text_column(0)
|
||||
dev.add(dropdown)
|
||||
logging.debug("Children: %s" % dropdown.get_children())
|
||||
elif option['type'] == "scale":
|
||||
val = int(self._config.get_config().get(option['section'], opt_name, fallback=option['value']))
|
||||
adj = Gtk.Adjustment(val, option['range'][0], option['range'][1], option['step'], option['step']*5)
|
||||
scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
|
||||
scale.set_hexpand(True)
|
||||
scale.set_digits(0)
|
||||
scale.connect("value-changed", self.scale_moved, option['section'], opt_name)
|
||||
dev.add(scale)
|
||||
elif option['type'] == "printer":
|
||||
logging.debug("Option: %s" % option)
|
||||
box = Gtk.Box()
|
||||
@ -224,6 +232,12 @@ class SettingsPanel(ScreenPanel):
|
||||
if callback is not None:
|
||||
callback(value)
|
||||
|
||||
def scale_moved(self, widget, section, option):
|
||||
logging.debug("[%s] %s changed to %s" % (section, option, widget.get_value()))
|
||||
if section not in self._config.get_config().sections():
|
||||
self._config.get_config().add_section(section)
|
||||
self._config.set(section, option, str(int(widget.get_value())))
|
||||
self._config.save_user_config_options()
|
||||
|
||||
def switch_config_option(self, switch, gparam, section, option):
|
||||
logging.debug("[%s] %s toggled %s" % (section, option, switch.get_active()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user