Skip to content
Snippets Groups Projects
Select Git revision
  • a4e33f39f3f26859f83a8f10941851e0c0353504
  • main default protected
  • phhw
  • captouch-threshold
  • t
  • dos
  • test2
  • test
  • slewtest
  • simtest
  • view-think
  • vm-pending
  • media-buf
  • scope
  • passthrough
  • wave
  • vsync
  • dos-main-patch-50543
  • json-error
  • rahix/big-flow3r
  • pippin/media_framework
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
34 results

application.py

Blame
  • Forked from flow3r / flow3r firmware
    Source project has a limited visibility.
    neopixel.py 840 B
    # NeoPixel driver for MicroPython on ESP8266
    # MIT license; Copyright (c) 2016 Damien P. George
    
    from esp import neopixel_write
    
    class NeoPixel:
        def __init__(self, pin, n):
            self.pin = pin
            self.n = n
            self.buf = bytearray(n * 3)
            self.pin.init(pin.OUT)
    
        def __setitem__(self, index, val):
            r, g, b = val
            self.buf[index * 3] = g
            self.buf[index * 3 + 1] = r
            self.buf[index * 3 + 2] = b
    
        def __getitem__(self, index):
            i = index * 3
            return self.buf[i + 1], self.buf[i], self.buf[i + 2]
    
        def fill(self, color):
            r, g, b = color
            for i in range(len(self.buf) / 3):
                self.buf[i * 3] = g
                self.buf[i * 3 + 1] = r
                self.buf[i * 3 + 2] = b
    
        def write(self):
            neopixel_write(self.pin, self.buf, True)