示例#1
0
	def __init__(self, hardware, global_brightness=AAPA102.MAX_BRIGHTNESS, order='rgb', bus=0, device=1, max_speed_hz=8000000, endFrame=255):
		super(APA102, self).__init__(hardware['numberOfLeds'])
		self._leds  = AAPA102(hardware['numberOfLeds'], global_brightness=global_brightness, order=order, bus=bus, device=device, max_speed_hz=max_speed_hz, endFrame=endFrame)

		try:
			self._power = LED(5)
		except:
			try:
				self._power = mraa.Gpio(5)
				self._power.dir(mraa.DIR_OUT)
			except Exception as e:
				self._logger.info('Device not using gpiozero or mraa, ignore power: {}'.format(e))

		self._hardware = hardware
		self._src = None
		if 'doa' in hardware and hardware['doa']:
			self._logger.info('Hardware is DOA capable')
			from libraries.seeedstudios.channel_picker import ChannelPicker
			from libraries.seeedstudios.source import Source

			lib = importlib.import_module('libraries.seeedstudios.' + hardware['doa'])
			klass = getattr(lib, 'DOA')

			self._src = Source(rate=hardware['rate'], channels=hardware['channels'])
			ch0 = ChannelPicker(channels=self._src.channels, pick=0)

			self._doa = klass(rate=hardware['rate'])
			self._src.link(ch0)
			self._src.link(self._doa)
    def __init__(self, hardware, vid, pid):
        self._hardware = hardware
        super(RespeakerMicArrayV2,
              self).__init__(self._hardware['numberOfLeds'])

        self._leds = pixel_ring.find(vid=int(vid, 16), pid=int(pid, 16))

        if self._leds is None:
            raise InterfaceInitError(
                'Respeaker Mic Array V2 not found using pid={} and vid={}'.
                format(pid, vid))

        self._colors = self._newArray()

        self._src = None
        if 'doa' in hardware and hardware['doa']:
            self._logger.info('Hardware is DOA capable')
            from libraries.seeedstudios.channel_picker import ChannelPicker
            from libraries.seeedstudios.source import Source

            lib = importlib.import_module('libraries.seeedstudios.' +
                                          hardware['doa'])
            klass = getattr(lib, 'DOA')

            self._src = Source(rate=hardware['rate'],
                               channels=hardware['channels'])
            ch0 = ChannelPicker(channels=self._src.channels, pick=0)

            self._doa = klass(rate=hardware['rate'])
            self._src.link(ch0)
            self._src.link(self._doa)