Skip to content

Commit

Permalink
Improve type hints and readme
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Johnson <ben@binarylogic.com>
  • Loading branch information
binarylogic committed Apr 11, 2024
1 parent d33e609 commit 94f4872
Show file tree
Hide file tree
Showing 2 changed files with 249 additions and 7 deletions.
142 changes: 135 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,147 @@ def callback(message):
altitude.start_listening(callback: callback)
```

## State

State will be available shortly after connecting. When a client connects to the
processor, it will send a list of messages reflecting the current state. The
`start_listening` method will receive these updates in the background and sync
your object with the processor's state.

```python
altitude.audiosync: bool | None # Current state of audiosync
altitude.bypass: bool | None = None # Current state of bypass
altitude.dim: bool | None = None # Current state of dim
altitude.id: str | None = None # Unique ID of the processor
altitude.mute: bool | None = None # Current state of mute
altitude.presets: dict = {} # Dictionary of all presets and their names
altitude.source: str | None = None # Current source
altitude.sources: dict = {} # Dictionary of all sources and their names
altitude.version: str | None = None # Software version of the processor
altitude.volume: float | None = None # Current volume level in dB
```

## Commands

All commands assume you have [setup](#setup) your Trinnov Altitude client.

### Change the volume
For a full list of commands, see the [`TrinnovAltitude` class](trinnov_altitude/trinnov_altitude.py),

### Acoustic Correction

```python
await altitude.acoustic_correction_off()
await altitude.acoustic_correction_on()
await altitude.acoustic_correction_set(state: bool)
await altitude.acoustic_correction_toggle()
```

### Bypass

```python
await altitude.bypass_off()
await altitude.bypass_on()
await altitude.bypass_set(state: bool)
await altitude.bypass_toggle()
```

### Dim

```python
await altitude.dim_off()
await altitude.dim_on()
await altitude.dim_set(state: bool)
await altitude.dim_toggle()
```

### Front display

```python
await altitude.dim_off()
await altitude.dim_on()
await altitude.dim_set(state: bool)
await altitude.dim_toggle()
```

### Level alignment

```python
await altitude.level_alignment_off()
await altitude.level_alignment_on()
await altitude.level_alignment_set(state: bool)
await altitude.level_alignment_toggle()
```

### Mute

```python
await altitude.mute_off()
await altitude.mute_on()
await altitude.mute_set(state: bool)
await altitude.mute_toggle()
```

### Page adjust

```python
# Get the current volume level
altitude.volume
await altitude.page_adjust(delta: int)
```

### Power

```python
altitude.power_on()
await altitude.power_off()
```

### Presets

```python
await altitude.preset_load(id: int)
```

### Quick optimized

```python
await altitude.quick_optimized_off()
await altitude.quick_optimized_on()
await altitude.quick_optimized_set(state: bool)
await altitude.quick_optimized_toggle()
```

### Remapping mode

```python
await altitude.remapping_mode_set(mode: const.RemappingMode)
```

### Sources

```python
await altitude.source_set(id: int)
```

# Change the processor's volume
await altitude.set_volume(-45)
### Time alignment

# See the new volume level. Once sent, the processor
altitude.volume
```python
await altitude.time_alignment_off()
await altitude.time_alignment_on()
await altitude.time_alignment_set(state: bool)
await altitude.time_alignment_toggle()
```

### Upmixer

```python
await altitude.source_set(mode: const.UpmixerMode)
```

### Volume

```python
await altitude.volume_adjust(delta: int | float)
await altitude.volume_down()
await altitude.volume_set(db: int | float)
await altitude.volume_ramp(db: int | float, duration: int)
await altitude.volume_up()
```
114 changes: 114 additions & 0 deletions trinnov_altitude/trinnov_altitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ def start_listening(
# --------------------------
# Commands
# --------------------------
async def acoustic_correction_off(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn the acoustic correction off.
"""
await self.acoustic_correction_set(False)

async def acoustic_correction_on(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn the acoustic correction on.
"""
await self.acoustic_correction_set(True)

async def acoustic_correction_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand All @@ -189,6 +205,18 @@ async def acoustic_correction_toggle(
"""
await self._write("use_acoustic_correct 2", timeout)

async def bypass_off(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the bypass off
"""
await self.bypass_set(False)

async def bypass_on(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the bypass on
"""
await self.bypass_set(True)

async def bypass_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand All @@ -203,6 +231,18 @@ async def bypass_toggle(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT)
"""
await self._write("bypass 2", timeout)

async def dim_off(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the dim off.
"""
await self.dim_set(False)

async def dim_on(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the dim on.
"""
await self.dim_set(True)

async def dim_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand All @@ -217,6 +257,20 @@ async def dim_toggle(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
await self._write("dim 2", timeout)

async def front_display_off(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn the front display off.
"""
await self.front_display_set(False)

async def front_display_on(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the front display on.
"""
await self.front_display_set(True)

async def front_display_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand All @@ -233,6 +287,22 @@ async def front_display_toggle(
"""
await self._write("dim 2", timeout)

async def level_alignment_off(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn the level alignment off.
"""
await self.level_alignment_set(False)

async def level_alignment_on(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn the level alignment on.
"""
await self.level_alignment_set(True)

async def level_alignment_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand All @@ -249,6 +319,18 @@ async def level_alignment_toggle(
"""
await self._write("use_level_alignment 2", timeout)

async def mute_off(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the mute off.
"""
await self.mute_set(False)

async def mute_on(self, timeout: int | float | None = USE_DEFAULT_TIMEOUT):
"""
Turn the mute on.
"""
await self.mute_set(True)

async def mute_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand Down Expand Up @@ -294,6 +376,22 @@ async def preset_load(
"""
await self._write("bypass 2", timeout)

async def quick_optimized_off(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn quick optimized off.
"""
await self.quick_optimized_set(False)

async def quick_optimized_on(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn quick optimized on.
"""
await self.quick_optimized_set(True)

async def quick_optimized_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand Down Expand Up @@ -329,6 +427,22 @@ async def source_set(
"""
await self._write(f"profile {id}", timeout)

async def time_alignment_off(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn time alignment off.
"""
await self.time_alignment_set(False)

async def time_alignment_on(
self, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
"""
Turn time alignment on.
"""
await self.time_alignment_set(True)

async def time_alignment_set(
self, state: bool, timeout: int | float | None = USE_DEFAULT_TIMEOUT
):
Expand Down

0 comments on commit 94f4872

Please sign in to comment.