Closed spatcho closed 4 months ago
Hi there, In my case, I use long press to turn on/off and short press to wakeup/sleep, try twist your code inside,
1st, make a bool pmu_flag = false;
bool pmu_flag = false;
2nd, custom function,
void setFlag(void) {
pmu_flag = true;
}
3rd, setup the interrupt in setup(),
pinMode(PMU_INPUT_PIN, INPUT_PULLUP); // the shared pin 6 of SoC and PMU. While DC1 power supply remained, SoC can be wakeup by this pin. And PMU can also be forced power off by long press this pin.
attachInterrupt(PMU_INPUT_PIN, setFlag, FALLING);
// Close other IRQs
PMU.disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
// Clear all interrupt flags
PMU.clearIrqStatus();
// Enable the required interrupt function
PMU.enableIRQ(XPOWERS_AXP2101_PKEY_SHORT_IRQ); //POWER KEY
4th, put a trigger in loop();
if (pmu_flag) {
pmu_flag = false;
// Get PMU Interrupt Status Register
uint32_t status = PMU.getIrqStatus();
if (PMU.isPekeyShortPressIrq()) {
// your codes here...
}
}
It worked, thank you
Shall I close it ?
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Good day,
I would like to keep using the power button on / off functionality, and also use the button to i.e. turn on an oled screen. Per example 4s press to turn off, 2s press to turn on, and short press to catch specific code. I see there is interrupt available but if my use case is possible, could I have a short code example ?