extrude: move firmware retraction into the panel, add pressure advance control closes #724
This commit is contained in:
parent
3d542465e8
commit
ac6f34acb0
@ -60,12 +60,6 @@ name: {{ gettext('Limits') }}
|
|||||||
icon: fine-tune
|
icon: fine-tune
|
||||||
panel: limits
|
panel: limits
|
||||||
|
|
||||||
[menu __main more retraction]
|
|
||||||
name: {{ gettext('Retraction') }}
|
|
||||||
icon: retract
|
|
||||||
panel: retraction
|
|
||||||
enable: {{ 'firmware_retraction' in printer.config_sections }}
|
|
||||||
|
|
||||||
[menu __main more fan]
|
[menu __main more fan]
|
||||||
name: {{ gettext('Fan') }}
|
name: {{ gettext('Fan') }}
|
||||||
icon: fan
|
icon: fan
|
||||||
|
@ -69,12 +69,6 @@ name: {{ gettext('Network') }}
|
|||||||
icon: network
|
icon: network
|
||||||
panel: network
|
panel: network
|
||||||
|
|
||||||
[menu __print retraction]
|
|
||||||
name: {{ gettext('Retraction') }}
|
|
||||||
icon: retract
|
|
||||||
panel: retraction
|
|
||||||
enable: {{ 'firmware_retraction' in printer.config_sections }}
|
|
||||||
|
|
||||||
[menu __print settings]
|
[menu __print settings]
|
||||||
name: KlipperScreen
|
name: KlipperScreen
|
||||||
icon: settings
|
icon: settings
|
||||||
|
@ -658,6 +658,9 @@ msgstr ""
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -661,6 +661,9 @@ msgstr "Zapni tiskárnu"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressure Advance:"
|
msgstr "Pressure Advance:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressure Advance"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Tisk"
|
msgstr "Tisk"
|
||||||
|
|
||||||
|
@ -656,6 +656,9 @@ msgstr "Tænd printer"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressure Advance:"
|
msgstr "Pressure Advance:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressure Advance"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Print"
|
msgstr "Print"
|
||||||
|
|
||||||
|
@ -661,6 +661,9 @@ msgstr "Drucker einschalten"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Druckvorlauf:"
|
msgstr "Druckvorlauf:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Druckvorlauf"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Druck"
|
msgstr "Druck"
|
||||||
|
|
||||||
|
@ -661,6 +661,9 @@ msgstr "Drucker einschalten"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Druckvorlauf:"
|
msgstr "Druckvorlauf:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Druckvorlauf"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Druck"
|
msgstr "Druck"
|
||||||
|
|
||||||
|
@ -662,6 +662,9 @@ msgstr "Encender Impresora"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Avance de presión:"
|
msgstr "Avance de presión:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Avance de presión"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Imprimir"
|
msgstr "Imprimir"
|
||||||
|
|
||||||
|
@ -656,6 +656,9 @@ msgstr "Printeri sisselülitamine"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Surveelisus:"
|
msgstr "Surveelisus:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Surveelisus"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Prindi"
|
msgstr "Prindi"
|
||||||
|
|
||||||
|
@ -662,6 +662,9 @@ msgstr "Allumer l'imprimante"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Avance de pression:"
|
msgstr "Avance de pression:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Avance de pression"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Imprimer"
|
msgstr "Imprimer"
|
||||||
|
|
||||||
|
@ -663,6 +663,9 @@ msgstr "הפעל מדפסת"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "פרשר אדוונס"
|
msgstr "פרשר אדוונס"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "פרשר אדוונס"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "הדפסה"
|
msgstr "הדפסה"
|
||||||
|
|
||||||
|
@ -655,6 +655,9 @@ msgstr "Nyomtató bekapcsolása"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Nyomás előtolás:"
|
msgstr "Nyomás előtolás:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Nyomás előtolás"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Nyomtatás"
|
msgstr "Nyomtatás"
|
||||||
|
|
||||||
|
@ -657,6 +657,9 @@ msgstr "Accendi la stampante"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressure Advance:"
|
msgstr "Pressure Advance:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressure Advance"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Stampa"
|
msgstr "Stampa"
|
||||||
|
|
||||||
|
@ -653,6 +653,9 @@ msgstr "プリンター電源"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "印刷"
|
msgstr "印刷"
|
||||||
|
|
||||||
|
@ -654,6 +654,9 @@ msgstr "프린터 전원 켜기"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "모서리 압출 제어 수치:"
|
msgstr "모서리 압출 제어 수치:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "모서리 압출 제어 수치"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "출력"
|
msgstr "출력"
|
||||||
|
|
||||||
|
@ -664,6 +664,10 @@ msgstr "Išjungti spausdintuvą"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Slėgio kontrolė:"
|
msgstr "Slėgio kontrolė:"
|
||||||
|
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Slėgio kontrolė"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Spausdinti"
|
msgstr "Spausdinti"
|
||||||
|
|
||||||
|
@ -661,6 +661,9 @@ msgstr "Printer Aanzetten"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressure Advance:"
|
msgstr "Pressure Advance:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressure Advance"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Print"
|
msgstr "Print"
|
||||||
|
|
||||||
|
@ -659,6 +659,9 @@ msgstr "Zasilanie włączone"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressure Advance:"
|
msgstr "Pressure Advance:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressure Advance"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Drukuj"
|
msgstr "Drukuj"
|
||||||
|
|
||||||
|
@ -662,6 +662,9 @@ msgstr "Ligar a impressora"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Avanço de Pressão:"
|
msgstr "Avanço de Pressão:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Avanço de Pressão"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Imprimir"
|
msgstr "Imprimir"
|
||||||
|
|
||||||
|
@ -661,6 +661,9 @@ msgstr "Ligar Impressora"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressão de Avanço (Pressure Advance):"
|
msgstr "Pressão de Avanço (Pressure Advance):"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressão de Avanço"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Imprimir"
|
msgstr "Imprimir"
|
||||||
|
|
||||||
|
@ -662,6 +662,9 @@ msgstr "Включить принтер"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Повышение давления:"
|
msgstr "Повышение давления:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Повышение давления"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Печать"
|
msgstr "Печать"
|
||||||
|
|
||||||
|
@ -664,6 +664,10 @@ msgstr "Vklopite tiskalnik"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Pressure Advance:"
|
msgstr "Pressure Advance:"
|
||||||
|
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Pressure Advance"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Natisni"
|
msgstr "Natisni"
|
||||||
|
|
||||||
|
@ -660,6 +660,9 @@ msgstr "Slå på skrivaren"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Tryckförflyttning:"
|
msgstr "Tryckförflyttning:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Tryckförflyttning"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Skriv ut"
|
msgstr "Skriv ut"
|
||||||
|
|
||||||
|
@ -659,6 +659,9 @@ msgstr "Yazıcıya Güç Ver (aç)"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Akış Dengeleme:"
|
msgstr "Akış Dengeleme:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Akış Dengeleme"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Yazdır"
|
msgstr "Yazdır"
|
||||||
|
|
||||||
|
@ -662,6 +662,9 @@ msgstr "Увімкнути принтер"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Випередження тиску:"
|
msgstr "Випередження тиску:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Випередження тиску"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "Друк"
|
msgstr "Друк"
|
||||||
|
|
||||||
|
@ -653,6 +653,9 @@ msgstr "Bật nguồn máy in"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "Nâng áp suất:"
|
msgstr "Nâng áp suất:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "Nâng áp suất"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "In"
|
msgstr "In"
|
||||||
|
|
||||||
|
@ -658,6 +658,9 @@ msgstr "打印机通电"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "压力提前:"
|
msgstr "压力提前:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "压力提前"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "打印"
|
msgstr "打印"
|
||||||
|
|
||||||
|
@ -658,6 +658,9 @@ msgstr "啟動列印機"
|
|||||||
msgid "Pressure Advance:"
|
msgid "Pressure Advance:"
|
||||||
msgstr "壓力推進:"
|
msgstr "壓力推進:"
|
||||||
|
|
||||||
|
msgid "Pressure Advance"
|
||||||
|
msgstr "壓力推進"
|
||||||
|
|
||||||
msgid "Print"
|
msgid "Print"
|
||||||
msgstr "列印"
|
msgstr "列印"
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ class Panel(ScreenPanel):
|
|||||||
'retract': self._gtk.Button("retract", _("Retract"), "color1"),
|
'retract': self._gtk.Button("retract", _("Retract"), "color1"),
|
||||||
'temperature': self._gtk.Button("heat-up", _("Temperature"), "color4"),
|
'temperature': self._gtk.Button("heat-up", _("Temperature"), "color4"),
|
||||||
'spoolman': self._gtk.Button("spoolman", "Spoolman", "color3"),
|
'spoolman': self._gtk.Button("spoolman", "Spoolman", "color3"),
|
||||||
|
'pressure': self._gtk.Button("settings", _("Pressure Advance"), "color2"),
|
||||||
|
'retraction': self._gtk.Button("settings", _("Retraction"), "color1")
|
||||||
}
|
}
|
||||||
self.buttons['extrude'].connect("clicked", self.extrude, "+")
|
self.buttons['extrude'].connect("clicked", self.extrude, "+")
|
||||||
self.buttons['load'].connect("clicked", self.load_unload, "+")
|
self.buttons['load'].connect("clicked", self.load_unload, "+")
|
||||||
@ -53,6 +55,12 @@ class Panel(ScreenPanel):
|
|||||||
self.buttons['spoolman'].connect("clicked", self.menu_item_clicked, {
|
self.buttons['spoolman'].connect("clicked", self.menu_item_clicked, {
|
||||||
"panel": "spoolman"
|
"panel": "spoolman"
|
||||||
})
|
})
|
||||||
|
self.buttons['pressure'].connect("clicked", self.menu_item_clicked, {
|
||||||
|
"panel": "pressure_advance"
|
||||||
|
})
|
||||||
|
self.buttons['retraction'].connect("clicked", self.menu_item_clicked, {
|
||||||
|
"panel": "retraction"
|
||||||
|
})
|
||||||
|
|
||||||
xbox = Gtk.Box(homogeneous=True)
|
xbox = Gtk.Box(homogeneous=True)
|
||||||
limit = 4
|
limit = 4
|
||||||
@ -67,7 +75,7 @@ class Panel(ScreenPanel):
|
|||||||
self.labels[extruder].connect("clicked", self.change_extruder, extruder)
|
self.labels[extruder].connect("clicked", self.change_extruder, extruder)
|
||||||
if extruder == self.current_extruder:
|
if extruder == self.current_extruder:
|
||||||
self.labels[extruder].get_style_context().add_class("button_active")
|
self.labels[extruder].get_style_context().add_class("button_active")
|
||||||
if self._printer.extrudercount <= limit:
|
if self._printer.extrudercount < limit:
|
||||||
xbox.add(self.labels[extruder])
|
xbox.add(self.labels[extruder])
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
@ -76,13 +84,19 @@ class Panel(ScreenPanel):
|
|||||||
self.labels['extruders'] = AutoGrid(extruder_buttons, vertical=self._screen.vertical_mode)
|
self.labels['extruders'] = AutoGrid(extruder_buttons, vertical=self._screen.vertical_mode)
|
||||||
self.labels['extruders_menu'] = self._gtk.ScrolledWindow()
|
self.labels['extruders_menu'] = self._gtk.ScrolledWindow()
|
||||||
self.labels['extruders_menu'].add(self.labels['extruders'])
|
self.labels['extruders_menu'].add(self.labels['extruders'])
|
||||||
if self._printer.extrudercount > limit:
|
if self._printer.extrudercount >= limit:
|
||||||
changer = self._gtk.Button("toolchanger")
|
changer = self._gtk.Button("toolchanger")
|
||||||
changer.connect("clicked", self.load_menu, 'extruders', _('Extruders'))
|
changer.connect("clicked", self.load_menu, 'extruders', _('Extruders'))
|
||||||
xbox.add(changer)
|
xbox.add(changer)
|
||||||
self.labels["current_extruder"] = self._gtk.Button("extruder", "")
|
self.labels["current_extruder"] = self._gtk.Button("extruder", "")
|
||||||
xbox.add(self.labels["current_extruder"])
|
xbox.add(self.labels["current_extruder"])
|
||||||
self.labels["current_extruder"].connect("clicked", self.load_menu, 'extruders', _('Extruders'))
|
self.labels["current_extruder"].connect("clicked", self.load_menu, 'extruders', _('Extruders'))
|
||||||
|
if not self._screen.vertical_mode:
|
||||||
|
xbox.add(self.buttons['pressure'])
|
||||||
|
i += 1
|
||||||
|
if self._printer.get_config_section("firmware_retraction") and not self._screen.vertical_mode:
|
||||||
|
xbox.add(self.buttons['retraction'])
|
||||||
|
i += 1
|
||||||
if i < limit:
|
if i < limit:
|
||||||
xbox.add(self.buttons['temperature'])
|
xbox.add(self.buttons['temperature'])
|
||||||
if i < (limit - 1) and self._printer.spoolman:
|
if i < (limit - 1) and self._printer.spoolman:
|
||||||
@ -145,9 +159,14 @@ class Panel(ScreenPanel):
|
|||||||
grid.attach(self.buttons['retract'], 2, 1, 2, 1)
|
grid.attach(self.buttons['retract'], 2, 1, 2, 1)
|
||||||
grid.attach(self.buttons['load'], 0, 2, 2, 1)
|
grid.attach(self.buttons['load'], 0, 2, 2, 1)
|
||||||
grid.attach(self.buttons['unload'], 2, 2, 2, 1)
|
grid.attach(self.buttons['unload'], 2, 2, 2, 1)
|
||||||
grid.attach(distbox, 0, 3, 4, 1)
|
settings_box = Gtk.Box(homogeneous=True)
|
||||||
grid.attach(speedbox, 0, 4, 4, 1)
|
settings_box.add(self.buttons['pressure'])
|
||||||
grid.attach(sensors, 0, 5, 4, 1)
|
if self._printer.get_config_section("firmware_retraction"):
|
||||||
|
settings_box.add(self.buttons['retraction'])
|
||||||
|
grid.attach(settings_box, 0, 3, 4, 1)
|
||||||
|
grid.attach(distbox, 0, 4, 4, 1)
|
||||||
|
grid.attach(speedbox, 0, 5, 4, 1)
|
||||||
|
grid.attach(sensors, 0, 6, 4, 1)
|
||||||
else:
|
else:
|
||||||
grid.attach(self.buttons['extrude'], 0, 2, 1, 1)
|
grid.attach(self.buttons['extrude'], 0, 2, 1, 1)
|
||||||
grid.attach(self.buttons['load'], 1, 2, 1, 1)
|
grid.attach(self.buttons['load'], 1, 2, 1, 1)
|
||||||
@ -163,7 +182,7 @@ class Panel(ScreenPanel):
|
|||||||
|
|
||||||
def enable_buttons(self, enable):
|
def enable_buttons(self, enable):
|
||||||
for button in self.buttons:
|
for button in self.buttons:
|
||||||
if button in ("temperature", "spoolman"):
|
if button in ("pressure", "retraction", "spoolman", "temperature"):
|
||||||
continue
|
continue
|
||||||
self.buttons[button].set_sensitive(enable)
|
self.buttons[button].set_sensitive(enable)
|
||||||
|
|
||||||
|
162
panels/pressure_advance.py
Normal file
162
panels/pressure_advance.py
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
import logging
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk, Pango
|
||||||
|
from ks_includes.screen_panel import ScreenPanel
|
||||||
|
|
||||||
|
# TODO multi-extruder support
|
||||||
|
|
||||||
|
|
||||||
|
class Panel(ScreenPanel):
|
||||||
|
def __init__(self, screen, title):
|
||||||
|
title = title or _("Pressure advance")
|
||||||
|
super().__init__(screen, title)
|
||||||
|
self.current_extruder = "extruder"
|
||||||
|
self.current_extruder_label = Gtk.Label(
|
||||||
|
label=_("Current") + f": {self.current_extruder}"
|
||||||
|
)
|
||||||
|
self.grid = Gtk.Grid()
|
||||||
|
self.grid.attach(self.current_extruder_label, 0, 0, 1, 1)
|
||||||
|
self.values = {}
|
||||||
|
self.list = {}
|
||||||
|
self.options = [
|
||||||
|
{
|
||||||
|
"name": _("Pressure Advance"),
|
||||||
|
"units": _("mm"),
|
||||||
|
"option": "pressure_advance",
|
||||||
|
"value": 0,
|
||||||
|
"digits": 2,
|
||||||
|
"maxval": 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": _("Smooth time"),
|
||||||
|
"units": _("s"),
|
||||||
|
"option": "smooth_time",
|
||||||
|
"value": 0.04,
|
||||||
|
"digits": 3,
|
||||||
|
"maxval": 0.200,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
for opt in self.options:
|
||||||
|
self.add_option(opt)
|
||||||
|
|
||||||
|
scroll = self._gtk.ScrolledWindow()
|
||||||
|
scroll.add(self.grid)
|
||||||
|
|
||||||
|
self.content.add(scroll)
|
||||||
|
self.content.show_all()
|
||||||
|
|
||||||
|
def add_option(self, option_data):
|
||||||
|
option = option_data["option"]
|
||||||
|
optname = option_data["name"]
|
||||||
|
units = option_data["units"]
|
||||||
|
value = option_data["value"]
|
||||||
|
digits = option_data["digits"]
|
||||||
|
maxval = option_data["maxval"]
|
||||||
|
|
||||||
|
logging.info(f"Adding option: {option}")
|
||||||
|
|
||||||
|
name_label = Gtk.Label()
|
||||||
|
name_label.set_markup(f"<big><b>{optname}</b></big> ({units})")
|
||||||
|
|
||||||
|
adjustment = Gtk.Adjustment(
|
||||||
|
value,
|
||||||
|
0,
|
||||||
|
maxval,
|
||||||
|
0.05 if option.startswith("pressure") else 0.005,
|
||||||
|
0.1 if option.startswith("pressure") else 0.01,
|
||||||
|
0,
|
||||||
|
)
|
||||||
|
|
||||||
|
scale = Gtk.Scale(
|
||||||
|
adjustment=adjustment,
|
||||||
|
digits=digits,
|
||||||
|
hexpand=True,
|
||||||
|
has_origin=True,
|
||||||
|
)
|
||||||
|
scale.get_style_context().add_class("option_slider")
|
||||||
|
scale.connect("button-release-event", self.set_opt_value, option)
|
||||||
|
|
||||||
|
reset_button = self._gtk.Button("refresh", style="color1")
|
||||||
|
reset_button.connect("clicked", self.reset_value, option)
|
||||||
|
reset_button.set_hexpand(False)
|
||||||
|
|
||||||
|
item = Gtk.Grid()
|
||||||
|
item.attach(name_label, 0, 0, 2, 1)
|
||||||
|
item.attach(scale, 0, 1, 1, 1)
|
||||||
|
item.attach(reset_button, 1, 1, 1, 1)
|
||||||
|
|
||||||
|
self.list[option] = {
|
||||||
|
"row": item,
|
||||||
|
"scale": scale,
|
||||||
|
"adjustment": adjustment,
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = sorted(self.list).index(option) + 1
|
||||||
|
self.grid.attach(self.list[option]["row"], 0, pos, 1, 1)
|
||||||
|
self.grid.show_all()
|
||||||
|
|
||||||
|
def reset_value(self, widget, option):
|
||||||
|
for opt in self.options:
|
||||||
|
if opt["option"] == option:
|
||||||
|
self.update_option(option, opt["value"])
|
||||||
|
self.set_opt_value(None, None, option)
|
||||||
|
|
||||||
|
def set_opt_value(self, widget, event, opt):
|
||||||
|
value = self.list[opt]["scale"].get_value()
|
||||||
|
if opt == "pressure_advance":
|
||||||
|
self._screen._ws.klippy.gcode_script(
|
||||||
|
f"SET_PRESSURE_ADVANCE EXTRUDER={self.current_extruder} ADVANCE={value}"
|
||||||
|
)
|
||||||
|
if opt == "smooth_time":
|
||||||
|
self._screen._ws.klippy.gcode_script(
|
||||||
|
f"SET_PRESSURE_ADVANCE EXTRUDER={self.current_extruder} SMOOTH_TIME={value}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def process_update(self, action, data):
|
||||||
|
if action != "notify_status_update":
|
||||||
|
return
|
||||||
|
if (
|
||||||
|
"toolhead" in data
|
||||||
|
and "extruder" in data["toolhead"]
|
||||||
|
and data["toolhead"]["extruder"]
|
||||||
|
):
|
||||||
|
self.current_extruder = data["toolhead"]["extruder"]
|
||||||
|
logging.debug(f"Changing to {self.current_extruder}")
|
||||||
|
self.current_extruder_label.set_label(
|
||||||
|
_("Current") + f": {self.current_extruder}"
|
||||||
|
)
|
||||||
|
for opt in self.list:
|
||||||
|
if opt in self._printer.data[self.current_extruder]:
|
||||||
|
self.update_option(
|
||||||
|
opt, self._printer.data[self.current_extruder][opt]
|
||||||
|
)
|
||||||
|
if self.current_extruder in data:
|
||||||
|
for opt in self.list:
|
||||||
|
if opt in data[self.current_extruder]:
|
||||||
|
self.update_option(opt, data[self.current_extruder][opt])
|
||||||
|
|
||||||
|
def update_option(self, option, value):
|
||||||
|
if option not in self.list:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.list[option]["scale"].has_grab():
|
||||||
|
return
|
||||||
|
|
||||||
|
self.values[option] = float(value)
|
||||||
|
|
||||||
|
# Infinite scale
|
||||||
|
for opt in self.options:
|
||||||
|
if opt["option"] == option and not option.startswith("smooth_time"):
|
||||||
|
if self.values[option] > opt["maxval"] * 0.75:
|
||||||
|
self.list[option]["adjustment"].set_upper(self.values[option] * 1.5)
|
||||||
|
else:
|
||||||
|
self.list[option]["adjustment"].set_upper(opt["maxval"])
|
||||||
|
break
|
||||||
|
self.list[option]["scale"].set_value(self.values[option])
|
||||||
|
self.list[option]["scale"].disconnect_by_func(self.set_opt_value)
|
||||||
|
self.list[option]["scale"].connect(
|
||||||
|
"button-release-event", self.set_opt_value, option
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user