command / attributes files in spec for decode

barrier exists and is doing a watch for status change on pins 0 and 1
main is starting to add in the new cluster at endpoint 8 on interview
com is where fancy_transmit is now
This commit is contained in:
2022-01-02 21:10:52 -05:00
parent 886f3c8d9f
commit 67410efd8b
4 changed files with 63 additions and 17 deletions

View File

@@ -2,18 +2,46 @@ import com
import xbee
from machine import Pin
class barrier:
moving = 0
position = 0
ad0 = Pin("D0", Pin.IN, Pin.PULL_UP)
ad1 = Pin("D1", Pin.IN, Pin.PULL_UP)
ad2 = Pin("D2", Pin.IN, Pin.PULL_UP)
ad4 = Pin("D4", Pin.OUT)
def status(seq,payload):
class Barrier:
moving = 0
barrier_position = 0
ad0 = Pin("D0", Pin.IN, Pin.PULL_UP) #door
ad1 = Pin("D1", Pin.IN, Pin.PULL_UP) #motor
ad4 = Pin("D4", Pin.OUT)
door = ad0.value()
motor = ad1.value()
update = False
def status(self, seq, payload):
pass
def command(seq, payload):
def command(self, seq, payload):
pass
def watch(self):
pass
current_door = self.door
current_motor = self.motor
self.door = self.ad0.value()
self.motor = self.ad1.value()
if (current_door != self.door) or (current_motor != self.motor):
self.update = True
else:
self.update = False
if self.door == 0:
if self.motor == 1:
self.moving = 0
self.barrier_position = 100
if self.motor == 0:
if self.door == 1:
self.moving = 0
self.barrier_position = 0
if self.motor == 0:
if self.door == 0:
if self.barrier_position == 100:
self.barrier_position = 50
self.moving = 1
if self.barrier_position == 0:
self.barrier_position = 50
self.moving = 2
return self.update