chore: initialize repository and staged implementation plan
This commit is contained in:
commit
cb0e9d156f
48 files changed
+7343
No files matched your search
+25
@@ -0,0 +1,25 @@
|
||||
import pigpio
|
||||
|
||||
class Barrier:
|
||||
def __init__(self, pin=12, min_pw=500, max_pw=2400):
|
||||
self.pi = pigpio.pi()
|
||||
if not self.pi.connected:
|
||||
raise RuntimeError("Cannot connect to pigpiod – is it running?")
|
||||
self.pin = pin
|
||||
self.min = min_pw
|
||||
self.max = max_pw
|
||||
self.pi.set_mode(pin, pigpio.OUTPUT)
|
||||
self.close()
|
||||
|
||||
def set_angle(self, deg):
|
||||
pulse = self.min + (deg / 180.0) * (self.max - self.min)
|
||||
self.pi.set_servo_pulsewidth(self.pin, pulse)
|
||||
|
||||
def open(self):
|
||||
self.set_angle(0)
|
||||
|
||||
def close(self):
|
||||
self.set_angle(90)
|
||||
|
||||
def stop(self):
|
||||
self.pi.set_servo_pulsewidth(self.pin, 0)
|
||||
Reference in new issue
Block a user