Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple models of Apple remote + long press #97

Merged
merged 1 commit into from
Apr 14, 2022

Conversation

zas
Copy link
Contributor

@zas zas commented Nov 30, 2021

No description provided.

@zas zas mentioned this pull request Nov 30, 2021
@zas zas changed the title Add support for multiple models of Apple remote + repeat Add support for multiple models of Apple remote + long press Nov 30, 2021
@zas zas marked this pull request as draft November 30, 2021 18:12
@zas zas force-pushed the appleremoterepeat branch 2 times, most recently from d02c219 to b33db1a Compare November 30, 2021 18:52
@zas zas marked this pull request as ready for review November 30, 2021 18:52
@zas
Copy link
Contributor Author

zas commented Nov 30, 2021

@dspverden I noticed something in

#define APPLE_REMOTE_CENTER_UP 0x77E12047
#define APPLE_REMOTE_MENU 0x77E14047
#define APPLE_REMOTE_PLAY_DOWN 0x77E17A47
#define APPLE_REMOTE_PLAY_UP 0x77E12047

0x77E12047 seems to be emitted when CENTER or PLAY are released (UP), so the codes are incorrect, but since they weren't used, no problem.
Other buttons don't send a different code when releasing, so not sure it is worth bothering.

My remote has codes looking like 77E1xx36, the master source has codes in the form of 77E1xx47, and f35adc3 has codes in the form of 77E1xx55.
#73 gives another set of codes that have the following patten 77E1xxF7

The code here should work with all.

@zas
Copy link
Contributor Author

zas commented Nov 30, 2021

@dspverden I improved the thing a bit so it speeds up when maintaining a long press on volume remote buttons, and tried to debounce very short presses, so it's possible to fine tune volume level. On short presses, it goes with 0.5db as it was before, but when maintaining buttons it speeds up to 1db then 2db.
Tell me what you think once you tested it.

@zas zas marked this pull request as draft December 2, 2021 16:46
@zas
Copy link
Contributor Author

zas commented Dec 2, 2021

I'm not yet happy with this code. I'll update the PR once I have something good enough.

@zas zas marked this pull request as ready for review December 2, 2021 17:35
@zas
Copy link
Contributor Author

zas commented Dec 2, 2021

I reworked the code, it is much simpler now, and should work as expected.

@exislow
Copy link

exislow commented Dec 2, 2021

Great job. Just tested it. Works like charm. Even the logic regarding short long presses and longer long presses. Love it.

- code should work with all Apple remotes with codes starting with 0x77E1
- volume increases/decreases faster if volume buttons are pressed for a long time
@dspverden
Copy link
Collaborator

To make things a bit more complicated, I had a bunch of Apple remotes here, they all showed different patterns. But it can be narrowed down to a scheme. In hex code the second byte identifies the key while byte 4 & 3 are always 0x77E1xxxx. That means masking byte 2 by 0x0000FF00 will give the key code. Here I found two variants for each key, e.g. Play button is either 0x00007A00 or 0x0000FA00.
See my last commit on develop. There I already implemented that. Perhaps you want to adapt long press solution to it?

@zas
Copy link
Contributor Author

zas commented Dec 13, 2021

@dspverden did you test my code with those remotes ? The 0x00007A00 or 0x0000FA00 should be handled by 0x00007F00 mask

EDIT:

I'm pretty sure this code was working with the variant you added in 00f0012

I wonder if you actually tested this code, and if it wasn't working, why.
Check
https://github.com/brackendawson/Appleceiver/blob/357a0a16013d9e35f1119530399aba55b7030bab/Appleceiver.ino#L43-L55:

//Apple remote definitions
//Address
#define A1156_ADDRESS   0x77E1  
/*Button codes
 I've seen many remotes have various codes,
 this is the best decode I have. The address
 is fixed, the message may be as so:
 #define A1156_BUT_PLUS  0x   5    0    9    D
                           0101 0000 1001 1101
                           ||      | |       |
 varies, battery flat?-----+|      | |       |
 fixed?, the button---------+------+ |       |
 varies, serial number?--------------+-------+ */

The first bit on the left varies ("battery flat?"), hence the mask 0x00007F00.

@zas
Copy link
Contributor Author

zas commented Dec 16, 2021

@dspverden you didn't answer to my comment above, I need to know what wasn't working with the models you own, before reworking this PR.

@dspverden
Copy link
Collaborator

Please have a look at the one of the latest commits from develop. There you can see, it seems to be bit 7 (most left) of the the second byte. As you described it above.

@dspverden dspverden merged commit b588c69 into freeDSP:develop Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants