How to use the ledfx.utils.BaseRegistry 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 / effects / __init__.py View on Github external
return phi_x

def smooth(x, sigma):
    lw = int(4.0 * float(sigma) + 0.5)
    w = _gaussian_kernel1d(sigma, 0, lw)
    window_len = len(w)

    s = np.r_[x[window_len-1:0:-1],x,x[-1:-window_len:-1]]
    y = np.convolve(w/w.sum(),s,mode='valid')

    if window_len < len(x):
        return y[(window_len//2):-(window_len//2)]
    return y[0:len(x)]

@BaseRegistry.no_registration
class Effect(BaseRegistry):
    """
    Manages an effect
    """
    NAME = ""
    _pixels = None
    _dirty = False
    _config = None
    _active = False

    # Basic effect properties that can be applied to all effects
    CONFIG_SCHEMA = vol.Schema({
        vol.Optional('blur', description='Amount to blur the effect', default = 0.0): vol.Coerce(float),
        vol.Optional('flip', description='Flip the effect', default = False): bool,
        vol.Optional('mirror', description='Mirror the effect', default = False): bool,
    })
github ahodges9 / LedFx / ledfx / devices / __init__.py View on Github external
from abc import abstractmethod
from threading import Thread
from ledfx.events import DeviceUpdateEvent, Event
import voluptuous as vol
import numpy as np
import importlib
import pkgutil
import logging
import time
import os
import re

_LOGGER = logging.getLogger(__name__)

@BaseRegistry.no_registration
class Device(BaseRegistry):

    CONFIG_SCHEMA = vol.Schema({
        vol.Required('name', description='Friendly name for the device'): str,
        vol.Optional('max_brightness', description='Max brightness for the device', default=1.0): vol.All(vol.Coerce(float), vol.Range(min=0, max=1)),
        vol.Optional('refresh_rate', description='Rate that pixels are sent to the device', default=60): int,
        vol.Optional('force_refresh', description='Force the device to always refresh', default=False): bool,
        vol.Optional('preview_only', description='Preview the pixels without updating the device', default=False): bool
    })

    _active = False
    _output_thread = None
    _active_effect = None

    def __init__(self, ledfx, config):
        self._ledfx = ledfx
        self._config = config
github ahodges9 / LedFx / ledfx / devices / __init__.py View on Github external
from ledfx.utils import BaseRegistry, RegistryLoader
from abc import abstractmethod
from threading import Thread
from ledfx.events import DeviceUpdateEvent, Event
import voluptuous as vol
import numpy as np
import importlib
import pkgutil
import logging
import time
import os
import re

_LOGGER = logging.getLogger(__name__)

@BaseRegistry.no_registration
class Device(BaseRegistry):

    CONFIG_SCHEMA = vol.Schema({
        vol.Required('name', description='Friendly name for the device'): str,
        vol.Optional('max_brightness', description='Max brightness for the device', default=1.0): vol.All(vol.Coerce(float), vol.Range(min=0, max=1)),
        vol.Optional('refresh_rate', description='Rate that pixels are sent to the device', default=60): int,
        vol.Optional('force_refresh', description='Force the device to always refresh', default=False): bool,
        vol.Optional('preview_only', description='Preview the pixels without updating the device', default=False): bool
    })

    _active = False
    _output_thread = None
    _active_effect = None

    def __init__(self, ledfx, config):
        self._ledfx = ledfx
github ahodges9 / LedFx / ledfx / effects / __init__.py View on Github external
phi_x *= q(x)
    return phi_x

def smooth(x, sigma):
    lw = int(4.0 * float(sigma) + 0.5)
    w = _gaussian_kernel1d(sigma, 0, lw)
    window_len = len(w)

    s = np.r_[x[window_len-1:0:-1],x,x[-1:-window_len:-1]]
    y = np.convolve(w/w.sum(),s,mode='valid')

    if window_len < len(x):
        return y[(window_len//2):-(window_len//2)]
    return y[0:len(x)]

@BaseRegistry.no_registration
class Effect(BaseRegistry):
    """
    Manages an effect
    """
    NAME = ""
    _pixels = None
    _dirty = False
    _config = None
    _active = False

    # Basic effect properties that can be applied to all effects
    CONFIG_SCHEMA = vol.Schema({
        vol.Optional('blur', description='Amount to blur the effect', default = 0.0): vol.Coerce(float),
        vol.Optional('flip', description='Flip the effect', default = False): bool,
        vol.Optional('mirror', description='Mirror the effect', default = False): bool,
    })
github ahodges9 / LedFx / ledfx / api / __init__.py View on Github external
from ledfx.utils import BaseRegistry, RegistryLoader
from aiohttp import web
import logging
import inspect
import json

@BaseRegistry.no_registration
class RestEndpoint(BaseRegistry):

    def __init__(self, ledfx):
        self._ledfx = ledfx

    async def handler(self, request: web.Request):
        method = getattr(self, request.method.lower(), None)
        if not method:
            raise web.HTTPMethodNotAllowed('')

        wanted_args = list(inspect.signature(method).parameters.keys())
        available_args = request.match_info.copy()
        available_args.update({'request': request})

        unsatisfied_args = set(wanted_args) - set(available_args.keys())
        if unsatisfied_args:
github ahodges9 / LedFx / ledfx / api / __init__.py View on Github external
from ledfx.utils import BaseRegistry, RegistryLoader
from aiohttp import web
import logging
import inspect
import json

@BaseRegistry.no_registration
class RestEndpoint(BaseRegistry):

    def __init__(self, ledfx):
        self._ledfx = ledfx

    async def handler(self, request: web.Request):
        method = getattr(self, request.method.lower(), None)
        if not method:
            raise web.HTTPMethodNotAllowed('')

        wanted_args = list(inspect.signature(method).parameters.keys())
        available_args = request.match_info.copy()
        available_args.update({'request': request})

        unsatisfied_args = set(wanted_args) - set(available_args.keys())
        if unsatisfied_args:
            raise web.HttpBadRequest('')