-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArduinoGate.py
35 lines (26 loc) · 1.04 KB
/
ArduinoGate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from SerialCommander import SerialCommander
class ArduinoGate(SerialCommander):
def __init__(self, port, baudrate = 9600, timeout = 5, EOF_string = '\r\n', OpenDuration = 1000, ClosedDuration = 1000):
super().__init__(port, baudrate, timeout, EOF_string)
self.OpenDuration = OpenDuration
self.ClosedDuration = ClosedDuration
def OpenGate(self):
#input is 0 or 1 for on and off
print('gatefunc')
self.serial_write('G=1')
print('openedgate')
def CloseGate(self):
self.serial_write('G=0')
def SetOpenDuration(self, input):
#input in ms
self.OpenDuration = input
input_string = 'OT' + str(input)
self.serial_write(input_string)
output = self.serial_read()
print(output)
def SetClosedDuration(self, input):
self.ClosedDuration = input
input_string = 'CT' + str(input)
self.serial_write(input_string)
def quick_open(self, duration):
(self.port).write((str(duration)+'\r\n').encode('ascii'))