added functions for reading mpr121 capacitive sensor #669
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, we at Politek (the audio engineering team at Politecnico di Torino) have found the problem in the libDaisy library and propose a solution.
You can check us out at https://politek.polito.it/
Problem
In the files
libDaisy/src/per/i2c.handlibDaisy/src/per/i2c.cppto read from an I2C device the functionReceiveBlocking(...)is used.Looking at the
i2c.cppfile, at line 346, in its function definition the hal functionHAL_I2C_Master_Receive (...)is used. The problem is that this hal function doesn't comply with the I2C reading protocol defined in the MPR121 datasheet, resulting in a wrong read.Solution
We found that the hal function
HAL_I2C_Mem_Read (...)implements the correct procedure to read from the MPR121, so we added a new function inside thei2c.cppand inside thesrc/dev/mpr121.hfiles to correctly use it.Using the function
FilteredData()now returns the correct values of capacitance reading from the mpr121 device.Closes #651