My Tab5 Extended GPIO and Power management library.
-
Hi all;
This is something I've been working on; a easy way of taking control of the Tab5's power management circuitry from vanilla MicroPython; without needing a special board build.
https://codeberg.org/easytarget/tab5-egpio-micropython
The README there has the full install and usage notes; plus a list of the (30!) methods it provides. This is deigned to be very simple in use; it is self-contained and lets you:
- Control power on/off for the WiFi chip, Speaker Amplifier, USB-A port and Expansion port 5V power.
- Switch WiFi between internal and external antennas
- Enable and disable battery charging, set the quick charge status, read the charge indicator pin.
- Read the battery voltage and current in/out.
- Detect if headphones are plugged in.
- Set LCD backlight brightness
- Trigger a poweroff event.
- Send reset signals to the LCD, TouchPanel and Camera modules.
Use it to create a power control object and set the device up as you need:
from tab5_egpio import TAB5_EGPIO tab5pwr = TAB5_EGPIO() tab5pwr.wlan_pwr_on() tab5pwr.charge_enable() # later (let the charge controller settle first) voltage, current = tab5pwr.battery_status() print('Battery: {:.2f}V @ {:.3f}A'.format(voltage, current))There are some demo's in the repo that show how to use this in more detail. And I have a page where I am documenting general hardware related Tab5 micropython information at: https://codeberg.org/easytarget/m5-tab5-micropython
[note: I'm cross-posting this here from the micropython official discussions, since it is specific to the Tab5]
-
Hello @easytarget
for me your current implementation to turn off M5Tab5 actually only does a reset.
The power off pulse needs to pulse to turn off M5Tab5. See here.
I modified
poweroff_nowfunction in your library like below:def poweroff_now(self): """Instant full power off. Be sure you want to use this!""" # self._e2.set_output(_PWROFF_PULSE_PIN, HIGH) for x in range(10): self._e2.set_output(_PWROFF_PULSE_PIN, LOW) sleep(0.05) self._e2.set_output(_PWROFF_PULSE_PIN, HIGH) sleep(0.05)and now my M5Tab5 turns off.
Thanks
Felix -
@felmue
Thank you! you are quite right! I hadn't really looked at what was happening properly :-(The pin needs to be toggled
highthenlowwith a ~50ms delay for a full power off, just toggling ithighdoes a full reset (after 1 second). I really wish there was a state diagram (or similar) available for the code in thePMS150Gpower control MCU.I've extended my code to do the required pulse similar to your modification, and added a
reset_device()method too. Plus relevant notes in the README etc, and done a new release.[testing shows that the poweroff happens immediately after the first pulse, I'm not sure why they attempt to pulse several times but I guess they are just making sure.. ;-)]