paneldue: Add support for the piezo buzzer

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-08-18 08:48:57 -04:00
parent 5a6f1ae062
commit f338bccc3b
1 changed files with 18 additions and 10 deletions

View File

@ -144,7 +144,7 @@ class PanelDue:
self.printer_state = {
'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
'fan': {}, 'display_status': {}, 'print_stats': {},
'idle_timeout': {}}
'idle_timeout': {}, 'gcode_macro PANELDUE_BEEP': {}}
self.extruder_count = 0
self.heaters = []
self.is_ready = False
@ -154,6 +154,7 @@ class PanelDue:
# Set up macros
self.confirmed_gcode = ""
self.mbox_sequence = 0
self.beep_sequence = 0
self.available_macros = {}
self.confirmed_macros = {
"RESTART": "RESTART",
@ -188,9 +189,6 @@ class PanelDue:
self.server.register_event_handler(
"server:gcode_response", self.handle_gcode_response)
self.server.register_remote_method(
"paneldue_beep", self.handle_paneldue_beep)
# These commands are directly executued on the server and do not to
# make a request to Klippy
self.direct_gcodes = {
@ -250,7 +248,7 @@ class PanelDue:
self.printer_state = {
'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
'fan': {}, 'display_status': {}, 'print_stats': {},
'idle_timeout': {}}
'idle_timeout': {}, 'gcode_macro PANELDUE_BEEP': {}}
sub_args = {k: None for k in self.printer_state.keys()}
self.extruder_count = 0
self.heaters = []
@ -287,8 +285,18 @@ class PanelDue:
self.printer_state[obj].update(items)
else:
self.printer_state[obj] = items
if "gcode_macro PANELDUE_BEEP" in status:
# This only processes a paneldue beep when the macro's
# variables have changed
params = self.printer_state["gcode_macro PANELDUE_BEEP"]
try:
self.handle_paneldue_beep(**params)
except Exception:
logging.exception("Unable to process PANELDUE_BEEP")
def handle_paneldue_beep(self, frequency, duration):
def handle_paneldue_beep(self, sequence, frequency, duration):
if sequence != self.beep_sequence:
self.beep_sequence = sequence
duration = int(duration * 1000.)
self.ioloop.spawn_callback(
self.write_response,