paneldue: Add support for the piezo buzzer
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
5a6f1ae062
commit
f338bccc3b
|
@ -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,12 +285,22 @@ 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):
|
||||
duration = int(duration * 1000.)
|
||||
self.ioloop.spawn_callback(
|
||||
self.write_response,
|
||||
{'beep_freq': frequency, 'beep_length': 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,
|
||||
{'beep_freq': frequency, 'beep_length': duration})
|
||||
|
||||
async def process_line(self, line):
|
||||
# If we find M112 in the line then skip verification
|
||||
|
|
Loading…
Reference in New Issue