arduino-libraries / Arduino_MKRIoTCarrier

Use the features included with the Arduino MKR IoT Carrier
https://store.arduino.cc/mkr-iot-carrier
GNU Lesser General Public License v2.1
18 stars 11 forks source link

Button 0 not detected via MKRIotCarrier library #34

Closed ghost closed 3 years ago

ghost commented 3 years ago

Button 0 is not detected when pressed regardless of sensitivity value if using Arduino_MKRIoTCarrier.h. Other buttons seems to work fine and Touch_signals example sketch shows an analog reading coming from button 0 in the serial plotter.

I tried to use Arduino_MKRIoTCarrier_Qtouch.h directly in order to bypass Arduino_MKRIoTCarrier.h and a press on button 0 was detected. Bellow is my working debug sketch for reference:

// Use Qtouch directly and bypass "Arduino_MKRIoTCarrier.h" library

#include <Arduino_MKRIoTCarrier_Qtouch.h>
MKRIoTCarrierQtouch Buttons = MKRIoTCarrierQtouch();
unsigned int threshold = 90;

void setup() {
  Serial.begin(9600);
  while (!Serial);

  //Set custom threshold before initializing Buttons instance
  Buttons.updateConfig(threshold);

  Buttons.begin();
  Serial.println("Touch initialization Done!");

  // Verify sensitivity value from MCHPTouch library directly
  Serial.print("Sensitivity value:");
  Serial.println(TOUCH.getSensorsSensitivity());
}

void loop() {
  Buttons.update();

  // Now button 0 works
  if (Buttons.getTouch(TOUCH0)) {
    Serial.println("touching 0");
  }
  if (Buttons.getTouch(TOUCH1)) {
    Serial.println("touching 1");
  }
  if (Buttons.getTouch(TOUCH2)) {
    Serial.println("touching 2");
  }
  if (Buttons.getTouch(TOUCH3)) {
    Serial.println("touching 3");
  }
  if (Buttons.getTouch(TOUCH4)) {
    Serial.println("touching 4");
  }
}

I could not pinpoint the problem but it feels like something is being overwritten when initializing MKRIoTCarrier. Arduino_MKRIotCarrier version 1.0.1. Using Arduino IDE 1.8.13 on Fedora 34 with an Arduino MKR WiFi 1010 from Explore IoT Kit

marqdevx commented 3 years ago

Hey! Could you check the version of the Arduino_MCHPTouch library? It should be 1.2.0, if its not please update it and let me know the results. Thanks.

ghost commented 3 years ago

Thank you @marqdevx , the Arduino IDE was indeed using version 1.1.0. I installed version 1.2.0 manually and it worked.

The IDE automatically installed version 1.1.0 as a dependency of Arduino_MKRIoTCarrier.hand the library manager does not give me the option to install version 1.2.0 (even though it has been released). Do you know why that is? If I can understand what needs to be fixed at the IDE level, I'm happy to bring this upstream so others don't run into the same problem.

per1234 commented 3 years ago

the library manager does not give me the option to install version 1.2.0 (even though it has been released). Do you know why that is?

It's because they forgot to update the version value in the library metadata before making the release: https://github.com/arduino-libraries/Arduino_MCHPTouch/blob/v1.2.0/library.properties#L2

This value is what is used by the Library Manager for versioning, so it sees that there is already a 1.1.0 in the Library Manager index and skips the duplicate version: https://downloads.arduino.cc/libraries/logs/github.com/arduino-libraries/Arduino_MCHPTouch/

2021/07/02 00:46:21 Checking out tag: v1.2.0
2021/07/02 00:46:21 Release Arduino_MCHPTouch:1.1.0 already loaded, skipping
ghost commented 3 years ago

Thank you @per1234 for explaining and @marqdevx for the PR in the Arduino_MCHPTouch library. I'm assuming it's just a matter of time until it's accepted. Should I close this issue?

ghost commented 3 years ago

The PR has been merged so I'm closing this issue.