-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoftKeys.py
134 lines (90 loc) · 3.57 KB
/
SoftKeys.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from AmiTree import *
from PlugIn import PlugIn
from CommunicationEngine import CommunicationEngine
from amiConfig import Config
from ctypes import cdll, c_int
from EventEngine import EventEngine
from Address import Address
import time
class SoftKeys(PlugIn):
def __init__(self, token, configFile):
PlugIn.__init__(self)
self.architecture = "all"
#plugin itself
self.content = avrContainer("plugin", token, "This hopefully will be a Threaded SoftKey Plugin")
self.content.name = "softKeyThread"
self.content.start()
# Functions of the Plugin
def getBuddies(self, text=""):
string = ""
for elem in CommunicationEngine.roster.getItems():
string += elem+"\n"
return string
# returns the plugin as a tree
def getTree(self):
return self.content
# just a little helper function
def getText(self, var):
try:
var = var.strings["text"]
return test
except:
return var
class avrContainer(ThreadContainer):
def __init__(self, type, token, information="empty"):
ThreadContainer.__init__(self, type, token, information="empty")
self.information = "hehehehe, arschloch"
self.lastval = 0
##
# Hardware Initialization
##
lib="/root/libavrBridgeC.so"
self.mega=cdll.LoadLibrary(lib)
self.mega.initUsbLib()
# init poti
self.mega.setPortPinDir(1,1,0)
self.mega.setPortPin(1,1,1)
# set pins input
self.mega.setPortPinDir(0,0,0)
self.mega.setPortPinDir(0,1,0)
self.mega.setPortPinDir(0,2,0)
# enable internal pullup
self.mega.setPortPin(0,0,1)
self.mega.setPortPin(0,1,1)
self.mega.setPortPin(0,2,1)
#LED output
self.mega.setPortPinDir(2,7,1)
# light up the led
self.mega.setPortPin(2,7,1)
def run(self):
while True:
#get value from poti
val = self.mega.getAdcPortPin(1, 1)
val = (val-30)/738.*100
#print str(int(val)),
#print self.mega.getPortPin(0, 0),
#print self.mega.getPortPin(0, 1),
#print self.mega.getPortPin(0, 2)
if self.mega.getPortPin(0,0) == 0:
self.mega.setPortPin(2,7,1)
address = Address("/Defaults/Play")
EventEngine.root.getByAddress(address.__str__()).use("http://www.mondayjazz.com/mixes/mj099_now_just_listen_by_dj_blueprint.mp3")
time.sleep(.5)
if self.mega.getPortPin(0,1) == 0:
self.mega.setPortPin(2,7,0)
address = Address("/Defaults/Stop")
EventEngine.root.getByAddress(address.__str__()).use()
time.sleep(.5)
if self.mega.getPortPin(0,2) == 0:
address = Address("/Defaults/Stop")
EventEngine.root.getByAddress(address.__str__()).use()
address = Address("/FeedReader/Random")
EventEngine.root.getByAddress(address.__str__()).use()
time.sleep(.5)
#if not str(int(self.lastval)).__eq__(str(int(val))):
# print "Default Volume"+str(val)+", "+str(int(self.lastval))+", "+str(int(val))
# address = Address("/Defaults/SetVol")
# print EventEngine.root.getByAddress(address.__str__())
# EventEngine.root.getByAddress(address.__str__()).use(val)
# self.lastval = val
time.sleep(.3)