menu: add config_sections of printer.cfg to improve menu filtering
remove idle_timeout from the enable status (not used) make status data do less stuff for performance reasons separate printer and moonraker in status enable docs: make menu config look more like configuration reference of klipper also fixes some mistakes and simplify the description
This commit is contained in:
parent
d21033ad55
commit
49a8fa8186
@ -155,52 +155,46 @@ printer is idle. The __print menu is accessible from the printing status page.
|
||||
A menu item is configured as follows:
|
||||
```{ .ini .no-copy }
|
||||
[menu __main my_menu_item]
|
||||
# To build a sub-menu of this menu item, you would next use [menu __main my_menu_item sub_menu_item]
|
||||
name: Item Name
|
||||
# Optional Parameters
|
||||
# To build a sub-menu of this menu item, you would next use [menu __main my_menu_item sub_menu_item]
|
||||
#
|
||||
# Icon name to be used, it can be any image in the directory:
|
||||
# KlipperScreen/styles/{theme}/images/ where {theme} is your current theme
|
||||
# Supported formats svg or png
|
||||
icon: home
|
||||
# Icon style, defined as "button.mycolor4" (for example) in the theme css
|
||||
style: mycolor4
|
||||
# Panel from the panels listed below
|
||||
panel: preheat
|
||||
# Moonraker method to call when the item is selected
|
||||
method: printer.gcode.script
|
||||
# Parameters that would be passed with the method above
|
||||
params: {"script":"G28 X"}
|
||||
# Enable allows hiding of a menu if the condition is false. This statement is evaluated in Jinja2
|
||||
# The following items are optional:
|
||||
# icon: home
|
||||
# Icon name to be used, it can be any image in the directory:
|
||||
# KlipperScreen/styles/{theme}/images/ where {theme} is your current theme
|
||||
# Supported formats svg or png
|
||||
#
|
||||
# style: mycolor4
|
||||
# Icon style, defined as "button.mycolor4" (for example) in the theme css
|
||||
# panel: preheat
|
||||
# Panel from the panels folder in the KlipperScreen folder
|
||||
# method: printer.gcode.script
|
||||
# Moonraker method to call when the item is selected
|
||||
# params: {"script":"G28 X"}
|
||||
# Parameters that would be passed with the method above
|
||||
# enable: {{ 'screws_tilt_adjust' in printer.config_sections and printer.power_devices.count > 0 }}
|
||||
# Enable allows hiding of a menu if the condition is false. (evaluated with Jinja2)
|
||||
# Available variables are listed below.
|
||||
enable: {{ printer.power_devices.count > 0 }}
|
||||
```
|
||||
Available panels are listed here: [docs/panels.md](Panels.md)
|
||||
|
||||
Certain variables are available for conditional testing of the enable statement:
|
||||
```{ .yaml .no-copy }
|
||||
# Configured in Moonraker
|
||||
moonraker.power_devices.count # Number of power devices
|
||||
moonraker.cameras.count # Number of cameras
|
||||
moonraker.spoolman # Has spoolman
|
||||
|
||||
# Printer specific
|
||||
printer.pause_resume.is_paused # Printing job is paused
|
||||
printer.extruders.count # Number of extruders
|
||||
printer.temperature_devices.count # Number of temperature related devices that are not extruders
|
||||
printer.temperature_devices.count # Number of temperature related devices (not extruders)
|
||||
printer.fans.count # Number of fans
|
||||
printer.power_devices.count # Number of power devices configured in Moonraker
|
||||
printer.output_pins.count # Number of pins configured
|
||||
printer.gcode_macros.count # Number of gcode macros
|
||||
printer.gcode_macros.list # List of names of the gcode macros
|
||||
printer.output_pins.count # Number of fans
|
||||
|
||||
printer.bltouch # Available if bltouch section defined in config
|
||||
printer.probe # Available if probe section defined in config
|
||||
printer.bed_mesh # Available if bed_mesh section defined in config
|
||||
printer.quad_gantry_level # Available if quad_gantry_level section defined in config
|
||||
printer.z_tilt # Available if z_tilt section defined in config
|
||||
|
||||
printer.firmware_retraction # True if defined in config
|
||||
printer.input_shaper # True if defined in config
|
||||
printer.bed_screws # True if defined in config
|
||||
printer.screws_tilt_adjust # True if defined in config
|
||||
|
||||
printer.idle_timeout # Idle timeout section
|
||||
printer.pause_resume # Pause resume section of Klipper
|
||||
|
||||
printer.leds.count # Number of leds
|
||||
printer.config_sections # Array of section headers of Klipper config (printer.cfg)
|
||||
```
|
||||
|
||||
|
||||
@ -210,11 +204,6 @@ A sample configuration of a main menu would be as follows:
|
||||
name: Homing
|
||||
icon: home
|
||||
|
||||
[menu __main preheat]
|
||||
name: Preheat
|
||||
icon: heat-up
|
||||
panel: preheat
|
||||
|
||||
[menu __main homing homeall]
|
||||
name: Home All
|
||||
icon: home
|
||||
@ -228,6 +217,10 @@ method: printer.gcode.script
|
||||
params: {"script":"MY_MACRO"}
|
||||
enable: {{ 'MY_MACRO' in printer.gcode_macros.list }}
|
||||
|
||||
[menu __main preheat]
|
||||
name: Preheat
|
||||
icon: heat-up
|
||||
panel: preheat
|
||||
```
|
||||
|
||||
## KlipperScreen behaviour towards configuration
|
||||
|
@ -19,8 +19,6 @@ extruder = 210
|
||||
[menu __main]
|
||||
name: {{ gettext('Main Menu') }}
|
||||
|
||||
|
||||
|
||||
[menu __main move]
|
||||
name: {{ gettext('Move') }}
|
||||
icon: move
|
||||
@ -61,14 +59,14 @@ name: {{ gettext('Quad Gantry Level') }}
|
||||
icon: home-z
|
||||
method: printer.gcode.script
|
||||
params: {"script":"QUAD_GANTRY_LEVEL"}
|
||||
enable: {{ printer.quad_gantry_level is defined }}
|
||||
enable: {{ 'quad_gantry_level' in printer.config_sections }}
|
||||
|
||||
[menu move homing Z-Tilt]
|
||||
name: {{ gettext('Z Tilt') }}
|
||||
icon: z-tilt
|
||||
method: printer.gcode.script
|
||||
params: {"script":"Z_TILT_ADJUST"}
|
||||
enable: {{ printer.z_tilt is defined }}
|
||||
enable: {{ 'z_tilt' in printer.config_sections }}
|
||||
|
||||
[menu __main temperature]
|
||||
name: {{ gettext('Temperature') }}
|
||||
@ -95,13 +93,13 @@ panel: print
|
||||
name: {{ gettext('Bed Level') }}
|
||||
icon: bed-level
|
||||
panel: bed_level
|
||||
enable: {{ printer.bed_screws or printer.screws_tilt_adjust}}
|
||||
enable: {{ 'bed_screws' in printer.config_sections or 'screws_tilt_adjust' in printer.config_sections }}
|
||||
|
||||
[menu __main more bedmesh]
|
||||
name: {{ gettext('Bed Mesh') }}
|
||||
icon: bed-mesh
|
||||
panel: bed_mesh
|
||||
enable: {{ printer.bed_mesh is defined }}
|
||||
enable: {{ 'bed_mesh' in printer.config_sections }}
|
||||
|
||||
[menu __main more zoffset]
|
||||
name: {{ gettext('Z Calibrate') }}
|
||||
@ -147,13 +145,13 @@ enable: {{ printer.output_pins.count > 0 }}
|
||||
name: {{ gettext('Power') }}
|
||||
icon: shutdown
|
||||
panel: power
|
||||
enable: {{ printer.power_devices.count > 0 }}
|
||||
enable: {{ moonraker.power_devices.count > 0 }}
|
||||
|
||||
[menu __main more camera]
|
||||
name: {{ gettext('Camera') }}
|
||||
icon: camera
|
||||
panel: camera
|
||||
enable: {{ printer.cameras.count > 0 }}
|
||||
enable: {{ moonraker.cameras.count > 0 }}
|
||||
|
||||
[menu __main more console]
|
||||
name: {{ gettext('Console') }}
|
||||
@ -220,7 +218,7 @@ enable: {{ printer.fans.count > 0 }}
|
||||
name: {{ gettext('Move') }}
|
||||
icon: move
|
||||
panel: move
|
||||
enable: {{ (printer.pause_resume.is_paused == True) }}
|
||||
enable: {{ printer.pause_resume.is_paused }}
|
||||
|
||||
[menu __print extrude]
|
||||
name: {{ gettext('Extrude') }}
|
||||
@ -232,7 +230,7 @@ enable: {{ printer.extruders.count > 0 }}
|
||||
name: {{ gettext('Power') }}
|
||||
icon: shutdown
|
||||
panel: power
|
||||
enable: {{ printer.power_devices.count > 0 }}
|
||||
enable: {{ moonraker.power_devices.count > 0 }}
|
||||
|
||||
[menu __print led]
|
||||
name: {{ gettext('Leds') }}
|
||||
@ -251,7 +249,7 @@ enable: {{ printer.gcode_macros.count > 0 }}
|
||||
name: {{ gettext('Camera') }}
|
||||
icon: camera
|
||||
panel: camera
|
||||
enable: {{ printer.cameras.count > 0 }}
|
||||
enable: {{ moonraker.cameras.count > 0 }}
|
||||
|
||||
[menu __print console]
|
||||
name: {{ gettext('Console') }}
|
||||
@ -272,7 +270,7 @@ panel: network
|
||||
name: {{ gettext('Retraction') }}
|
||||
icon: retract
|
||||
panel: retraction
|
||||
enable: {{ printer.firmware_retraction }}
|
||||
enable: {{ 'firmware_retraction' in printer.config_sections }}
|
||||
|
||||
[menu __print settings]
|
||||
name: KlipperScreen
|
||||
@ -286,7 +284,7 @@ name: {{ gettext('Menu') }}
|
||||
name: {{ gettext('Power') }}
|
||||
icon: shutdown
|
||||
panel: power
|
||||
enable: {{ printer.power_devices.count > 0 }}
|
||||
enable: {{ moonraker.power_devices.count > 0 }}
|
||||
|
||||
[menu __splashscreen network]
|
||||
name: {{ gettext('Network') }}
|
||||
@ -308,10 +306,10 @@ panel: settings
|
||||
name: Spoolman
|
||||
icon: spoolman
|
||||
panel: spoolman
|
||||
enable: {{ printer.spoolman }}
|
||||
enable: {{ moonraker.spoolman }}
|
||||
|
||||
[menu __print spoolman]
|
||||
name: Spoolman
|
||||
icon: spoolman
|
||||
panel: spoolman
|
||||
enable: {{ printer.spoolman }}
|
||||
enable: {{ moonraker.spoolman }}
|
||||
|
@ -242,33 +242,24 @@ class Printer:
|
||||
return None
|
||||
|
||||
def get_printer_status_data(self):
|
||||
data = {
|
||||
return {
|
||||
"moonraker": {
|
||||
"power_devices": {"count": len(self.get_power_devices())},
|
||||
"cameras": {"count": len(self.cameras)},
|
||||
"spoolman": self.spoolman,
|
||||
},
|
||||
"printer": {
|
||||
"pause_resume": {"is_paused": self.state == "paused"},
|
||||
"extruders": {"count": self.extrudercount},
|
||||
"temperature_devices": {"count": self.tempdevcount},
|
||||
"fans": {"count": self.fancount},
|
||||
"output_pins": {"count": self.output_pin_count},
|
||||
"gcode_macros": {"count": len(self.get_gcode_macros()), "list": self.get_gcode_macros()},
|
||||
"idle_timeout": self.get_stat("idle_timeout").copy(),
|
||||
"pause_resume": {"is_paused": self.state == "paused"},
|
||||
"power_devices": {"count": len(self.get_power_devices())},
|
||||
"cameras": {"count": len(self.cameras)},
|
||||
"spoolman": self.spoolman,
|
||||
"leds": {"count": self.ledcount},
|
||||
"config_sections": [section for section in self.config.keys()],
|
||||
}
|
||||
}
|
||||
|
||||
sections = ["bed_mesh", "bltouch", "probe", "quad_gantry_level", "z_tilt"]
|
||||
for section in sections:
|
||||
if self.config_section_exists(section):
|
||||
data["printer"][section] = self.get_config_section(section).copy()
|
||||
|
||||
sections = ["firmware_retraction", "input_shaper", "bed_screws", "screws_tilt_adjust"]
|
||||
for section in sections:
|
||||
data["printer"][section] = self.config_section_exists(section)
|
||||
|
||||
return data
|
||||
|
||||
def get_leds(self):
|
||||
return [
|
||||
led
|
||||
|
Loading…
x
Reference in New Issue
Block a user