diff --git a/README.md b/README.md index 2f973c5..727db7d 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ idf.py flash ![config-top](https://user-images.githubusercontent.com/6020549/147515950-b6e2cf2f-5a82-4114-a565-df7a78085c8d.jpg) -![config-mpr121](https://user-images.githubusercontent.com/6020549/147515956-ef978fca-07ae-4dc6-b8c1-121fe17e23ef.jpg) +![config-mpr121](https://user-images.githubusercontent.com/6020549/147892705-4672b941-3939-42c2-aad9-8a12f49d2451.jpg) # Wirering diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index f5ed153..b43cb9b 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -1,5 +1,11 @@ menu "MPR121 Configuration" + config I2C_ADDRESS + hex "I2C address" + default 0x5A + help + I2C address. + config SCL_GPIO int "SCL GPIO number" range 0 48 diff --git a/main/main.c b/main/main.c index 8324c1f..3d86577 100644 --- a/main/main.c +++ b/main/main.c @@ -15,12 +15,11 @@ #include "mpr121.h" -#define MPR121_ADDR 0x5A - static const char *TAG = "MAIN"; void app_main(void) { + ESP_LOGI(TAG, "CONFIG_I2C_ADDRESS=0x%X", CONFIG_I2C_ADDRESS); ESP_LOGI(TAG, "CONFIG_SCL_GPIO=%d", CONFIG_SCL_GPIO); ESP_LOGI(TAG, "CONFIG_SDA_GPIO=%d", CONFIG_SDA_GPIO); ESP_LOGI(TAG, "CONFIG_IRQ_GPIO=%d", CONFIG_IRQ_GPIO); @@ -30,7 +29,7 @@ void app_main(void) uint16_t releaseThreshold = 20; //uint16_t interruptPin = 4; - bool ret = MPR121_begin(&dev, MPR121_ADDR, touchThreshold, releaseThreshold, CONFIG_IRQ_GPIO, CONFIG_SDA_GPIO, CONFIG_SCL_GPIO); + bool ret = MPR121_begin(&dev, CONFIG_I2C_ADDRESS, touchThreshold, releaseThreshold, CONFIG_IRQ_GPIO, CONFIG_SDA_GPIO, CONFIG_SCL_GPIO); ESP_LOGI(TAG, "MPR121_begin=%d", ret); if (ret == false) { switch (MPR121_getError(&dev)) { @@ -63,8 +62,8 @@ void app_main(void) #if 0 - MPR121_setTouchThresholdAll(&dev, 40); // this is the touch threshold - setting it low makes it more like a proximity trigger, default value is 40 for touch - MPR121_setReleaseThresholdAll(&dev, 20); // this is the release threshold - must ALWAYS be smaller than the touch threshold, default value is 20 for touch + MPR121_setTouchThresholdAll(&dev, 40); // this is the touch threshold - setting it low makes it more like a proximity trigger, default value is 40 for touch + MPR121_setReleaseThresholdAll(&dev, 20); // this is the release threshold - must ALWAYS be smaller than the touch threshold, default value is 20 for touch #endif