Power
class Power
重要
Power Class的方法依赖 M5.begin()
。
调用 Power 对象的所有方法,需要放在 M5.begin()
的后面。
Methods
- Power.setExtOutput(enable: bool, port: int = 0xFF) None
设置外接端口的电源输出。
enable
为 True 时,外接端口电源为输出模式。enable
为 False 时,外接端口电源为输入模式。port
为端口号,可选值请参考 class PORT, 仅在 M5Stack Station 有效。UIFLOW2:
- Power.setUsbOutput(enable: bool) None
设置主 USB 端口的电源输出。
enable
为 True 时,主 USB 端口电源为输出模式。enable
为 False 时,主 USB 端口电源为输入模式。UIFLOW2:
- Power.getUsbOutput() bool
获取主USB端口的电源输出。
返回值为
True
, 主 USB 端口电源为输出模式。 返回值为False
, 主 USB 端口电源为输入模式。UIFLOW2:
- Power.setLed(brightness=255) None
打开/关闭电源 LED。
brightness
为亮度值,范围为 0-255。 0 为关闭,255 为最大亮度。UIFLOW2:
- Power.powerOff()
所有电源关闭。
UIFLOW2:
- Power.timerSleep(seconds) None
- Power.timerSleep(minutes, hours) None
- Power.timerSleep(minutes, hours, date, weekDay) None
睡眠和定时器启动。 启动条件可以通过参数指定。
seconds
: 取值范围是 1 - 15300, 单位是秒。minutes
: 取值范围是 0 - 59, 单位是分钟。hours
: 取值范围是 0 - 23, 单位是小时。date
: 取值范围是 1 - 31, 单位是天。weekDay
: 取值范围是 0 - 6。UIFLOW2:
- Power.deepSleep(micro_seconds: int = 0, wakeup: bool = True)
ESP32 深度睡眠。
micro_seconds
: 唤醒的微秒数。wakeup
: 是否唤醒。UIFLOW2:
- Power.lightSleep(micro_seconds: int = 0, wakeup: bool = True)
ESP32 浅睡眠。
micro_seconds
: 唤醒的微秒数。wakeup
: 是否唤醒。UIFLOW2:
class PORT
Constants
- PORT.A
端口 A。
- PORT.B1
端口 B1。
- PORT.B2
端口 B2。
- PORT.C1
端口 C1。
- PORT.C2
端口 C2。
- PORT.USB
USB 端口。
- PORT.HAT
HAT 端口。
- PORT.ALL
所有端口。