bezmi / jvc_projector

Python library to control JVC projectors
MIT License
16 stars 10 forks source link

HDR/Cinema/etc buttons #1

Closed atrus05 closed 4 years ago

atrus05 commented 4 years ago

Hi good sir, Thanks for making this! Any chance you could consider adding support for switching between Cinema and HDR (and that third button on the remote which I seldom use)?

atrus05 commented 4 years ago

Natural is the third button :)

bezmi commented 4 years ago

I will consider it but I have very limited time to push changes. I'm open to pull requests and adding commands is trivial. Here are the steps to figure out the comnmand string if you would like to have a go at submitting a pull request:

Step 1

Page 25 of this reference shows that the function is PMPM for "Picture Mode Switch". The hex representation of these ASCII characters in pythonic format is:

b"\x50\x4D\x50\x4D"

Step 2

The relevant picture modes are presented in Table 4-19 on Page 30. Let's take 01 for the "Cinema" preset:

b"\x30\x31"

Step 3

Finally, the examples on page 42 show what we need to append to the start and end of the command string. In the end, the final command added to the Commands Enum in __init__.py becomes:

class Commands(Enum):
    # ...
    # ALL THE OTHER COMMAND STRINGS...
    # ...

    pm_cinema = b"\x21\x89\x01\x50\x4D\x50\x4D\x30\x31\x0A"

Step 5

Just change the value of step 2 for the remaining input modes you want. You should be able to use it like any of the other commands, with either the JVCProjector.command() function in this module or the remote.send_command service in Home Assistant using "pm_cinema" as the command string.

Potential Issues

One of the reasons I held off on this is that the commands from step 2 will be slightly different for older projectors. The picture mode is represented by one byte/character. In this case, for the "Cinema" mode, we would use:

b"\x31"

Instead of the two byte code in step 2.

So if you're keen, submit a pull request. Otherwise, I'll get around to it whenever I have time.

atrus05 commented 4 years ago

Thank you for the description. I am not adeveloper (hobby scripter and good at many things but expert in nothing). But if I manage to learn how to do pull requests and the code changes I will of course do that. My guess is that I will not be able to do it, but maybe! :) If not, I am keeping my fingers crossed that you will find time in the future. Of course no pressure from me mate!

bezmi commented 4 years ago

October is a good month to get involved!

atrus05 commented 4 years ago

Hah, thanks to your excellent description I actually think I will be able to do this. I spent some time looking through everything, and it makes sense to me. I do however have a x5900, and that pdf seems to describe the newer projectors. So that may cause issues.

bezmi commented 4 years ago

Great, looking forward to the pull request. I also have an X5900 and use that file as a reference as it's for 2018 projectors. The commands should work as long as your projector has that feature. There are also specifications for 2017 and lower models here and it looks like the commands for the 2017 models (first ones with hdr) are identical.

atrus05 commented 4 years ago

Pull request made. No idea if I did it correctly though. Be gentle with me :)

atrus05 commented 4 years ago

I will likely be adding more in the future, but I will not do more until I know that I have done things correctly for this first try.

atrus05 commented 4 years ago

Tested the changes I added in the pull request, and they work fine. Will close this now, please let me know if something else is holding you back from merging.