changeset 1094:90bf3f11fc2b

gamma curve on led output Ignore-this: 338721a341a37881375d99c5a113f9e2 darcs-hash:5524f8c883a11b9ae1b1b52bb18828fce88ed416
author drewp <drewp@bigasterisk.com>
date Wed, 11 May 2016 21:45:11 -0700
parents e3ae71fbd3bd
children 870d1bbae402
files service/piNode/config/main.n3 service/piNode/devices.py
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/service/piNode/config/main.n3	Mon May 09 01:05:24 2016 -0700
+++ b/service/piNode/config/main.n3	Wed May 11 21:45:11 2016 -0700
@@ -46,7 +46,7 @@
   :blueChannel board2pin:GPIO4 .
     
 board2pin:GPIO27 :connectedTo :headboardWhite .
-:headboardWhite a :LedOutput .
+:headboardWhite a :LedOutput ; :gamma 2 .
   
 #board2pin:b29 :connectedTo board2ow: .
 #board2ow: a :OneWire;
--- a/service/piNode/devices.py	Mon May 09 01:05:24 2016 -0700
+++ b/service/piNode/devices.py	Wed May 11 21:45:11 2016 -0700
@@ -400,6 +400,7 @@
     def hostStateInit(self):
         self.value = 0
         self.fv = FilteredValue(self._setPwm)
+        self.gamma = float(self.graph.value(self.uri, ROOM['gamma'], default=1))
     
     def setup(self):
         setupPwm(self.pi, self.pinNumber)
@@ -414,7 +415,7 @@
         self.fv.set(self.value)
 
     def _setPwm(self, x):
-        v = int(x * 255)
+        v = int((x ** self.gamma)* 255)
         self.pi.set_PWM_dutycycle(self.pinNumber, v)
 
     def hostStatements(self):