Closed jhillyerd closed 3 years ago
Hi and thanks for testing this. I don't have an Apple remote to test with, but I think adding support for them should be doable.
Repeat is sort of working, but not properly propagated through library, I have a issue (#47) with some notes about the problems. The easy way would be to just cache the last command and just return that again. But I can imagine that the user of the library would like to know that the command received was a repeat. I will probably just att a flag to the the Command trait in the next version
A quick read through the Wikipedia article suggest that the timing from the remote is standard NEC, but the data format is different. I think a new NecApple NecVariant needs to be added to https://github.com/jkristell/infrared/blob/master/src/protocols/nec/mod.rs that can parse the data format.
The mapping of the fields to Infrared ones needs some thought, Device Id seems to be configurable, so maybe this should just be ignored and we pretend that the vendor bits are the address and let the Command Page and Command together to form the Command?
I have created a branch with some test code. Could you try something like this:
https://github.com/jkristell/infrared-examples/blob/test-appleremote/stm32f103-bluepill/examples/receiver.rs
Change the receiver type from Nec
to Nec<NecApple>
and debug print the bitbuf.
And override the infrared in Cargo.toml with
[patch.crates-io]
infrared = { git = "https://github.com/jkristell/infrared", branch="appleremote" }
And then post some prints here and then I could try to verify the decoder I'm about to write
Left: 9B0987EE
Up: 9B0A87EE
Right: 9B0687EE
Down: 9B0C87EE
Enter: 9B5C87EE
and 9B0587EE
Menu: 9B0387EE
Play/P: 9B5F87EE
and 9B0587EE
All were interspersed with bitbuf: 0
as well
Thanks! Implemented support for it on "appleremote" branch
I combined the Command Page and Command from the specification into the cmd field in the NecCommand struct. So you have to update your RemoteControl struct Button mappings.
Cool, I will test this branch in my project sometime in the next few days. Thanks.
Thanks.
My plan is to do some refactoring to the NEC-code and implement proper support for Repeats and then do a new release with AppleNec support. I found a Apple remote as well, but haven't tested it yet, so not sure if it's the same vintage as yours.
The one I have know looks to be the same, and it works. I have a new branch with the refactored Nec code, the nice thing is that detecting Repeat for Nec now works and we have access to all of the fields https://github.com/jkristell/infrared/blob/wip-r0.9/src/protocols/nec/cmds.rs#L183 of the Apple Nec-command and don't have to do tricks to make it work with the RemoteControl trait.
The rewrite got a bit bigger than I first expected, so I will need some more time to clean it up and make sure I want to commit to some of the API changes. But I updated the exampled in the infrared-examples repo to use the Apple Remote so, and it seems to work really well. See for instance the mediakeys example https://github.com/jkristell/infrared-examples/blob/infrared-r0.9/stm32f103-bluepill/examples/mediakeyboard.rs
Released a new version (0.9) with support for the Apple version of the NEC protocol and a RemoteControl implemntation based on your work. Thanks!
Awesome, thanks for adding. Haven't had a chance to play with it yet, but I have a project in mind to start in a few weeks.
I have a remote definition to contribute, but I thought it may warrant some discussion first. According to Wikipedia, Apple is using NEC with a different format. I'm not sure if the format matters since it seems to be working.
https://github.com/jhillyerd/bluepill-exp/blob/master/src/apple2009.rs
The remote button decoding works fine as is, but there are undecodable commands.
Hold-down repeat
I'm not sure if the crate supports this or not, but I see 0/0 when holding down a button:
Legacy cmd 5
Apple sends an extra command when pressing Enter or Play/Pause, so that legacy receivers can still interpret it as a Play/Pause. Wikipedia documents this.