renamed stuff

added first gamma correction, closes #1
added db upgrade logic
This commit is contained in:
Giovanni Harting
2015-10-04 01:19:19 +02:00
parent ad009bd0d5
commit 1a568b194c
6 changed files with 80 additions and 29 deletions

View File

@@ -100,10 +100,17 @@ class Controller:
def __repr__(self):
return "<Controller stripes={} cid={}>".format(len(self.stripes), self.id)
def set_channel(self, channel, val):
self.bus.write_word_data(self._address, LED0_OFF_L + 4 * channel, int(val * 4095))
def set_channel(self, channel, val, gamma):
self.bus.write_word_data(self._address, LED0_OFF_L + 4 * channel, self.gamma_correct(gamma, int(val * 4095),
4095))
self.bus.write_word_data(self._address, LED0_ON_L + 4 * channel, 0)
@staticmethod
def gamma_correct(gamma, val, maxval):
corrected = int(pow(float(val) / float(maxval), float(gamma)) * float(maxval) + 0.5)
logging.getLogger(__name__).debug("GammaCorrect: in=%s out=%s, gamma=%s", val, corrected, gamma)
return corrected
def get_channel(self, channel):
return self.bus.read_word_data(self._address, LED0_OFF_L + 4 * channel) / 4095