renamed stuff
added first gamma correction, closes #1 added db upgrade logic
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user