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 = {
|
self.printer_state = {
|
||||||
'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
|
'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
|
||||||
'fan': {}, 'display_status': {}, 'print_stats': {},
|
'fan': {}, 'display_status': {}, 'print_stats': {},
|
||||||
'idle_timeout': {}}
|
'idle_timeout': {}, 'gcode_macro PANELDUE_BEEP': {}}
|
||||||
self.extruder_count = 0
|
self.extruder_count = 0
|
||||||
self.heaters = []
|
self.heaters = []
|
||||||
self.is_ready = False
|
self.is_ready = False
|
||||||
|
@ -154,6 +154,7 @@ class PanelDue:
|
||||||
# Set up macros
|
# Set up macros
|
||||||
self.confirmed_gcode = ""
|
self.confirmed_gcode = ""
|
||||||
self.mbox_sequence = 0
|
self.mbox_sequence = 0
|
||||||
|
self.beep_sequence = 0
|
||||||
self.available_macros = {}
|
self.available_macros = {}
|
||||||
self.confirmed_macros = {
|
self.confirmed_macros = {
|
||||||
"RESTART": "RESTART",
|
"RESTART": "RESTART",
|
||||||
|
@ -188,9 +189,6 @@ class PanelDue:
|
||||||
self.server.register_event_handler(
|
self.server.register_event_handler(
|
||||||
"server:gcode_response", self.handle_gcode_response)
|
"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
|
# These commands are directly executued on the server and do not to
|
||||||
# make a request to Klippy
|
# make a request to Klippy
|
||||||
self.direct_gcodes = {
|
self.direct_gcodes = {
|
||||||
|
@ -250,7 +248,7 @@ class PanelDue:
|
||||||
self.printer_state = {
|
self.printer_state = {
|
||||||
'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
|
'gcode_move': {}, 'toolhead': {}, 'virtual_sdcard': {},
|
||||||
'fan': {}, 'display_status': {}, 'print_stats': {},
|
'fan': {}, 'display_status': {}, 'print_stats': {},
|
||||||
'idle_timeout': {}}
|
'idle_timeout': {}, 'gcode_macro PANELDUE_BEEP': {}}
|
||||||
sub_args = {k: None for k in self.printer_state.keys()}
|
sub_args = {k: None for k in self.printer_state.keys()}
|
||||||
self.extruder_count = 0
|
self.extruder_count = 0
|
||||||
self.heaters = []
|
self.heaters = []
|
||||||
|
@ -287,12 +285,22 @@ class PanelDue:
|
||||||
self.printer_state[obj].update(items)
|
self.printer_state[obj].update(items)
|
||||||
else:
|
else:
|
||||||
self.printer_state[obj] = items
|
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):
|
||||||
duration = int(duration * 1000.)
|
if sequence != self.beep_sequence:
|
||||||
self.ioloop.spawn_callback(
|
self.beep_sequence = sequence
|
||||||
self.write_response,
|
duration = int(duration * 1000.)
|
||||||
{'beep_freq': frequency, 'beep_length': duration})
|
self.ioloop.spawn_callback(
|
||||||
|
self.write_response,
|
||||||
|
{'beep_freq': frequency, 'beep_length': duration})
|
||||||
|
|
||||||
async def process_line(self, line):
|
async def process_line(self, line):
|
||||||
# If we find M112 in the line then skip verification
|
# If we find M112 in the line then skip verification
|
||||||
|
|
Loading…
Reference in New Issue