diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 286dce36..48ece06d 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -202,6 +202,11 @@ The following standard commands are supported: adjustment will only be made every BAND millimeters of z height - in that case the formula used is `value = start + factor * ((floor(z_height / band) + .5) * band)`. +- `SET_DISPLAY_GROUP DISPLAY= GROUP=`: Set the active + display group of the display. This allows to define multiple display + data groups in the config, e.g.`[display_data ]` + and switch between them using this extended gcode command. use + `DISPLAY=display` to change the display group of the default display. - `SET_IDLE_TIMEOUT [TIMEOUT=]`: Allows the user to set the idle timeout (in seconds). - `RESTART`: This will cause the host software to reload its config diff --git a/klippy/extras/display/display.py b/klippy/extras/display/display.py index ccf7c391..a7a2621f 100644 --- a/klippy/extras/display/display.py +++ b/klippy/extras/display/display.py @@ -103,6 +103,10 @@ class PrinterLCD: self.printer.register_event_handler("klippy:ready", self.handle_ready) self.screen_update_timer = self.reactor.register_timer( self.screen_update_event) + gcode = self.printer.lookup_object("gcode") + gcode.register_mux_command( + 'SET_DISPLAY_GROUP', 'DISPLAY', name, self.cmd_SET_DISPLAY_GROUP, + desc=self.cmd_SET_DISPLAY_GROUP_help) # Configurable display def _parse_glyph(self, config, glyph_name, data, width, height): glyph_data = [] @@ -215,6 +219,13 @@ class PrinterLCD: self.lcd_chip.write_graphics(col, row, i, data) self.lcd_chip.write_graphics(col, row, 15, [0xff]*width) return "" + cmd_SET_DISPLAY_GROUP_help = "Set the active display group" + def cmd_SET_DISPLAY_GROUP(self, gcmd): + group = gcmd.get('GROUP') + new_dg = self.display_data_groups.get(group) + if new_dg is None: + raise gcmd.error("Unknown display_data group '%s'" % (group,)) + self.show_data_group = new_dg def load_config(config): return PrinterLCD(config)