示例#1
0
def rainbow(i, wait=0.001, width=num_pixels):
    for j in range(num_pixels):
        x = int((j % width) * 256. / width)
        x = x + i & 255
        pixels[j] = utils.wheel(x)
    pixels.show()
    time.sleep(wait)
示例#2
0
    def run(self):
        self.neopixel.setBrightness(255)
        while self.loading:
            self.neopixel.setPixelColor(self.i, wheel(self.rainbow))
            self.neopixel.show()
            self.next()
            time.sleep(0.007)

        print("program ready")
示例#3
0
文件: modes.py 项目: joram/steps
def mode_solid_rainbow(key, pixels):
    h = 0
    while key == state_key():
        h = h % 255
        color = wheel(h)
        pixels.fill(color)
        pixels.show()
        time.sleep(0.01)
        h += 1
示例#4
0
 def note(self, freq):
     print(freq, self.a, self.b)
     if freq < self.b and freq > self.a:
         ri = int((freq - self.a) / self.wide * (255 - self.offset) +
                  self.offset)
         print(ri)
         self.npx.setPixelColor(self.index, wheel(ri))
         self.npx.show()
         self.increment()
示例#5
0
文件: modes.py 项目: joram/steps
def mode_sliding_circle_rainbow(key, pixels):
    h = 0
    while key == state_key():
        for i in range(0, pixels.n):
            hue = (h + i) % 255
            color = wheel(hue)
            set_pixel_circle(pixels, i, color)
        pixels.show()
        time.sleep(0.01)
        h += 1
示例#6
0
文件: modes.py 项目: joram/steps
def mode_halloween(key, pixels):
    red = {"r": 255, "g": 0, "b": 0}
    orange = {"r": 255, "g": 140, "b": 0}
    c1 = _color_tuple(red)
    c2 = _color_tuple(orange)
    i = 0
    delta = 1
    global halloween_mode
    global h
    global offset

    def start_rainbow():
        global halloween_mode
        halloween_mode = HalloweenModes.RAINBOW
        # post_message_to_lack("trick or treaters are here")
        global h
        global offset
        h = 0
        offset = 0
        post_message_to_lack("rainbow mode")

    register_button(start_rainbow)

    while key == state_key():
        if halloween_mode == HalloweenModes.WAITING:
            color = _color_between(c1, c2, float(i) / 100.0)
            pixels.fill(color)
            pixels.show()
            time.sleep(0.01)
            if i >= 100:
                delta = -1
            if i <= 0:
                delta = 1
            i += delta

        if halloween_mode == HalloweenModes.RAINBOW:
            for i in range(0, pixels.n):
                hue = (h + i) % 255
                color = wheel(hue)
                set_pixel_circle(pixels, i, color)
            pixels.show()
            time.sleep(0.01)
            h += 1
            if h >= 100:
                post_message_to_lack("nyancat mode")
                halloween_mode = HalloweenModes.NYANCAT

        if halloween_mode == HalloweenModes.NYANCAT:
            nyan_pixels = _nyan_pixels()
            num_cats = 8
            offset = offset % pixels.n
            pixels.fill((0, 0, 0))
            for i in range(0, num_cats):
                _set_pixels(offset + int(pixels.n / num_cats) * i, pixels,
                            nyan_pixels)
            pixels.show()
            time.sleep(0.01)
            offset += 1
            if offset >= 100:
                post_message_to_lack("waiting mode")
                halloween_mode = HalloweenModes.WAITING