Exemple #1
0
 def __init__(self,
              leds=[32, 8],
              pin=18,
              channel=0,
              freq_hz=800000,
              dma=5,
              invert=False,
              brightness=255,
              type_=ws.WS2811_STRIP_GRB):
     self._leds = ws.new_ws2811_t()
     for cn in range(2):
         c = ws.ws2811_channel_get(self._leds, cn)
         ws.ws2811_channel_t_count_set(c, 0)
         ws.ws2811_channel_t_gpionum_set(c, 0)
         ws.ws2811_channel_t_invert_set(c, 0)
         ws.ws2811_channel_t_brightness_set(c, 0)
     self._ch = ws.ws2811_channel_get(self._leds, channel)
     ws.ws2811_channel_t_count_set(self._ch, leds[0] * leds[1])
     ws.ws2811_channel_t_gpionum_set(self._ch, pin)
     ws.ws2811_channel_t_invert_set(self._ch, (0 if invert == False else 1))
     ws.ws2811_channel_t_brightness_set(self._ch, brightness)
     ws.ws2811_channel_t_strip_type_set(self._ch, type_)
     ws.ws2811_t_freq_set(self._leds, freq_hz)
     ws.ws2811_t_dmanum_set(self._leds, dma)
     self.data = LED_Data(self._ch, leds)
     atexit.register(self._c)
     r = ws.ws2811_init(self._leds)
     if (r != ws.WS2811_SUCCESS):
         raise RuntimeError(ws.ws2811_get_return_t_str(r))
Exemple #2
0
	def begin(self):
		"""Initialize library, must be called once before other functions are
		called.
		"""
		resp = ws.ws2811_init(self._leds)
		if resp != ws.WS2811_SUCCESS:
			message = ws.ws2811_get_return_t_str(resp)
			raise RuntimeError('ws2811_init failed with code {0} ({1})'.format(resp, message))