Mercurial > code > home > repos > homeauto
comparison 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 |
comparison
equal
deleted
inserted
replaced
323:e2865f1034a9 | 324:d5dec124ccfe |
---|---|
444 assert statements[0][:2] == (self.uri, ROOM['brightness']) | 444 assert statements[0][:2] == (self.uri, ROOM['brightness']) |
445 self.value = float(statements[0][2]) | 445 self.value = float(statements[0][2]) |
446 self.fv.set(self.value) | 446 self.fv.set(self.value) |
447 | 447 |
448 def _setPwm(self, x): | 448 def _setPwm(self, x): |
449 v = int((x ** self.gamma)* 255) | 449 v = max(0, min(255, int((x ** self.gamma)* 255))) |
450 self.pi.set_PWM_dutycycle(self.pinNumber, v) | 450 self.pi.set_PWM_dutycycle(self.pinNumber, v) |
451 | 451 |
452 def hostStatements(self): | 452 def hostStatements(self): |
453 return [(self.uri, ROOM['brightness'], Literal(self.value))] | 453 return [(self.uri, ROOM['brightness'], Literal(self.value))] |
454 | 454 |