How to use the ledfx.events.DeviceUpdateEvent function in LedFx

To help you get started, weโ€™ve selected a few LedFx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ahodges9 / LedFx / ledfx / devices / __init__.py View on Github external
def thread_function(self):
        # TODO: Evaluate switching over to asyncio with UV loop optimization
        # instead of spinning a seperate thread.

        if self._active:
            self._ledfx.loop.call_later(1 / self._config['refresh_rate'],
                self.thread_function)

            # Assemble the frame if necessary, if nothing changed just sleep
            assembled_frame = self.assemble_frame()
            if assembled_frame is not None:
                if not self._config['preview_only']:
                    self.flush(assembled_frame)
                self._ledfx.events.fire_event(DeviceUpdateEvent(
                    self.id, assembled_frame))
github ahodges9 / LedFx / ledfx / devices / __init__.py View on Github external
def clear_effect(self):
        if self._active_effect != None:
            self._active_effect.deactivate()
            self._active_effect = None
        
        if self._active:
            # Clear all the pixel data before deactiving the device
            assembled_frame = np.zeros((self.pixel_count, 3))
            self.flush(assembled_frame)
            self._ledfx.events.fire_event(DeviceUpdateEvent(
                self.id, assembled_frame))

            self.deactivate()