limits: change to minimum cruise ratio
This commit is contained in:
parent
e62b0ac4ad
commit
b7cbbee4d1
@ -17,20 +17,34 @@ class Panel(ScreenPanel):
|
|||||||
|
|
||||||
conf = self._printer.get_config_section("printer")
|
conf = self._printer.get_config_section("printer")
|
||||||
self.options = [
|
self.options = [
|
||||||
{"name": _("Max Acceleration"), "units": _("mm/s²"), "option": "max_accel",
|
{
|
||||||
"max": int(float(conf['max_accel']))},
|
"name": _("Max Acceleration"),
|
||||||
{"name": _("Max Acceleration to Deceleration"), "units": _("mm/s²"), "option": "max_accel_to_decel",
|
"option": "max_accel",
|
||||||
"max": int(float(conf['max_accel_to_decel'])) if "max_accel_to_decel" in conf
|
"units": _("mm/s²"),
|
||||||
else int(float(conf['max_accel']) / 2)},
|
"value": int(float(conf['max_accel']))
|
||||||
{"name": _("Max Velocity"), "units": _("mm/s"), "option": "max_velocity",
|
},
|
||||||
"max": int(float(conf["max_velocity"]))},
|
{
|
||||||
{"name": _("Square Corner Velocity"), "units": _("mm/s"), "option": "square_corner_velocity",
|
"name": _("Minimum Cruise Ratio"),
|
||||||
"max": int(float(conf['square_corner_velocity'])) if "square_corner_velocity" in conf
|
"option": "minimum_cruise_ratio",
|
||||||
else 5}
|
"units": "%",
|
||||||
|
"value": int(float(conf['minimum_cruise_ratio']) * 100),
|
||||||
|
"max": 99
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": _("Max Velocity"),
|
||||||
|
"option": "max_velocity",
|
||||||
|
"units": _("mm/s"),
|
||||||
|
"value": int(float(conf["max_velocity"]))},
|
||||||
|
{
|
||||||
|
"name": _("Square Corner Velocity"),
|
||||||
|
"option": "square_corner_velocity",
|
||||||
|
"units": _("mm/s"),
|
||||||
|
"value": int(float(conf['square_corner_velocity'])) if "square_corner_velocity" in conf else 5
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
for opt in self.options:
|
for opt in self.options:
|
||||||
self.add_option(opt['option'], opt['name'], opt['units'], opt['max'])
|
self.add_option(opt)
|
||||||
|
|
||||||
scroll = self._gtk.ScrolledWindow()
|
scroll = self._gtk.ScrolledWindow()
|
||||||
scroll.add(self.grid)
|
scroll.add(self.grid)
|
||||||
@ -46,43 +60,48 @@ class Panel(ScreenPanel):
|
|||||||
self.update_option(opt, data["toolhead"][opt])
|
self.update_option(opt, data["toolhead"][opt])
|
||||||
|
|
||||||
def update_option(self, option, value):
|
def update_option(self, option, value):
|
||||||
|
logging.info(f"{option} {value}")
|
||||||
|
|
||||||
if option not in self.limits:
|
if option not in self.limits:
|
||||||
|
logging.debug("not in self limits")
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.limits[option]['scale'].has_grab():
|
if self.limits[option]['scale'].has_grab():
|
||||||
return
|
return
|
||||||
|
if option == "minimum_cruise_ratio" and value < 1:
|
||||||
self.values[option] = int(value)
|
self.values[option] = int(value * 100)
|
||||||
|
else:
|
||||||
|
self.values[option] = int(value)
|
||||||
self.limits[option]['scale'].disconnect_by_func(self.set_opt_value)
|
self.limits[option]['scale'].disconnect_by_func(self.set_opt_value)
|
||||||
self.limits[option]['scale'].set_value(self.values[option])
|
self.limits[option]['scale'].set_value(self.values[option])
|
||||||
for opt in self.options:
|
for opt in self.options:
|
||||||
if opt["option"] == option:
|
if opt["option"] == option and 'max' not in opt:
|
||||||
if self.values[option] > opt["max"]:
|
if self.values[option] > opt["value"]:
|
||||||
self.limits[option]['scale'].get_style_context().add_class("option_slider_max")
|
self.limits[option]['scale'].get_style_context().add_class("option_slider_max")
|
||||||
# Infinite scale
|
# Infinite scale
|
||||||
self.limits[option]['adjustment'].set_upper(self.values[option] * 1.5)
|
self.limits[option]['adjustment'].set_upper(self.values[option] * 1.5)
|
||||||
else:
|
else:
|
||||||
self.limits[option]['scale'].get_style_context().remove_class("option_slider_max")
|
self.limits[option]['scale'].get_style_context().remove_class("option_slider_max")
|
||||||
self.limits[option]['adjustment'].set_upper(opt["max"] * 1.5)
|
self.limits[option]['adjustment'].set_upper(opt["value"] * 1.5)
|
||||||
self.limits[option]['scale'].connect("button-release-event", self.set_opt_value, option)
|
self.limits[option]['scale'].connect("button-release-event", self.set_opt_value, option)
|
||||||
|
|
||||||
def add_option(self, option, optname, units, value):
|
def add_option(self, option):
|
||||||
logging.info(f"Adding option: {option}")
|
logging.info(f"Adding option: {option['option']}")
|
||||||
|
|
||||||
name = Gtk.Label(hexpand=True, vexpand=True, halign=Gtk.Align.START, valign=Gtk.Align.CENTER,
|
name = Gtk.Label(hexpand=True, vexpand=True, halign=Gtk.Align.START, valign=Gtk.Align.CENTER,
|
||||||
wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR)
|
wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR)
|
||||||
name.set_markup(f"<big><b>{optname}</b></big> ({units})")
|
name.set_markup(f"<big><b>{option['name']}</b></big> ({option['units']})")
|
||||||
|
|
||||||
# adj (value, lower, upper, step_increment, page_increment, page_size)
|
# adj (value, lower, upper, step_increment, page_increment, page_size)
|
||||||
adj = Gtk.Adjustment(value, 1, (value * 1.5), 1, 5, 0)
|
max_value = option['max'] if 'max' in option else option['value'] * 1.5
|
||||||
scale = Gtk.Scale(adjustment=adj,
|
adj = Gtk.Adjustment(option['value'], 1, max_value, 1, 5, 0)
|
||||||
digits=0, hexpand=True, has_origin=True)
|
scale = Gtk.Scale(adjustment=adj, digits=0, hexpand=True, has_origin=True)
|
||||||
scale.get_style_context().add_class("option_slider")
|
scale.get_style_context().add_class("option_slider")
|
||||||
scale.connect("button-release-event", self.set_opt_value, option)
|
scale.connect("button-release-event", self.set_opt_value, option)
|
||||||
self.values[option] = value
|
self.values[option['option']] = option['value']
|
||||||
|
|
||||||
reset = self._gtk.Button("refresh", style="color1")
|
reset = self._gtk.Button("refresh", style="color1")
|
||||||
reset.connect("clicked", self.reset_value, option)
|
reset.connect("clicked", self.reset_value, option['option'])
|
||||||
reset.set_hexpand(False)
|
reset.set_hexpand(False)
|
||||||
|
|
||||||
item = Gtk.Grid()
|
item = Gtk.Grid()
|
||||||
@ -90,23 +109,24 @@ class Panel(ScreenPanel):
|
|||||||
item.attach(scale, 0, 1, 1, 1)
|
item.attach(scale, 0, 1, 1, 1)
|
||||||
item.attach(reset, 1, 1, 1, 1)
|
item.attach(reset, 1, 1, 1, 1)
|
||||||
|
|
||||||
self.limits[option] = {
|
self.limits[option['option']] = {
|
||||||
"row": item,
|
"row": item,
|
||||||
"scale": scale,
|
"scale": scale,
|
||||||
"adjustment": adj,
|
"adjustment": adj,
|
||||||
}
|
}
|
||||||
|
|
||||||
limits = sorted(self.limits)
|
limits = sorted(self.limits)
|
||||||
pos = limits.index(option)
|
pos = limits.index(option['option'])
|
||||||
|
|
||||||
self.grid.insert_row(pos)
|
self.grid.insert_row(pos)
|
||||||
self.grid.attach(self.limits[option]['row'], 0, pos, 1, 1)
|
self.grid.attach(self.limits[option['option']]['row'], 0, pos, 1, 1)
|
||||||
self.grid.show_all()
|
self.grid.show_all()
|
||||||
|
|
||||||
def reset_value(self, widget, option):
|
def reset_value(self, widget, option):
|
||||||
for x in self.options:
|
for x in self.options:
|
||||||
if x["option"] == option:
|
if x["option"] == option:
|
||||||
self.update_option(option, x["max"])
|
self.update_option(option, x["value"])
|
||||||
|
logging.debug(f"Reset {option} to {x['value']}")
|
||||||
self.set_opt_value(None, None, option)
|
self.set_opt_value(None, None, option)
|
||||||
|
|
||||||
def set_opt_value(self, widget, event, opt):
|
def set_opt_value(self, widget, event, opt):
|
||||||
@ -114,8 +134,8 @@ class Panel(ScreenPanel):
|
|||||||
|
|
||||||
if opt == "max_accel":
|
if opt == "max_accel":
|
||||||
self._screen._ws.klippy.gcode_script(f"SET_VELOCITY_LIMIT ACCEL={value}")
|
self._screen._ws.klippy.gcode_script(f"SET_VELOCITY_LIMIT ACCEL={value}")
|
||||||
elif opt == "max_accel_to_decel":
|
elif opt == "minimum_cruise_ratio":
|
||||||
self._screen._ws.klippy.gcode_script(f"SET_VELOCITY_LIMIT ACCEL_TO_DECEL={value}")
|
self._screen._ws.klippy.gcode_script(f"SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO={value / 100}")
|
||||||
elif opt == "max_velocity":
|
elif opt == "max_velocity":
|
||||||
self._screen._ws.klippy.gcode_script(f"SET_VELOCITY_LIMIT VELOCITY={value}")
|
self._screen._ws.klippy.gcode_script(f"SET_VELOCITY_LIMIT VELOCITY={value}")
|
||||||
elif opt == "square_corner_velocity":
|
elif opt == "square_corner_velocity":
|
||||||
|
@ -268,7 +268,7 @@ class KlipperScreen(Gtk.Window):
|
|||||||
"print_stats": ["print_duration", "total_duration", "filament_used", "filename", "state", "message",
|
"print_stats": ["print_duration", "total_duration", "filament_used", "filename", "state", "message",
|
||||||
"info"],
|
"info"],
|
||||||
"toolhead": ["homed_axes", "estimated_print_time", "print_time", "position", "extruder",
|
"toolhead": ["homed_axes", "estimated_print_time", "print_time", "position", "extruder",
|
||||||
"max_accel", "max_accel_to_decel", "max_velocity", "square_corner_velocity"],
|
"max_accel", "minimum_cruise_ratio", "max_velocity", "square_corner_velocity"],
|
||||||
"virtual_sdcard": ["file_position", "is_active", "progress"],
|
"virtual_sdcard": ["file_position", "is_active", "progress"],
|
||||||
"webhooks": ["state", "state_message"],
|
"webhooks": ["state", "state_message"],
|
||||||
"firmware_retraction": ["retract_length", "retract_speed", "unretract_extra_length", "unretract_speed"],
|
"firmware_retraction": ["retract_length", "retract_speed", "unretract_extra_length", "unretract_speed"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user