Skip to content

Comments

Use I2CHandle::ReadDataAtAddress for reading registers in mpr121.h#688

Merged
stephenhensley merged 7 commits intoelectro-smith:masterfrom
kaathewise:mpr121-read-register
Feb 20, 2026
Merged

Use I2CHandle::ReadDataAtAddress for reading registers in mpr121.h#688
stephenhensley merged 7 commits intoelectro-smith:masterfrom
kaathewise:mpr121-read-register

Conversation

@kaathewise
Copy link
Contributor

Based on #669 which seems abandoned. Remade the original pull request so it can be merged.

All credit goes to Matteocaroleo and Politek.

Closes #651

@kaathewise
Copy link
Contributor Author

Tested this on hardware, the addresses are correct, there is no need to shift them to the left (as was done in prior work).

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Test Results

150 tests  ±0   150 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 9b7812d. ± Comparison against base commit f044cdc.

♻️ This comment has been updated with latest results.

@stephenhensley
Copy link
Collaborator

@kaathewise Good timing! I actually have a bit of time to go over contributions, etc. and was going to check in on the original PR today.

If I can dig out an MPR121 from somewhere in my office, I'll also give this a test. If not, this looks okay based on the previous PR, and your successful tests.

Thanks for the PR!

@kaathewise
Copy link
Contributor Author

kaathewise commented Feb 19, 2026

I've also uncommented out the section that was not working before and updated one comment below which was inaccurate.

Perhaps the discrepancy between the comment and the behaviour deserves separate attention.

The comment said baseline tracking & proximity disabled, while 0x80 actually enables baseline tracking. I've updated the comment to match the behaviour, however the question is which behaviour is actually desired?

I personally would love the baseline tracking enabled on startup and then immediately disabled, as the current settings lead to contamination of baseline values and incorrect touch status when two or more pads are touched at once.

@kaathewise
Copy link
Contributor Author

Sorry, had to add one more thing. I've noticed that WriteRegister was using incorrect Read method as well. Fixed that, and also unified reading and writing methods to reduce confusion.

@stephenhensley
Copy link
Collaborator

No need to apologize! Thanks for the thorough update.

I'm hoping to test this a bit in general, but if I can't find my mpr121 hardware sometime tomorrow, I'll defer to your tests and merge it.

@stephenhensley
Copy link
Collaborator

Okay, I found my mpr121 breakout, and was able to test a bit.

Seems solid to me!
I wrote a little example program that prints data via USB serial that I'll add to the repo's examples a little later today.

There is a lot of configuration (proximity, baseline tracking, etc.) that people may/may not want to use, but I think there is a lot of room for additional configuration to be added in future PRs.

If there are any particular features you are currently using, or want to use, feel free to open a new PR with some additional data in the Config struct, and/or methods for any relevant runtime reconfiguration.

I'm not very familiar with this chip myself, but it is very widely used (and quite fun now that I've had a chance to mess with it a bit).
So supporting more features would definitely be welcome.

Thank you again for the contribution!
And thanks to @Matteocaroleo for the initial fix, and leg work in tracking down the issue.

@stephenhensley stephenhensley merged commit 5ad4c36 into electro-smith:master Feb 20, 2026
13 checks passed
@kaathewise
Copy link
Contributor Author

Thank you for your quick response and testing!

As for the features, I realised that the public WriteRegister method should be enough to support arbitrary configuration changes, at least for my purposes.

@kaathewise kaathewise deleted the mpr121-read-register branch February 20, 2026 18:13
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.

MPR121 class FilteredData() returns wrong data

2 participants