當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。