diff options
author | Dan <dan@rcoh-ubuntu-small.(none)> | 2011-01-25 00:33:46 -0500 |
---|---|---|
committer | Dan <dan@rcoh-ubuntu-small.(none)> | 2011-01-25 00:33:46 -0500 |
commit | eaaef5460a95d2de1dddc847f6c3bbcb2aef8047 (patch) | |
tree | 004f6e326959cb5d6bfcf0793686dab74260a3db /behaviors | |
parent | 2019fb2895237aa9d86450daaf6d90831189fc13 (diff) |
Adding an OSC input.
Diffstat (limited to 'behaviors')
-rw-r--r-- | behaviors/DebugBehavior.py | 2 | ||||
-rw-r--r-- | behaviors/MrmrSetColor.py | 21 | ||||
-rw-r--r-- | behaviors/Square.py | 15 |
3 files changed, 30 insertions, 8 deletions
diff --git a/behaviors/DebugBehavior.py b/behaviors/DebugBehavior.py index 34f4106..17383db 100644 --- a/behaviors/DebugBehavior.py +++ b/behaviors/DebugBehavior.py @@ -4,5 +4,5 @@ import pdb class DebugBehavior(Behavior): def processResponse(self, sensorInputs, recursiveInputs): if sensorInputs != []: - main_log.debug('Sensor Inputs: ' + str(sensorInputs)) + main_log.error('Sensor Inputs: ' + str(sensorInputs)) return ([], []) diff --git a/behaviors/MrmrSetColor.py b/behaviors/MrmrSetColor.py new file mode 100644 index 0000000..97b9fb7 --- /dev/null +++ b/behaviors/MrmrSetColor.py @@ -0,0 +1,21 @@ +from operationscore.Behavior import * +from logger import main_log +#import util.ColorOps as color +import colorsys +import pdb +class MrmrSetColor(Behavior): + def behaviorInit(self): + self.h=0 + self.s=0 + self.v=0 + def processResponse(self, sensorInputs, recursiveInputs): + ret = [] + for data in sensorInputs: + if data['Path'].find('horizontal') != -1: + self.h = data['Value'] / 2.78 + elif data['Path'].find('vertical') != -1: + self.s = data['Value'] / 1000.0 + else: + main_log.error('Sensor Inputs: ' + str(sensorInputs)) + ret.append({'Color':[i*255 for i in colorsys.hsv_to_rgb(self.h,self.s,self.v)]}) + return (ret, []) diff --git a/behaviors/Square.py b/behaviors/Square.py index aef3622..ecd000c 100644 --- a/behaviors/Square.py +++ b/behaviors/Square.py @@ -2,11 +2,12 @@ from operationscore.Behavior import * class Square(Behavior): def processResponse(self, sensorInputs, recursiveInputs): for sensory in sensorInputs:#TODO: consider replicating the dict - xLoc = sensory['Location'][0] - yLoc = sensory['Location'][1] - width = self['Width'] - #sensory['Location'] = 'True' - sensory['Location'] =\ - '{x}<'+str(xLoc+width)+',{x}>'+str(xLoc-width)+\ - ',{y}<'+str(yLoc+width)+',{y}>'+str(yLoc-width) + if 'Location' in sensory: + xLoc = sensory['Location'][0] + yLoc = sensory['Location'][1] + width = self['Width'] + #sensory['Location'] = 'True' + sensory['Location'] =\ + '{x}<'+str(xLoc+width)+',{x}>'+str(xLoc-width)+\ + ',{y}<'+str(yLoc+width)+',{y}>'+str(yLoc-width) return (sensorInputs, recursiveInputs) |