diff --git a/src/vmr_cli/bus.py b/src/vmr_cli/bus.py index dc387a3..d68b215 100644 --- a/src/vmr_cli/bus.py +++ b/src/vmr_cli/bus.py @@ -7,6 +7,9 @@ from .context import Context from .help import CustomHelpFormatter app = App(name='bus', help_formatter=CustomHelpFormatter()) +# The VBAN protocl does not yet define a packet structure for these bus parameters. +# Hopefully that will come in the form of a 'VBAN_VMPARAMBUS_PACKET'. +# app.command(eq.app.meta, name='eq') @app.meta.default diff --git a/src/vmr_cli/eq.py b/src/vmr_cli/eq.py new file mode 100644 index 0000000..2925f78 --- /dev/null +++ b/src/vmr_cli/eq.py @@ -0,0 +1,53 @@ +from typing import Annotated + +from cyclopts import App, Argument, Parameter + +from .context import Context +from .help import CustomHelpFormatter + +app = App(name='eq', help_formatter=CustomHelpFormatter()) + + +@app.meta.default +def launcher( + band: Annotated[int, Argument()] = None, + *tokens: Annotated[str, Parameter(show=False, allow_leading_hyphen=True)], + index: Annotated[int, Argument()] = None, + ctx: Annotated[Context, Parameter(show=False)] = None, +): + """Control the EQ parameters. + + Only channel 0 is supported, as the VBAN protocol only exposes parameters for this channel. + """ + additional_kwargs = {} + command, bound, _ = app.parse_args(tokens) + if index is not None: + additional_kwargs['index'] = index + if band is not None: + additional_kwargs['band'] = band + if ctx is not None: + additional_kwargs['ctx'] = ctx + + return command(*bound.args, **bound.kwargs, **additional_kwargs) + + +@app.command(name='on') +def on( + new_state: Annotated[bool, Argument()] = None, + *, + index: Annotated[int, Parameter(show=False)] = None, + band: Annotated[int, Parameter(show=False)] = None, + ctx: Annotated[Context, Parameter(show=False)] = None, +): + """Get or set the on state of the specified EQ band. + + Parameters + ---------- + new_state : bool + If provided, sets the on state to this value. If not provided, the current on state is printed. + """ + if new_state is None: + # This doesn't work because the VBAN protocol doesn't send an initial NBS1 packet. + # console.out.print(ctx.client.strip[index].eq.channel[0].cell[band].on) + return + ctx.client.strip[index].eq.channel[0].cell[band].on = new_state diff --git a/src/vmr_cli/strip.py b/src/vmr_cli/strip.py index ade3e05..469512a 100644 --- a/src/vmr_cli/strip.py +++ b/src/vmr_cli/strip.py @@ -2,11 +2,12 @@ from typing import Annotated, Optional from cyclopts import App, Argument, Parameter -from . import console +from . import console, eq from .context import Context from .help import CustomHelpFormatter app = App(name='strip', help_formatter=CustomHelpFormatter()) +app.command(eq.app.meta, name='eq') @app.meta.default