Esempio n. 1
0
    def run(self):
        section_width = (self.upper_border -
                         self.lower_border) // self.highlight_sections
        target_led = random.randrange(self.lower_border, self.upper_border,
                                      section_width)
        frame_time = self.p['time_sec'] / (3 * self.highlight_sections
                                           )  # 3 for the three roundtrips

        # go round the strip one time
        for led in range(self.lower_border, self.upper_border + 1,
                         section_width):
            self.highlight(led, highlight_radius=section_width // 2)
            self.sleep(frame_time)
        for led in range(self.upper_border + 1, self.lower_border,
                         -section_width):
            self.highlight(led, highlight_radius=section_width // 2)
            self.sleep(frame_time)

        # focus on target
        for led in range(self.lower_border, target_led, section_width):
            self.highlight(led)
            relative_distance = abs(led - target_led) / self.strip.num_leds
            self.sleep(0.0006 * self.p['time_sec'] /
                       relative_distance)  # slow down a little
        self.highlight(target_led, highlight_radius=section_width // 2)

        if self.p['fadeout']:
            self.sleep(10)
            blend_whole_strip_to_color(
                self.strip, self.p['background_color'])  # fadeout the spot
Esempio n. 2
0
    def update(self, current_step: int, current_cycle: int) -> bool:
        if current_cycle == 0 and current_step == 0:
            blend_whole_strip_to_color(self.strip, self.p['color'])
        self.dir = (current_cycle % 2)
        pixel_color = self.p['color']
        highlight_color = self.p['highlight']
        if self.dir == 0:
            self.cpixel = current_step
        else:
            self.cpixel = (self.strip.num_leds - current_step)
        self.centerdistance = abs((self.strip.num_leds / 2) - self.cpixel)
        self.waitmodifier = self.expospeed(self.centerdistance)

        #Paint Wurst
        for led in range(self.cpixel - (self.p['radius'] // 2),
                         self.cpixel + (self.p['radius'] // 2) + 1):
            distance = abs(led - self.cpixel)
            dim_factor = (1 - (distance / self.p['radius']))**2
            color = linear_dim(highlight_color, dim_factor)
            self.strip.set_pixel(led, *color)

        #Clean Up b4 and after Wurst
        if current_step > 0 and current_step < self.strip.num_leds:  #Cleanup
            if self.dir == 0:
                self.strip.set_pixel(self.cpixel - (self.p['radius'] // 2) - 1,
                                     *pixel_color)
            else:
                self.strip.set_pixel(self.cpixel + (self.p['radius'] // 2) + 2,
                                     *pixel_color)
        #Velocity applied TBD dynamically through MQTT
        self.sleep(0.1 * self.waitmodifier)
        return True
Esempio n. 3
0
    def whole_blendover(self, num_cycles: int = 1):
        blendtime_sec = lambda: self.velocity
        pause_sec = lambda: 3 * self.velocity

        for _ in range(num_cycles):
            blend_whole_strip_to_color(self.strip, (255, 20, 10), fadetime_sec=blendtime_sec())
            self.sleep(pause_sec())
            blend_whole_strip_to_color(self.strip, (30, 255, 0), fadetime_sec=blendtime_sec())
            self.sleep(pause_sec())
Esempio n. 4
0
    def run(self):
        section_width = (self.upper_border - self.lower_border) // self.highlight_sections
        target_led = random.randrange(self.lower_border, self.upper_border, section_width)
        frame_time = self.p.value['time_sec'] / (3 * self.highlight_sections)  # 3 for the three roundtrips

        # go round the strip one time
        for led in range(self.lower_border, self.upper_border + 1, section_width):
            self.highlight(led, highlight_radius=section_width // 2)
            self.sleep(frame_time)
        for led in range(self.upper_border + 1, self.lower_border, -section_width):
            self.highlight(led, highlight_radius=section_width // 2)
            self.sleep(frame_time)

        # focus on target
        for led in range(self.lower_border, target_led, section_width):
            self.highlight(led)
            relative_distance = abs(led - target_led) / self.strip.num_leds
            self.sleep(0.0006 * self.p.value['time_sec'] / relative_distance)  # slow down a little
        self.highlight(target_led, highlight_radius=section_width // 2)

        if self.p.value['fadeout']:
            self.sleep(10)
            blend_whole_strip_to_color(self.strip, self.p.value['background_color'])  # fadeout the spot
Esempio n. 5
0
    def run(self):
        while True:
            # single leds
            blend_whole_strip_to_color(self.strip, (255, 0, 0), fadetime_sec=0)
            self.sleep(10)
            blend_whole_strip_to_color(self.strip, (0, 255, 0), fadetime_sec=0)
            self.sleep(10)
            blend_whole_strip_to_color(self.strip, (0, 0, 255), fadetime_sec=0)
            self.sleep(10)

            # all leds together
            blend_whole_strip_to_color(self.strip, (255, 255, 255), fadetime_sec=0)
            self.sleep(10)

            # clear strip
            self.strip.clear_strip()
            self.sleep(5)
Esempio n. 6
0
 def run(self):
     blend_whole_strip_to_color(self.strip, self.p['color'])
Esempio n. 7
0
 def run(self):
     blend_whole_strip_to_color(self.strip, (0, 0, 0), self.p.value['fadetime_sec'])  # fade out
     self.strip.clear_strip()
     self.strip.clear_strip()  # just to be sure
Esempio n. 8
0
 def run(self):
     blend_whole_strip_to_color(self.strip, self.p.value['color'])