another fix for handle_initial_gpio_control
This commit is contained in:
@@ -1041,34 +1041,19 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
|
||||
pass
|
||||
|
||||
def handle_initial_gpio_control(self):
|
||||
|
||||
for filament_sensor in list(filter(lambda item: item['input_type'] == 'gpio' and
|
||||
item['action_type'] == 'output_control', self.rpi_inputs)):
|
||||
gpio_pin = self.to_int(rpi_input['gpio_pin'])
|
||||
controlled_io = self.to_int(rpi_input['controlled_io'])
|
||||
if (rpi_input['edge'] == 'fall') ^ GPIO.input(gpio_pin):
|
||||
rpi_output = [r_out for r_out in self.rpi_outputs if self.to_int(
|
||||
r_out['index_id']) == controlled_io].pop()
|
||||
if rpi_output['output_type'] == 'regular':
|
||||
val = GPIO.LOW if rpi_input['controlled_io_set_value'] == 'low' else GPIO.HIGH
|
||||
self.write_gpio(self.to_int(
|
||||
rpi_output['gpio_pin']), val)
|
||||
for notification in self.notifications:
|
||||
if notification['gpioAction']:
|
||||
msg = "GPIO control action caused by input " + str(rpi_input['label']) + ". Setting GPIO" + str(
|
||||
rpi_input['controlled_io']) + " to: " + str(rpi_input['controlled_io_set_value'])
|
||||
self.send_notification(msg)
|
||||
if rpi_output['output_type'] == 'gcode_output':
|
||||
self.send_gcode_command(rpi_output['gcode'])
|
||||
for notification in self.notifications:
|
||||
if notification['gpioAction']:
|
||||
msg = "GPIO control action caused by input " + \
|
||||
str(rpi_input['label']) + \
|
||||
". Sending GCODE command"
|
||||
self.send_notification(msg)
|
||||
if rpi_output['output_type'] == 'shell_output':
|
||||
command = rpi_output['shell_script']
|
||||
self.send_shell_command(command)
|
||||
try:
|
||||
for filament_sensor in list(filter(lambda item: item['input_type'] == 'gpio' and
|
||||
item['action_type'] == 'output_control', self.rpi_inputs)):
|
||||
gpio_pin = self.to_int(rpi_input['gpio_pin'])
|
||||
controlled_io = self.to_int(rpi_input['controlled_io'])
|
||||
if (rpi_input['edge'] == 'fall') ^ GPIO.input(gpio_pin):
|
||||
rpi_output = [r_out for r_out in self.rpi_outputs if self.to_int(
|
||||
r_out['index_id']) == controlled_io].pop()
|
||||
if rpi_output['output_type'] == 'regular':
|
||||
val = GPIO.LOW if rpi_input['controlled_io_set_value'] == 'low' else GPIO.HIGH
|
||||
self.write_gpio(self.to_int(
|
||||
rpi_output['gpio_pin']), val)
|
||||
except Exception as ex:
|
||||
self.log_error(ex)
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user