当前位置: 首页>>代码示例>>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;未经允许,请勿转载。