added functions for reading mpr121 capacitive sensor#669
added functions for reading mpr121 capacitive sensor#669Matteocaroleo wants to merge 2 commits intoelectro-smith:masterfrom
Conversation
|
Hi @Matteocaroleo, The only difference is that |
|
You're right, so the |
|
@Matteocaroleo thanks for the contribution! You can modify this branch with additional commits, without having to make a separate PR. The CI also has a few issues with the code formatting. So if you wouldn't mind cleaning those up to conform, that would be great. |
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