Changeset - eccbc249fee7
[Not reviewed]
default
0 2 0
Drew Perttula - 8 years ago 2017-06-10 03:11:57
drewp@bigasterisk.com
fix KC launch bug. log corrupt settings and move on.
Ignore-this: 343e3a38e37b281cf807172f75aece87
2 files changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
bin/keyboardcomposer
Show inline comments
 
@@ -18,12 +18,13 @@ from light9.uihelpers import toplevelat
 
from light9.namespaces import L9, RDF
 
from light9.tkdnd import initTkdnd, dragSourceRegister, dropTargetRegister
 
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
 

	
 
nudge_keys = {
 
    'up'   : list('qwertyui'),
 
    'down' : list('asdfghjk')
 
@@ -66,13 +67,13 @@ class SubmasterBox(tk.Frame):
 
        self.sub = sub
 
        self.session = session
 
        self.col, self.row = col, row
 
        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)
 
        self.slider_var = tk.DoubleVar()
 
        self.pauseTrace = False
 
        self.scale = SubScale(self, variable=self.slider_var, width=20)
 
@@ -454,20 +455,20 @@ class KeyboardComposer(tk.Frame, SubClie
 
        outputSettings = []
 
        for setting in graph.objects(self.session, L9['subSetting']):
 
            effect = graph.value(setting, L9['sub'])
 
            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
 
        log.info("saving current levels as %s", subname)
 
        with self.graph.currentState() as current:
 
            sub = self.get_levels_as_sub(graph=current)
light9/effect/effecteval.py
Show inline comments
 
@@ -2,12 +2,13 @@ from __future__ import division
 
from rdflib import URIRef, Literal
 
from light9.namespaces import L9, RDF, DEV
 
from webcolors import rgb_to_hex, hex_to_rgb
 
from colorsys import hsv_to_rgb
 
from decimal import Decimal
 
import math
 
import traceback
 
from noise import pnoise1
 
import logging
 
import time
 
from light9.effect.settings import DeviceSettings
 

	
 

	
 
@@ -68,22 +69,26 @@ class EffectEval(object):
 
            self.graph.addHandler(self.updateEffectsFromGraph)
 

	
 
    def updateEffectsFromGraph(self):
 
        for effect in self.graph.subjects(RDF.type, L9['Effect']):
 
            settings = []
 
            for setting in self.graph.objects(effect, L9['setting']):
 
                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
 
                        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)))
 

	
 
            if settings:
 
                self.effectOutputs[effect] = settings
 
            # also have to read eff :effectAttr [ :tint x; :tintStrength y ]
0 comments (0 inline, 0 general)