diff service/piNode/devices.py @ 324:d5dec124ccfe

clamp led brightness Ignore-this: 7bd6777e794fec977b09f0052939ed4f
author drewp@bigasterisk.com
date Mon, 15 Jan 2018 03:00:26 -0800
parents f420207c7fb4
children a94f2a522d41
line wrap: on
line diff
--- a/service/piNode/devices.py	Mon Jan 15 02:59:52 2018 -0800
+++ b/service/piNode/devices.py	Mon Jan 15 03:00:26 2018 -0800
@@ -446,7 +446,7 @@
         self.fv.set(self.value)
 
     def _setPwm(self, x):
-        v = int((x ** self.gamma)* 255)
+        v = max(0, min(255, int((x ** self.gamma)* 255)))
         self.pi.set_PWM_dutycycle(self.pinNumber, v)
 
     def hostStatements(self):