# HG changeset patch # User Drew Perttula # Date 2017-06-10 03:11:57 # Node ID eccbc249fee7a7ea871ea2eb26d6f284a9df9dd2 # Parent a0fc6f957323e81a1f2a499ba61fef61cc109abf fix KC launch bug. log corrupt settings and move on. Ignore-this: 343e3a38e37b281cf807172f75aece87 diff --git a/bin/keyboardcomposer b/bin/keyboardcomposer --- a/bin/keyboardcomposer +++ b/bin/keyboardcomposer @@ -21,6 +21,7 @@ from light9.rdfdb import clientsession from light9.rdfdb.syncedgraph import SyncedGraph from light9.effect.sequencer import CodeWatcher import light9.effect.effecteval +from light9.effect.settings import DeviceSettings from bcf2000 import BCF2000 @@ -69,7 +70,7 @@ class SubmasterBox(tk.Frame): bg = self.graph.value(sub, L9.color, default='#000000') rgb = webcolors.hex_to_rgb(bg) hsv = colorsys.rgb_to_hsv(*[x/255 for x in rgb]) - darkBg = webcolors.rgb_to_hex(tuple([x * 255 for x in colorsys.hsv_to_rgb( + darkBg = webcolors.rgb_to_hex(tuple([int(x * 255) for x in colorsys.hsv_to_rgb( hsv[0], hsv[1], .2)])) tk.Frame.__init__(self, master, bd=1, relief='raised', bg=bg) self.name = self.graph.label(sub) @@ -457,14 +458,14 @@ class KeyboardComposer(tk.Frame, SubClie strength = graph.value(setting, L9['level']) if strength: now = time.time() - outputSettings.extend( + outputSettings.append( self.effectEval[effect].outputFromEffect( [(L9['strength'], strength)], songTime=now, # should be counting from when you bumped up from 0 noteTime=now)) - return outputSettings + return DeviceSettings.fromList(graph, outputSettings) def save_current_stage(self, subname): raise NotImplementedError diff --git a/light9/effect/effecteval.py b/light9/effect/effecteval.py --- a/light9/effect/effecteval.py +++ b/light9/effect/effecteval.py @@ -5,6 +5,7 @@ from webcolors import rgb_to_hex, hex_to from colorsys import hsv_to_rgb from decimal import Decimal import math +import traceback from noise import pnoise1 import logging import time @@ -71,16 +72,20 @@ class EffectEval(object): for effect in self.graph.subjects(RDF.type, L9['Effect']): settings = [] for setting in self.graph.objects(effect, L9['setting']): - d = self.graph.value(setting, L9['device']) - a = self.graph.value(setting, L9['deviceAttr']) - v = self.graph.value(setting, L9['value']) - sv = self.graph.value(setting, L9['scaledValue']) - if not (bool(v) ^ bool(sv)): - raise NotImplementedError - if d is None: - raise TypeError('no device on %s' % effect) - if a is None: - raise TypeError('no attr on %s' % effect) + try: + d = self.graph.value(setting, L9['device']) + a = self.graph.value(setting, L9['deviceAttr']) + v = self.graph.value(setting, L9['value']) + sv = self.graph.value(setting, L9['scaledValue']) + if not (bool(v) ^ bool(sv)): + raise NotImplementedError('no value for %s' % setting) + if d is None: + raise TypeError('no device on %s' % effect) + if a is None: + raise TypeError('no attr on %s' % effect) + except Exception: + traceback.print_exc() + continue settings.append((d, a, v if v is not None else sv, bool(sv)))