aboutsummaryrefslogtreecommitdiff
path: root/behaviors/ExpandingColorZones.py
diff options
context:
space:
mode:
authorGravatar dan <dmtaub@gmail.com>2011-01-28 16:11:11 -0500
committerGravatar dan <dmtaub@gmail.com>2011-01-28 16:11:11 -0500
commitf017051f9b93c3a8ac435537c8c9c1f360d0702f (patch)
tree3f0a9e01ddcb87af2e1b016dd8489be572641ca0 /behaviors/ExpandingColorZones.py
parentfac2f8373cd0e63a34a39cb77c0c7276d1d88b65 (diff)
parenta7d6577e55ebd665ad9e4f45183836f11b3c6fd4 (diff)
Merge branch 'fridaydemo' of github.com:rcoh/SmootLight into osc
Diffstat (limited to 'behaviors/ExpandingColorZones.py')
-rw-r--r--behaviors/ExpandingColorZones.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/behaviors/ExpandingColorZones.py b/behaviors/ExpandingColorZones.py
new file mode 100644
index 0000000..345851e
--- /dev/null
+++ b/behaviors/ExpandingColorZones.py
@@ -0,0 +1,20 @@
+from operationscore.Behavior import *
+from logger import main_log
+class ExpandingColorZones(Behavior):
+ def behaviorInit(self):
+ self.mapping = {'r':[(132,0),(255,0,0)], 'g':[(400,0), (0,255,0)],
+ 'b':[(668,0),
+ (0,0,255)]}
+ self.mappingkey = 'KeyChar'
+ def processResponse(self, sensorInputs, recursiveInputs):
+ ret = []
+ for data in sensorInputs:
+ data = dict(data)
+ if self.mappingkey in data:
+ try:
+ data['Location'], data['Color'] =\
+ self.mapping[data[self.mappingkey]]
+ ret.append(data)
+ except:
+ main_log.warn('Bad mapping key. Expanding Color Zones.')
+ return (ret,[])