Skip to content

Commit

Permalink
add new modes
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveicedgreentea committed Dec 18, 2022
1 parent a4175a0 commit 52d5491
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 5 deletions.
3 changes: 2 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
## BREAKING CHANGES

### Commands
`input` renamed to `input_mode`
`input` renamed to `input_mode`
`laser_dim` renamed to `laser_mode`
22 changes: 20 additions & 2 deletions jvc_projector/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ACKs(Enum):
greeting = b"PJ_OK"
pj_ack = b"PJACK"
pj_req = b"PJREQ"
install_acks = b"IN"
hdmi_ack = b"IS"


class InputModes(Enum):
Expand Down Expand Up @@ -189,7 +191,17 @@ class AnamorphicModes(Enum):
c = b"3"
d = b"4"

class ColorSpaceModes(Enum):
auto = b"0"
YCbCr444 = b"1"
YCbCr422 = b"2"
RGB = b"3"

class InputLevel(Enum):
standard = b"0"
enhanced = b"1"
superwhite = b"2"
auto = b"3"
class EshiftModes(Enum):
off = b"0"
on = b"1"
Expand Down Expand Up @@ -220,6 +232,12 @@ class Commands(Enum):

# picture mode commands
picture_mode = b"PMPM", PictureModes, ACKs.picture_ack

# Color modes
color_mode = b"ISHS", ColorSpaceModes, ACKs.hdmi_ack

# input_level like 0-255
input_level = b"ISIL", InputLevel, ACKs.hdmi_ack

# low latency enable/disable
low_latency = b"PMLL", LowLatencyModes, ACKs.picture_ack
Expand All @@ -240,7 +258,7 @@ class Commands(Enum):
menu = b"RC73", MenuModes, ACKs.menu_ack

# NZ Series Laser Dimming commands
laser_dim = b"PMDC", LaserDimModes, ACKs.picture_ack
laser_mode = b"PMDC", LaserDimModes, ACKs.picture_ack

# Lens Aperture commands
aperture = b"PMDI", ApertureModes, ACKs.picture_ack
Expand All @@ -250,4 +268,4 @@ class Commands(Enum):
anamorphic = b"INVS", AnamorphicModes, ACKs.lens_ack

# e-shift
eshift = b"PMUS", EshiftModes, ACKs.picture_ack
eshift_mode = b"PMUS", EshiftModes, ACKs.picture_ack
78 changes: 76 additions & 2 deletions jvc_projector/jvc_projector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from typing import Final, Union
import asyncio
from jvc_projector.commands import ACKs, Footer, Header, Commands, PowerStates, Enum, LowLatencyModes
from jvc_projector.commands import InputLevel, ColorSpaceModes,EshiftModes ,ACKs, Footer, Header, Commands, PowerStates, PictureModes, InstallationModes, InputModes, LaserDimModes, Enum, LowLatencyModes


class JVCProjector:
Expand Down Expand Up @@ -417,14 +417,88 @@ async def async_get_low_latency_state(self) -> bool:
"""
Get the current state of LL
None if there was an error
"""
state, _ = await self._async_do_reference_op(
"low_latency", ACKs.picture_ack
)
# LL is off, could be disabled
return LowLatencyModes(state.replace(ACKs.picture_ack.value, b"")).name

async def async_get_picture_mode(self) -> str:
"""
Get the current picture mode as str -> user1, natural
"""
state, _ = await self._async_do_reference_op(
"picture_mode", ACKs.picture_ack
)
# LL is off, could be disabled
return PictureModes(state.replace(ACKs.picture_ack.value, b"")).name

async def async_get_install_mode(self) -> str:
"""
Get the current install mode as str
"""
state, _ = await self._async_do_reference_op(
"installation_mode", ACKs.install_acks
)
# LL is off, could be disabled
return InstallationModes(state.replace(ACKs.install_acks.value, b"")).name

async def async_get_input_mode(self) -> str:
"""
Get the current input mode
"""
state, _ = await self._async_do_reference_op(
"input_mode", ACKs.input_ack
)
# LL is off, could be disabled
return InputModes(state.replace(ACKs.input_ack.value, b"")).name

async def async_get_laser_mode(self) -> str:
"""
Get the current laser mode
"""
state, _ = await self._async_do_reference_op(
"laser_mode", ACKs.picture_ack
)
# LL is off, could be disabled
return LaserDimModes(state.replace(ACKs.picture_ack.value, b"")).name

async def async_get_eshift_mode(self) -> str:
"""
Get the current eshift mode
"""
state, _ = await self._async_do_reference_op(
"eshift_mode", ACKs.picture_ack
)
# LL is off, could be disabled
return EshiftModes(state.replace(ACKs.picture_ack.value, b"")).name

async def async_get_color_mode(self) -> str:
"""
Get the current color mode
"""
state, _ = await self._async_do_reference_op(
"color_mode", ACKs.hdmi_ack
)
return ColorSpaceModes(state.replace(ACKs.hdmi_ack.value, b"")).name

async def async_get_input_level(self) -> str:
"""
Get the current input level
"""
state, _ = await self._async_do_reference_op(
"input_level", ACKs.hdmi_ack
)
# LL is off, could be disabled
return InputLevel(state.replace(ACKs.hdmi_ack.value, b"")).name
# async def _async_check_low_latency(self) -> list[str]:
# """
# Infer if Low Latency is disabled or not otherwise commands will hang
Expand Down

0 comments on commit 52d5491

Please sign in to comment.