当前位置: 首页>>代码示例>>Python>>正文


Python neopixel.Adafruit_NeoPixel方法代码示例

本文整理汇总了Python中neopixel.Adafruit_NeoPixel方法的典型用法代码示例。如果您正苦于以下问题:Python neopixel.Adafruit_NeoPixel方法的具体用法?Python neopixel.Adafruit_NeoPixel怎么用?Python neopixel.Adafruit_NeoPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neopixel的用法示例。


在下文中一共展示了neopixel.Adafruit_NeoPixel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_demo

# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import Adafruit_NeoPixel [as 别名]
def run_demo(strip: neopixel.Adafruit_NeoPixel, led_queue: mp.Queue):
    for demo in (chase_loop, spinning_loop, rings_loop, random_loop):
        print("demo: {}".format(demo))
        p = mp.Process(target=demo, kwargs={"strip": strip, })
        p.start()
        sleep(5)  # show each demo for 5s
        while True:
            # get messages, ignore satellite updates that might still be in the queue
            try:
                m = led_queue.get_nowait()
                if m == "BUTTON":  # if the button is pressed we stay in the demo
                    while True:
                        m = led_queue.get()
                        if m == "BUTTON":  # if the button is pressed again we exit
                            p.terminate()
                            return
            except queue.Empty:
                # if there was no button press move on to the next demo
                p.terminate()
                break 
开发者ID:PaulKlinger,项目名称:satellite_tracker,代码行数:22,代码来源:main.py

示例2: __init__

# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import Adafruit_NeoPixel [as 别名]
def __init__(
            self, num, gamma=gamma.NEOPIXEL, c_order="RGB", gpio=18,
            ledFreqHz=800000, ledDma=5, ledInvert=False,
            color_channels=3, brightness=255, **kwds):

        if not NeoColor:
            raise ValueError(WS_ERROR)
        super().__init__(num, c_order=c_order, gamma=gamma, **kwds)
        self.gamma = gamma
        if gpio not in PIN_CHANNEL.keys():
            raise ValueError('{} is not a valid gpio option!')
        try:
            strip_type = STRIP_TYPES[color_channels]
        except:
            raise ValueError('In PiWS281X, color_channels can only be 3 or 4')

        self._strip = Adafruit_NeoPixel(
            num, gpio, ledFreqHz, ledDma, ledInvert, brightness,
            PIN_CHANNEL[gpio], strip_type)
        # Intialize the library (must be called once before other functions).
        try:
            self._strip.begin()
        except RuntimeError as e:
            if os.geteuid():
                if os.path.basename(sys.argv[0]) in ('bp', 'bibliopixel'):
                    command = ['bp'] + sys.argv[1:]
                else:
                    command = ['python'] + sys.argv
                error = SUDO_ERROR.format(command=' '.join(command))
                e.args = (error,) + e.args
            raise 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:33,代码来源:PiWS281X.py

示例3: led_strip_from_constants

# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import Adafruit_NeoPixel [as 别名]
def led_strip_from_constants():
    return neopixel.Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA,
                                      LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL,
                                      strip_type=neopixel.ws.WS2811_STRIP_GRB) 
开发者ID:PaulKlinger,项目名称:satellite_tracker,代码行数:6,代码来源:main.py

示例4: __init__

# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import Adafruit_NeoPixel [as 别名]
def __init__(self, n_pixels, pin=18, invert_logic=False,
                 freq=800000, dma=5):
        """Creates a Raspberry Pi output device
        Parameters
        ----------
        n_pixels: int
            Number of LED strip pixels
        pin: int, optional
            GPIO pin used to drive the LED strip (must be a PWM pin).
            Pin 18 can be used on the Raspberry Pi 2.
        invert_logic: bool, optional
            Whether or not to invert the driving logic.
            Set this to True if you are using an inverting logic level
            converter, otherwise set to False.
        freq: int, optional
            LED strip protocol frequency (Hz). For ws2812 this is 800000.
        dma: int, optional
            DMA (direct memory access) channel used to drive PWM signals.
            If you aren't sure, try 5.
        """
        try:
            import neopixel
        except ImportError as e:
            url = 'learn.adafruit.com/neopixels-on-raspberry-pi/software'
            print('Could not import the neopixel library')
            print('For installation instructions, see {}'.format(url))
            raise e
        self.strip = neopixel.Adafruit_NeoPixel(n_pixels, pin, freq, dma,
                                                invert_logic, 255)
        self.strip.begin() 
开发者ID:not-matt,项目名称:Systematic-LEDs,代码行数:32,代码来源:devices.py

示例5: __init__

# 需要导入模块: import neopixel [as 别名]
# 或者: from neopixel import Adafruit_NeoPixel [as 别名]
def __init__(self, width = 16, height = 16, led_pin = 18, led_freq_hz = 800000, led_dma = 5, led_invert = False, led_brightness = 200):
		super(Screen, self).__init__(width, height)
		import neopixel
		
		self.strip = neopixel.Adafruit_NeoPixel(width * height, led_pin, led_freq_hz, led_dma, led_invert, led_brightness)
		self.strip.begin()
		self.update_brightness()
		
		global instance
		instance = self 
开发者ID:marian42,项目名称:pixelpi,代码行数:12,代码来源:screen.py


注:本文中的neopixel.Adafruit_NeoPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。