def __init__(self): self._logger = Log.get('uchroma.power') self._name_watchers = [] self._running = False self._sleeping = False self._session_bus = SessionBus() self._system_bus = SystemBus() self._dm = UChromaDeviceManager() #singleton
def __init__(self, width: int, height: int, logger=None): self._width = width self._height = height if logger is None: self._logger = Log.get('uchroma.frame') else: self._logger = logger self._matrix = np.zeros(shape=(self._height, self._width, 4), dtype=np.float) self._bg_color = None self._blend_mode = BlendOp.screen self._opacity = 1.0
def __init__(self, hardware: Hardware, devinfo: hidapi.DeviceInfo, index: int, sys_path: str, input_devices=None, *args, **kwargs): self._hardware = hardware self._devinfo = devinfo self._devindex = index self._sys_path = sys_path self.logger = Log.get('uchroma.driver-%d' % index) # needed for mixins super(BaseUChromaDevice, self).__init__(*args, **kwargs) self._dev = None self._serial_number = None self._firmware_version = None self._last_cmd_time = None self._prefs = None self._offline = False self._suspended = False self.power_state_changed = Signal() self.restore_prefs = Signal() self._input_manager = None if input_devices is not None: self._input_manager = InputManager(self, input_devices) self._animation_manager = None if self.width > 0 and self.height > 0: self._animation_manager = AnimationManager(self) self._brightness_animator = ValueAnimator(self._update_brightness) self._fx_manager = None self._ref_count = 0 self._executor = futures.ThreadPoolExecutor(max_workers=1)
def __init__(self, *callbacks): self._logger = Log.get('uchroma.devicemanager') self._devices = OrderedDict() self._monitor = False self._udev_context = Context() self._udev_observer = None self._callbacks = [] if callbacks is not None: self._callbacks.extend(callbacks) self._loop = asyncio.get_event_loop() self.device_added = Signal() self.device_removed = Signal() self.discover()
def __init__(self, driver, *args, **kwargs): self._avail_q = asyncio.Queue(maxsize=NUM_BUFFERS) self._active_q = asyncio.Queue(maxsize=NUM_BUFFERS) self.running = False self.width = driver.width self.height = driver.height self._tick = Ticker(1 / DEFAULT_FPS) self._input_queue = None if hasattr(driver, 'input_manager') and driver.input_manager is not None: self._input_queue = InputQueue(driver) self._logger = Log.get('uchroma.%s.%d' % (self.__class__.__name__, self.zindex)) super(Renderer, self).__init__(*args, **kwargs)
def __init__(self): gbulb.install() parser = argparse.ArgumentParser(description='UChroma daemon') parser.add_argument('-v', "--version", action='version', version='self.version') parser.add_argument('-d', "--debug", action='append_const', const=True, help="Increase logging verbosity") parser.add_argument('-C', "--colorlog", action='store_true', help="Use colored log output") args = parser.parse_args() self._loop = asyncio.get_event_loop() level = logging.INFO asyncio_debug = False colorlog = False if args.colorlog is not None: colorlog = args.colorlog Log.enable_color(colorlog) self._logger = Log.get('uchroma.server') if args.debug is not None: if len(args.debug) > 2: level = LOG_PROTOCOL_TRACE asyncio_debug = True elif len(args.debug) == 2: level = LOG_TRACE asyncio_debug = True elif len(args.debug) == 1: level = logging.DEBUG logging.getLogger().setLevel(level) self._loop.set_debug(asyncio_debug)
def _z_changed(self, change): if change.old == change.new and change.new >= 0: return self._logger = Log.get('uchroma.%s.%d' % (self.__class__.__name__, change.new))
from traitlets import HasTraits, TraitType, Undefined, UseEnum from frozendict import frozendict from grapefruit import Color import numpy as np from uchroma.log import Log from uchroma.traits import class_traits_as_dict, ColorTrait, \ ColorSchemeTrait, trait_as_dict from uchroma.util import camel_to_snake, snake_to_camel ArgSpec = NamedTuple('ArgSpec', [('direction', str), ('name', str), ('type', str)]) logger = Log.get('uchroma.util') def _check_variance(items: list): if len(items) == 0: return True if len(items) == 1: return False first_sig = dbus_prepare(items[0])[1] return not all(dbus_prepare(x)[1] == first_sig for x in items) def dbus_prepare(obj,