I’m trying to use the MODE button on the Particle Electron for my own program. I essentially want to be able to read whether it is pressed or not, just like digitalRead would on an external button. I want none of the functionality MODE provides by default. I realize this will prevent important things like “listening mode”, but I’m willing to accept that.
Browsing around, I found some code that does this. However, there’s a problem. The MODE functionality is still there. If the MODE button is held, the Electron enters listening mode, stopping my program. And if the MODE button is pressed twice quickly, the device shuts down! I want to prevent the MODE button from doing anything other than what I program in.
Here’s what I have now, and it works to detect the MODE button’s state. It doesn’t prevent the MODE button from doing other things though.
if (System.buttonPushed()>0) {
/* The button is pressed */
}
else
{
/* The button is not pressed */
}
I’ve tried adding this to my loop, but then the MODE button no longer does anything at all, even what I program in. It seems this affects the System.buttonPushed()
value.
if (HAL_Core_Mode_Button_Pressed(1)) {
HAL_Core_Mode_Button_Reset(BUTTON1);
}
How can I go about using the MODE button exactly as I would an external button, with no extra Particle functionality?