Skip to content
Snippets Groups Projects
Select Git revision
  • 0f3c325ad6fb23a7436974aaab1c20c18d94d020
  • master default protected
  • Stormwind
  • patch-1
  • schneider/bsec
  • dx/meh-bdf-to-stm
  • dx/somewhat-more-dynamic-config
  • rahix/proper-sleep
  • dx/flatten-config-module
  • genofire/ble-follow-py
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • v1.12
  • v1.11
  • v1.10
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
37 results

gen-modules.py

Blame
  • Forked from card10 / 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)