-
Notifications
You must be signed in to change notification settings - Fork 11
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
Sensitivity not changed if updateConfig
called after carrier.begin()
#21
Comments
Hey @jeniara could you please send me the sketch? Thanks |
Thanks! See the example code from the master, Custom_Sensitivity , modified lines 20-24 and line 8-9 (I have the case mounted).
…---
#include "Arduino_MKRIoTCarrier.h"
MKRIoTCarrier carrier;
// When CARRIER_CASE is false it's set to 100 (closer)
// When CARRIER_CASE is true it's set to 4 (further)
// But if you use Buttons.updateConfig(value) It will not set the above values
unsigned int threshold = 4;
unsigned int threshold_btn_0 = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial);
// CARRIER_CASE = true;
//Now we can set our custom touch threshold
// First we update all the buttons with the new threshold
// Then we overwrite individually one of them (they can be all set individually too)
carrier.begin();
Serial.println("carrier begin");
carrier.Buttons.updateConfig(threshold);
carrier.Button0.updateConfig(threshold_btn_0);
Serial.println("Updated Config");
}
void loop() {
// put your main code here, to run repeatedly:
carrier.Buttons.update();
// Verify your thresholds
if (carrier.Button0.getTouch()) {
Serial.println("touching 0");
}
if (carrier.Button1.getTouch()) {
Serial.println("touching 1");
}
if (carrier.Button2.getTouch()) {
Serial.println("touching 2");
}
if (carrier.Button3.getTouch()) {
Serial.println("touching 3");
}
if (carrier.Button4.getTouch()) {
Serial.println("touching 4");
}
}
|
So, hmm it doesnt matter if you change the threshold after the Im going to debug it tomorrow and let you know if I find something. Thanks for the feedback. |
Now I was able to check again: This is working #include "Arduino_MKRIoTCarrier.h"
MKRIoTCarrier carrier;
// When CARRIER_CASE is false it's set to 100 (closer)
// When CARRIER_CASE is true it's set to 4 (further)
// But if you use Buttons.updateConfig(value) It will not set the above values
unsigned int threshold = 4;
unsigned int threshold_btn_0 = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial);
// CARRIER_CASE = true;
//Now we can set our custom touch threshold
// First we update all the buttons with the new threshold
// Then we overwrite individually one of them (they can be all set individually too)
carrier.Buttons.updateConfig(threshold);
carrier.Button0.updateConfig(threshold_btn_0);
Serial.println("Updated Config");
carrier.begin();
Serial.println("carrier begin");
}
void loop() {
// put your main code here, to run repeatedly:
carrier.Buttons.update();
// Verify your thresholds
if (carrier.Button0.getTouch()) {
Serial.println("touching 0");
}
if (carrier.Button1.getTouch()) {
Serial.println("touching 1");
}
if (carrier.Button2.getTouch()) {
Serial.println("touching 2");
}
if (carrier.Button3.getTouch()) {
Serial.println("touching 3");
}
if (carrier.Button4.getTouch()) {
Serial.println("touching 4");
}
} This is not working #include "Arduino_MKRIoTCarrier.h"
MKRIoTCarrier carrier;
// When CARRIER_CASE is false it's set to 100 (closer)
// When CARRIER_CASE is true it's set to 4 (further)
// But if you use Buttons.updateConfig(value) It will not set the above values
unsigned int threshold = 4;
unsigned int threshold_btn_0 = 4;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while (!Serial);
// CARRIER_CASE = true;
//Now we can set our custom touch threshold
// First we update all the buttons with the new threshold
// Then we overwrite individually one of them (they can be all set individually too)
carrier.begin();
Serial.println("carrier begin");
carrier.Buttons.updateConfig(threshold);
carrier.Button0.updateConfig(threshold_btn_0);
Serial.println("Updated Config");
}
void loop() {
// put your main code here, to run repeatedly:
carrier.Buttons.update();
// Verify your thresholds
if (carrier.Button0.getTouch()) {
Serial.println("touching 0");
}
if (carrier.Button1.getTouch()) {
Serial.println("touching 1");
}
if (carrier.Button2.getTouch()) {
Serial.println("touching 2");
}
if (carrier.Button3.getTouch()) {
Serial.println("touching 3");
}
if (carrier.Button4.getTouch()) {
Serial.println("touching 4");
}
} |
@jeniara - I have to agree with you - I have spent a day trying to resolve Button0 not responding when in the case. The instructions in Calibrating-the-MKR-IoT-Carrier-capacitive-buttons just don't work for 2 reasons.
unsigned int threshold = 98;
unsigned int threshold_btn_0 = 95;
...
carrier.begin();
//CARRIER_CASE = false;
//Now we can set our custom touch threshold
// First we update all the buttons with the new threshold
// Then we overwrite individually one of them (they can be all set individually too)
carrier.Buttons.updateConfig(threshold);
**carrier.Buttons.updateConfig(threshold_btn_0);**
//this would have updated all buttons! Should have been
carrier.Button0.updateConfig(threshold_btn_0); //or
carrier.Buttons.updateConfig(threshold_btn_0, Touch0); |
Hello @mhavill @jeniara ! Thanks |
Hi @marqdevx, Thanks |
Thanks @mhavill , yes the Online Editor uses the latest version by default, I'll try the sketch and contact you with more info. |
I think I ran into the same issue as this. What I found is that the default value of Here are the two references to the code I could find:
Arduino_MKRIoTCarrier/src/Arduino_MKRIoTCarrier.cpp Lines 41 to 43 in b8b931e
This is the same thing found in #21 (comment), I'm just reiterating the behavior for the latest version, and a workaround below. As of #include "Arduino_MKRIoTCarrier.h"
MKRIoTCarrier carrier;
void setup() {
Serial.begin(9600);
while (!Serial);
// make sure withCase() is called so begin() does not reset
// the button sensitivities
carrier.withCase();
// then set all the button sensitivities individually
carrier.Buttons.updateConfig(4, TOUCH0);
carrier.Buttons.updateConfig(30, TOUCH1);
carrier.Buttons.updateConfig(60, TOUCH2);
carrier.Buttons.updateConfig(100, TOUCH3);
carrier.Buttons.updateConfig(200, TOUCH4);
// or set them all at once
// carrier.Buttons.updateConfig(200);
// finally call begin
carrier.begin();
} |
updateConfig
called after carrier.begin()
If I modify the example "Custom_Sensitivity" and move the
carrier.begin()
on line 22 and put it BEFORE line 20:it no longer respond to touch. However, if I uncomment line 16:
// CARRIER_CASE = false;
then it works again, even with
carrier.begin();
before the setting.I can not verify if the
updateConfig
actually change the values (yet) but I think the code should be robust to allow definition of button sensitivity before or after thebegin.carrier()
call.The text was updated successfully, but these errors were encountered: