Open JasonPittenger opened 2 years ago
Is anyone looking into this issue?
I already have a soft power-down routine that uses the touch buttons. However, I'm using the m5 in an environment where I am often wearing gloves. Adding detection of presses to the physical power button would allow me to power up and power down without using any of the touch buttons or the touch screen.
I added my own version, though it is not in the library. Here is my example code.
//Let's read the power button from the m5 AXP chip Wire1.beginTransmission(0x34); Wire1.write(0x46); Wire1.endTransmission(); Wire1.requestFrom(0x34, 1); u8_PowerWasPressed = Wire1.read(); Serial.println(u8_PowerWasPressed); if((u8_PowerWasPressed & 0x01) == 0x01) { //Power button was long pressed! Serial.println("Power Long Press"); //Save all data and safely stop all processes here. M5.Axp.PowerOff(); } else if((u8_PowerWasPressed & 0x02) == 0x02) { //Power button was short pressed! Serial.println("Power Short Press"); M5.Axp.SetPeripherialsPower(false); //Turn off all external peripherials (5V power) SleepProcessor(SLEEP_MSEC(10000)); //Sleep for 10 seconds M5.Axp.SetPeripherialsPower(true); //Turn on all external peripherials (5V power) M5.Axp.SetBusPowerMode(0); //Needed to Turn on all external peripherials for some reason } if(u8_PowerWasPressed & 0x03)
Describe the bug
There's no way to use the power button as a soft power down option. The AXP192 does detect short presses of the power button, and stores it in register 0X46.
This could be solved by the addition of the following function.
bool AXP192::GetPowerPressed() { if (Read8bit(0x46) | 0x02) return true; else return false; }
To reproduce
In environments, this cannot be done.
Expected behavior
I would expect something like this behavior
if(AXP192::GetPowerPressed()) { //Do power down routine AXP192::PowerOff(); }
or
if(AXP192::GetPowerPressed()) { //Do power down routine AXP192::LightSleep(SLEEP_SEC(5)); }
Screenshots
No response
Environment
Additional context
No response
Issue checklist