You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
#!/usr/bin/env python3
|
|
|
|
import shepherd.config as shconf
|
|
import shepherd.plugin
|
|
|
|
import sys
|
|
import os
|
|
import time
|
|
import argparse
|
|
|
|
|
|
class AphidtrapModule(shepherd.plugin.Plugin):
|
|
@staticmethod
|
|
def define_config(confdef):
|
|
pass
|
|
|
|
def __init__(self, pluginInterface, config):
|
|
super().__init__(pluginInterface, config)
|
|
|
|
self.config = config
|
|
self.interface = pluginInterface
|
|
self.plugins = pluginInterface.other_plugins
|
|
self.hooks = pluginInterface.hooks
|
|
|
|
print("Aphidtrap config:")
|
|
print(self.config)
|
|
|
|
if "picam" in self.plugins:
|
|
self.interface.attach_hook("picam", "pre_cam", self.led_on)
|
|
self.interface.attach_hook("picam", "post_cam", self.led_off)
|
|
elif "usbcam" in self.plugins:
|
|
self.interface.attach_hook("usbcam", "pre_cam", self.led_on)
|
|
self.interface.attach_hook("usbcam", "post_cam", self.led_off)
|
|
else:
|
|
raise ValueError("Need to either have picam or usbcam plugin loaded")
|
|
|
|
self.interface.register_function(self.test)
|
|
|
|
def led_on(self):
|
|
self.plugins["scout"].set_out2(True)
|
|
|
|
def led_off(self):
|
|
self.plugins["scout"].set_out2(False)
|
|
|
|
def test(self):
|
|
self.led_on()
|
|
time.sleep(2)
|
|
self.led_off() |