示例#1
0
 def _get_dead_coasting_effects(self):
     color = self.map_color(None, 1, 0)
     gobo = self.map_gobo(None, 1, 0)
     return {
         'color': Effect(color, color, 8),
         'gobo': Effect(gobo, gobo, 8),
     }
示例#2
0
    def map_pattern_size(self, trigger, value, threshold):
        shrink = True
        if threshold < 0:
            shrink = False
            threshold = -threshold

        if value >= threshold:
            # Instead of returning a new value, force an effect
            if shrink:
                eff = Effect(255, 0, 0.25)
            else:
                eff = Effect(0, 255, 0.25)
            self.add_effect('pattern_size', eff, overwrite=False)
    def _command_effect(self, s, *names, **props):
        lights = list(filter(lambda v: v.name in names,
                             self.lights)) if names else self.lights
        out = []
        for l in lights:
            if hasattr(l, 'add_effect'):
                for k, v in props.items():
                    # TODO: random
                    start = v['start']
                    if start == 'current':
                        start = l.state[k]

                    end = v.get('end')
                    if end == 'current':
                        end = l.state[k]

                    eff = Effect(start,
                                 end,
                                 v.get('duration', 0),
                                 done_value=v.get('done'),
                                 automation=False)
                    l.add_effect(k, eff, overwrite=v.get('overwrite', False))
                out.append({'light': l.name, 'result': True})

        self.send_command(s, 'OK', *out)
示例#4
0
 def map_strobe(self, trigger, value, threshold):
     return None
     # should set a high threshold for this
     if value > threshold and self.last_function['strobe'] + self.RATES.get(
             'strobe', 0) < time.time():
         # TODO: might need a different value for some lights
         self.add_effect('strobe', Effect(255, 255, 1, 0))
         # Because this is not applied normally...
         self.last_function['strobe'] = time.time()
示例#5
0
 def _get_dead_coasting_effects(self):
     return {
         'color':
         Effect((
             self.auto_state['red'],
             self.auto_state['green'],
             self.auto_state['blue'],
         ), self.map_color(None, 1, 0), 2)
     }
示例#6
0
    def map_color(self, trigger, value, threshold):
        if trigger == 'frequency_all':
            if not isinstance(value[0], list):
                # Raw bins
                bins_per = int(len(value) / 3)
                temp_value = []
                for offset in (0, bins_per, bins_per * 2):
                    bucket = []
                    for idx in range(offset, offset + bins_per):
                        bucket.append(value[idx])
                value = temp_value

            out = []
            colors = ('red', 'green', 'blue')
            for color, bins in zip(colors, value[:3]):
                newvalue = max(bins)
                if newvalue > threshold:
                    out.append(int(newvalue * 255))
                else:
                    out.append(0)
            if sum(out):
                # Try to create an effect to fade to the next color, always return something if there's data
                curr = (self.auto_state['red'], self.auto_state['green'],
                        self.auto_state['blue'])
                self.add_effect('color', Effect(curr, out, 0.25))
                # return curr
            return None

        if value < threshold:
            return

        if trigger == 'pitch':
            return int((value / 128) * 255), 0, 0

        old_rgb = [self.auto_state[k] for k in ('red', 'green', 'blue')]
        diff = 0
        while diff < 0.25:
            rgb = [random.randint(0, 256) for _ in range(3)]
            diff = sum((abs(rgb[i] - old_rgb[i]) / 256 for i in range(3))) / 3
        return rgb
示例#7
0
 def run(self, light, data):
     light.add_effect(
         'pattern',
         Effect(random.randint(0, 255), None, self.pattern_duration))
示例#8
0
 def apply(self, light, data):
     light.add_effect('dim',
                      Effect(light.auto_state['dim'], 0, self.dim_duration),
                      overwrite=True)
示例#9
0
 def run(self, light, data):
     light.add_effect(
         'pan', Effect(random.randint(0, 255), None, self.move_duration))
     light.add_effect(
         'tilt', Effect(random.randint(0, 255), None, self.move_duration))
示例#10
0
 def run(self, light, data):
     light.add_effect('pan', Effect(random.randint(0, 255), None, 8))
     light.add_effect('tilt', Effect(random.randint(0, 255), None, 8))
     if hasattr(light, '_get_dead_coasting_effects'):
         for k, e in light._get_dead_coasting_effects().items():
             light.add_effect(k, e)
示例#11
0
 def map_strobe(self, trigger, value, threshold):
     # should set a high threshold for this
     if value > threshold:
         # TODO: might need a different value for some lights
         if 'strobe' not in self.effects:
             self.effects['strobe'] = Effect(255, 255, 1, 0)