-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainLogicController.py
52 lines (41 loc) · 1.36 KB
/
MainLogicController.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import DataBaseControllerFile
from DataBaseControllerFile import DatabaseController
import ServoControllerFile
from ServoControllerFile import ServoController
import time
dutyCycleFullRight = 3
dutyCycleFullLeft = 15
dutyCycleTDC = 8
dbController = DatabaseController()
servoController = ServoController(dutyCycleTDC)
def incrementAmount():
currentValue = dbController.selectValue()
if currentValue < dutyCycleFullLeft:
currentValue += 1
dbController.updateValue(currentValue)
def resetAmount():
return dutyCycleTDC
def decrementAmount():
currentValue = dbController.selectValue()
if currentValue > dutyCycleFullRight:
currentValue -= 1
dbController.updateValue(currentValue)
def myCallBack(channel, increment):
print "Edge detected on channel ", channel
if increment == 'up':
print "increment up"
incrementAmount()
#updateServoPosition(value)
elif increment == 'down':
print "increment down"
decrementAmount()
#updateServoPosition(value)
else:
print "reset servo"
value = resetAmount()
dbController.updateValue(value)
#updateServoPosition(value)
def updateServoPosition(currentValue):
#currentValue = dbController.selectValue()
servoController.setServoToPosition(currentValue)