當前位置: 首頁>>代碼示例>>Python>>正文


Python neopixel.NeoPixel方法代碼示例

本文整理匯總了Python中neopixel.NeoPixel方法的典型用法代碼示例。如果您正苦於以下問題:Python neopixel.NeoPixel方法的具體用法?Python neopixel.NeoPixel怎麽用?Python neopixel.NeoPixel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在neopixel的用法示例。


在下文中一共展示了neopixel.NeoPixel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def main():
    # Wemos D1 Mini NeoPixel Shield is on pin 4 (D2)
    pin = machine.Pin(4, machine.Pin.OUT)
    # There is just 1 Neopixel LED on Shield
    n = neopixel.NeoPixel(pin, 1)
    # Wemos D1 Mini DHT Shield is on pin 2 (D4)
    d = dht.DHT22(machine.Pin(2))

    while True:
        d.measure()
        h = d.humidity()
        print(h)

        if (h < 45):
            # RGB values
            n[0] = (127, 0, 0)
        else:
            n[0] = (0, 127, 0)
        
        # Write value to LEDs
        n.write()

        time.sleep(10) 
開發者ID:bechynsky,項目名稱:Micropython,代碼行數:25,代碼來源:hmeter.py

示例2: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self):
        self.PORT = board.D18
        self.NUM = 15
        self.NUMBASE = 5
        self.pixels = neopixel.NeoPixel(self.PORT, self.NUM)
        self.cols = [
            (255, 0, 0),
            (255, 63, 0),
            (255, 120, 0),
            (0, 255, 0),
            (0, 255, 255),
            (0, 0, 255),
            (255, 0, 255)
        ]
        self.col_neutral = (80, 80, 30)
        self.NUMCOLS = len(self.cols)
        self.mode = 1
        self.ORDER = neopixel.GRB
        self.num_pixels = self.NUM
        self.pixels.fill(self.col_neutral)
        self.drinkcolor = (0,0,0)
        self.thr = threading.Thread(target=self.mode3, args=())
        self.thr.start() 
開發者ID:H3c702,項目名稱:Hector9000,代碼行數:25,代碼來源:Simple_LED_Connector.py

示例3: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self):
        super().__init__()

        i2c = board.I2C()

        if i2c is not None:
            self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c)

        # NeoPixels
        self._neopixels = neopixel.NeoPixel(
            board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB
        )

        self._buttons = GamePad(
            digitalio.DigitalInOut(board.BUTTON_A),
            digitalio.DigitalInOut(board.BUTTON_B),
        ) 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_PyBadger,代碼行數:19,代碼來源:clue.py

示例4: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self):
        self.PORT = board.D18
        self.NUM = 15
        self.NUMBASE = 5
        self.pixels = neopixel.NeoPixel(self.PORT, self.NUM)
        self.cols = [
            (255, 0, 0),
            (255, 63, 0),
            (255, 120, 0),
            (0, 255, 0),
            (0, 255, 255),
            (0, 0, 255),
            (255, 0, 255)
        ]
        self.col_neutral = (80, 80, 30)
        self.NUMCOLS = len(self.cols)
        self.mode = 1
        self.ORDER = neopixel.GRB
        self.num_pixels = self.NUM
        self.pixels.fill(self.col_neutral)
        self.drinkcolor = (0,0,0) 
開發者ID:H3c702,項目名稱:Hector9000,代碼行數:23,代碼來源:LEDStripConnector.py

示例5: led_on

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def led_on(pin):
    if pin == 1:
        pixels = neopixel.NeoPixel(board.D12, 20)
    elif pin == 2:
        pixels = neopixel.NeoPixel(board.D18, 20)
    else:
        print("wrong id")
        return False
    pixels.fill((255, 255, 255))
    return True 
開發者ID:jeonghoonkang,項目名稱:BerePi,代碼行數:12,代碼來源:led_strip.py

示例6: led_off

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def led_off(pin):
    if pin == 1:
        pixels = neopixel.NeoPixel(board.D12, 20)
    elif pin == 2:
        pixels = neopixel.NeoPixel(board.D18, 20)
    else:
        return False
    pixels.fill((0, 0, 0))
    return True 
開發者ID:jeonghoonkang,項目名稱:BerePi,代碼行數:11,代碼來源:led_strip.py

示例7: led_color

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def led_color(pin, R=255,G=255,B=255):
    if pin == 1:
        pixels = neopixel.NeoPixel(board.D12, 20)
    elif pin == 2:
        pixels = neopixel.NeoPixel(board.D18, 20)
    else:
        return False
    pixels.fill((R, G, B))
    return True 
