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

Autoconfig function #42

Open
wystewart opened this issue Jan 12, 2025 · 1 comment
Open

Autoconfig function #42

wystewart opened this issue Jan 12, 2025 · 1 comment

Comments

@wystewart
Copy link

wystewart commented Jan 12, 2025

recommend to add a function to enable autoconfig or to add an optional parameter to begin to enable autoconfig. The later being the preferred method.

Present method requires modification of code, which breaks updating the code/library to a new version in arduinoide or platformio library manager.

thank you.

@wystewart
Copy link
Author

Suggest code changes:

.h file
bool begin(uint8_t i2caddr = MPR121_I2CADDR_DEFAULT, TwoWire *theWire = &Wire,
uint8_t touchThreshold = MPR121_TOUCH_THRESHOLD_DEFAULT,
uint8_t releaseThreshold = MPR121_RELEASE_THRESHOLD_DEFAULT,
boolean autoconfig = false);

.c file
delete
// uncomment to use autoconfig !
// #define AUTOCONFIG // use autoconfig (Yes it works pretty well!)

modify
bool Adafruit_MPR121::begin(uint8_t i2caddr, TwoWire *theWire,
uint8_t touchThreshold, uint8_t releaseThreshold,
bool autoconfig) {

if (autoconfig)
{
writeRegister(MPR121_AUTOCONFIG0, 0x0B);

// correct values for Vdd = 3.3V
writeRegister(MPR121_UPLIMIT, 200); // ((Vdd - 0.7)/Vdd) * 256
writeRegister(MPR121_TARGETLIMIT, 180); // UPLIMIT * 0.9
writeRegister(MPR121_LOWLIMIT, 130); // UPLIMIT * 0.65
}

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

No branches or pull requests

1 participant