def run_demo(self): self._check_reqs() from time import sleep import volux import voluxaudio # create Volux Operator object (hub for communication between modules) vlx = volux.VoluxOperator() vlx.add_module(voluxaudio.VoluxAudio()) vlx.add_module(volux.VoluxCliPrint()) vlx.add_connection(volux.VoluxConnection(vlx.audio, vlx.cli, 60)) try: while True: vlx.start_sync() sleep(10) vlx.stop_sync() print("Ctrl+C to exit demo at any time") sleep(4) except KeyboardInterrupt: print("exiting...") finally: vlx.stop_sync() exit()
def run_demo(self): self._check_reqs() import volux import voluxaudio import voluxlight import voluxlightvisualiser as vvis script_hz = 240 device_label = str( input("LIFX device's label (case-sensitive!) [Strip]: ") ) if device_label == "": device_label = "Strip" vlx = volux.VoluxOperator() audio_UUID = vlx.add_module(voluxaudio.VoluxAudio()) lstrip_UUID = vlx.add_module( voluxlight.VoluxLight( instance_label="demo", init_mode="device", init_mode_args={"label": device_label}, ) ) vis_UUID = vlx.add_module( vvis.VoluxLightVisualiser( mode="intense", hueHz=script_hz, hue_cycle_duration=5 ) ) vlx.add_connection( volux.VoluxConnection( vlx.modules[audio_UUID], vlx.modules[vis_UUID], script_hz ) ) vlx.add_connection( volux.VoluxConnection( vlx.modules[vis_UUID], vlx.modules[lstrip_UUID], script_hz ) ) try: vlx.modules[lstrip_UUID].prepare() vlx.start_sync() input("press [Enter] to stop...") except KeyboardInterrupt: print("Exit signal sent!") finally: vlx.stop_sync() vlx.modules[lstrip_UUID].restore()
def run_demo(self): self._check_reqs() import volux import voluxbar import voluxlight import voluxvolume import colorama device_label = str( input("LIFX device's label (case-sensitive!) [Demo Bulb]: ")) if device_label == "": device_label = "Demo Bulb" # create Volux Operator object (hub for communication between modules) vlx = volux.VoluxOperator() vlx.add_module(voluxvolume.VoluxVolume()) vlx.add_module(voluxbar.VoluxBar()) vlx.bar.add_mode("default", vlx.volume) try: vlx.add_module( voluxlight.VoluxLight( instance_label="demo", init_mode="device", init_mode_args={"label": device_label}, )) vlx.bar.add_mode("light", vlx.light_demo) except Exception as err: print("{}WARNING: couldn't add light module/s... reason: {}{}". format(colorama.Fore.YELLOW, err, colorama.Style.RESET_ALL)) # load Volux Bar module print( "{}Tip: Double right-click bar or press Ctrl+C while this window is active to stop demo{}" .format(colorama.Fore.YELLOW, colorama.Style.RESET_ALL)) vlx.bar.init_window()
def run_demo(self): self._check_reqs() import volux # import essentials import voluxaudio # module to get amplitude of desktop audio import voluxgui # module to generate GUI # instantiate an operator for managing connections vlx = volux.VoluxOperator() # add modules vlx.add_module(volux.VoluxCliPrint()) vlx.add_module(voluxaudio.VoluxAudio()) vlx.add_module(voluxgui.VoluxGui()) # add connections vlx.add_connection(volux.VoluxConnection( vlx.audio, vlx.gui, 120)) # change GUI bar to match audio amplitude # vlx.add_connection(volux.VoluxConnection(vlx.audio,vlx.cli,120)) # print audio amplitude to terminal vlx.start_sync() vlx.gui.init_window() vlx.stop_sync() print("Ctrl+C to end demo...")
import pytest import volux # create Volux Operator object (hub for communication between modules) vlx = volux.VoluxOperator() volux_module_cli_print = volux.coremodules.VoluxCliPrint() class Test_voluxcliprint: def test_adding_module(self): cli_UUID = vlx.add_module(volux_module_cli_print) assert cli_UUID in vlx.modules assert isinstance(vlx.modules[cli_UUID], volux.VoluxModule) def test_get_modules(self): print(vlx.get_modules()) assert vlx.get_modules() == vlx.modules def test_default_value(self): assert vlx.cli.cli_val == vlx.cli.get() def test_set_value(self): vlx.cli.set(20) assert vlx.cli.get() == 20 vlx.cli.set(10) assert vlx.cli.get() == 10
def launch(): # builtins import os import sys import threading import logging import importlib # site import volux import colorama # package from .gui import VoluxGui log = logging.getLogger("voluxgui launch") log.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.INFO) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s - %(lineno)d") ch.setFormatter(formatter) log.addHandler(ch) vlx = volux.VoluxOperator() shared_modules = [] def add_volux_module(module_name, class_name, *args, **kwargs): try: module = importlib.import_module(module_name) module_UUID = vlx.add_module( getattr(module, class_name)(*args, **kwargs)) shared_modules.append(vlx.modules[module_UUID]) except Exception as err: log.warning("failed to import {}... ({})".format(module_name, err)) add_volux_module("voluxaudio", "VoluxAudio") add_volux_module( "voluxlight", "VoluxLight", instance_label="strip", init_mode="device", init_mode_args={"label": "Strip"}, ) add_volux_module( "voluxlight", "VoluxLight", instance_label="ceiling", init_mode="device", init_mode_args={"label": "Office Ceiling"}, ) add_volux_module( "voluxlight", "VoluxLight", instance_label="demo", init_mode="device", init_mode_args={"label": "Demo Bulb"}, ) add_volux_module( "voluxlightvisualiser", "VoluxLightVisualiser", mode="intense", hueHz=120, hue_cycle_duration=5, ) add_volux_module("voluxvolume", "VoluxVolume") vlx.add_module( # VoluxGui(shared_modules=gui_shared_modules), VoluxGui(shared_modules=shared_modules), req_permissions=[ volux.RequestSyncState, volux.RequestAddConnection, volux.RequestRemoveConnection, volux.RequestGetConnections, volux.RequestStartSync, volux.RequestStopSync, ], ) vlx.gui.init_window() vlx.stop_sync()