開發者ID:jeonghoonkang,項目名稱:BerePi,代碼行數:11,代碼來源:led_strip.py

示例8: neo_status

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def neo_status(self, value):
        """The status NeoPixel.

        :param value: The color to change the NeoPixel.

        """
        if self.neopix:
            self.neopix.fill(value) 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_PyPortal,代碼行數:10,代碼來源:adafruit_pyportal.py

示例9: __init_pixels

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init_pixels(self, leds):
        self.pin = leds[0]
        self.pixels = neopixel.NeoPixel(leds[0], leds[1], brightness=leds[2], auto_write=False,
                                   pixel_order=ORDER) 
開發者ID:sindar,項目名稱:pRodriguezAssistant,代碼行數:6,代碼來源:bender_backlight.py

示例10: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self, num_pixels=10, bytes_per_pixel=4, pinno=15):
        pin = Pin(pinno, Pin.OUT)
        self.np = NeoPixel(pin, num_pixels, bpp=bytes_per_pixel)
        self.bytes_per_pixel = bytes_per_pixel
        self.tuple_len = bytes_per_pixel+1 
開發者ID:mpi-sws-rse,項目名稱:thingflow-python,代碼行數:7,代碼來源:neopixel_writer.py

示例11: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self, config, pixel_pin):
        try:
            import neopixel

            self.neopixel = neopixel.NeoPixel(
                pixel_pin,
                config['num_pixels'],
                pixel_order=config['rgb_order'],
                auto_write=False,
            )
            if len(config['rgb_order']) == 4:
                self.rgbw = True
            self.num_pixels = const(config['num_pixels'])
            self.hue_step = const(config['hue_step'])
            self.sat_step = const(config['sat_step'])
            self.val_step = const(config['val_step'])
            self.hue = const(config['hue_default'])
            self.sat = const(config['sat_default'])
            self.val = const(config['val_default'])
            self.breathe_center = const(config['breathe_center'])
            self.knight_effect_length = const(config['knight_effect_length'])
            self.val_limit = const(config['val_limit'])
            self.animation_mode = config['animation_mode']
            self.animation_speed = const(config['animation_speed'])
            if 'user_animation' in config:
                print(config['user_animation'])
                self.user_animation = config['user_animation']

        except ImportError as e:
            print(e) 
開發者ID:KMKfw,項目名稱:kmk_firmware,代碼行數:32,代碼來源:rgb.py

示例12: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self, pin):
        self.np = NeoPixel(pin, 256)
        self.color = (0,0,8) 
開發者ID:shaoziyang,項目名稱:microbit-lib,代碼行數:5,代碼來源:neo16x16.py

示例13: __init__

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def __init__(self,pin):
        self.np=NeoPixel(pin,256) 
開發者ID:shaoziyang,項目名稱:microbit-lib,代碼行數:4,代碼來源:neo16x16_img.py

示例14: pixels

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def pixels(self):
        """Sequence-like object representing the ten NeoPixels around the outside
        of the Circuit Playground. Each pixel is at a certain index in the sequence
        as labeled below. Colors can be RGB hex like 0x110000 for red where each
        two digits are a color (0xRRGGBB) or a tuple like (17, 0, 0) where (R, G, B).
        Set the global brightness using any number from 0 to 1 to represent a
        percentage, i.e. 0.3 sets global brightness to 30%.

        See `neopixel.NeoPixel` for more info.

        .. image :: ../docs/_static/neopixel_numbering.jpg
          :alt: NeoPixel order diagram

        Here is an example that sets the first pixel green and the ninth red.

        To use with the Circuit Playground Express or Bluefruit:

        .. code-block:: python

          from adafruit_circuitplayground import cp

          cp.pixels.brightness = 0.3
          cp.pixels[0] = 0x00FF00
          cp.pixels[9] = (255, 0, 0)
        """
        return self._pixels 
開發者ID:adafruit,項目名稱:Adafruit_CircuitPython_CircuitPlayground,代碼行數:28,代碼來源:circuit_playground_base.py

示例15: setup_neopixels

# 需要導入模塊: import neopixel [as 別名]
# 或者: from neopixel import NeoPixel [as 別名]
def setup_neopixels(pin, count):
    global strip
    import neopixel
    strip = neopixel.NeoPixel(machine.Pin(pin), count)
    update_strip() 
開發者ID:davea,項目名稱:sonoff-mqtt,代碼行數:7,代碼來源:main.py


注:本文中的neopixel.NeoPixel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。