Пример #1
0
def main():
    os.environ['SDL_VIDEODRIVER'] = 'dummy'
    if '--debug' in sys.argv:
        logging.basicConfig(level=logging.DEBUG)

    logger = logging.getLogger()
    settings.from_files(cfg='yaml', verbose=True)
    settings.from_args(sys.argv[1:])
    if settings.prometheus:
        start_http_server(settings.prometheus_port)

    b = Board(settings)
    http = HTTPThread(b, settings)
    http.start()
    for file in get_files(settings.yaml_directory, 'yaml'):
        sound_set = SoundSet.from_yaml(file, settings=settings)
        b.register_sound_set(sound_set)

    joystick = Joystick(settings.device_path, backend=settings.input_type,
                        mapping=settings.physical_mapping,
                        offset=settings.scancode_offset)

    b.register_joystick(joystick)
    http_joystick = Joystick(http.queue, backend='queue')
    b.register_joystick(http_joystick)
    b.run()
Пример #2
0
def setup_mqtt_controller(board: Board, mqtt: MQTT):
    mqtt_queue: Queue[Tuple[int, int]] = Queue()
    mqtt_joystick = Joystick(mqtt_queue, backend="queue")

    def joystick_cb(topic, msg):
        btn, _, state = msg.partition(b"=")
        joystick_data = int(btn), int(state)
        mqtt_queue.put(joystick_data)

    board.register_joystick(mqtt_joystick)
    mqtt.add_topic_handler(MQTT_TOPIC_CONTROLLER, joystick_cb)
Пример #3
0
def main():
    os.environ["SDL_VIDEODRIVER"] = "dummy"
    if "--debug" in sys.argv:
        logging.basicConfig(level=logging.DEBUG)

    settings.from_files(cfg="yaml", verbose=True)
    settings.from_args(sys.argv[1:])
    if settings.prometheus:
        start_http_server(settings.prometheus_port)

    board = Board(settings)
    for file in Path(settings.yaml_directory).glob("*.yaml"):
        board.register_sound_set(yamlfile=file)

    if settings.http:
        setup_http(board)

    if settings.device_path:
        joystick = Joystick(
            settings.device_path,
            backend=settings.input_type,
            offset=settings.scancode_offset,
        )

        board.register_joystick(joystick)
    else:
        logger.warning("no hardware soundboard")

    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    proto_pb2_grpc.add_SoundboardServicer_to_server(
        SoundboardServicer(board), server,
    )
    reflection.enable_server_reflection(
        (
            "soundboard.Soundboard",
            reflection.SERVICE_NAME,
        ), server,
    )
    server.add_insecure_port('[::]:50051')
    server.start()

    if settings.mqtt:
        mqtt = MQTT(
            path=settings.mqtt_path,
            login=settings.mqtt_login,
            password=settings.mqtt_password,
        )
        mqtt.add_topic_handler(MQTT_TOPIC_DANK, board.on_dankness)
        setup_mqtt_controller(board, mqtt)
    board.run()
Пример #4
0
def main():
    logger = logging.getLogger()
    settings.from_args(sys.argv[1:])

    if settings.debug:
        logger.setLevel(logging.DEBUG)
    os.environ['SDL_VIDEODRIVER'] = 'dummy'
    b = Board()
    for file in get_files(settings.yaml_directory, 'yaml'):
        sound_set = SoundSet.from_yaml(file, settings=settings)
        b.register_sound_set(sound_set)

    joystick = Joystick(settings.device_path, backend=settings.input_type,
                        mapping=settings.physical_mapping,
                        offset=settings.scancode_offset)

    b.register_joystick(joystick)
    b.run()