filament_switch_sensor: Add a get_status() method

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-02-16 16:49:09 -05:00 committed by KevinOConnor
parent 9415071482
commit 718da75910
1 changed files with 3 additions and 0 deletions

View File

@ -111,6 +111,8 @@ class RunoutHelper:
"Filament Sensor %s: runout event detected, Time %.2f" %
(self.name, eventtime))
self.reactor.register_callback(self._runout_event_handler)
def get_status(self, eventtime):
return {"filament_detected": bool(self.filament_present)}
cmd_QUERY_FILAMENT_SENSOR_help = "Query the status of the Filament Sensor"
def cmd_QUERY_FILAMENT_SENSOR(self, params):
if self.filament_present:
@ -129,6 +131,7 @@ class SwitchSensor:
switch_pin = config.get('switch_pin')
buttons.register_buttons([switch_pin], self._button_handler)
self.runout_helper = RunoutHelper(config)
self.get_status = self.runout_helper.get_status
def _button_handler(self, eventtime, state):
self.runout_helper.note_filament_present(state)