API to tell when plugged in to power


Being able to tell from Lua whether the Playdate is connected to power vs. running on battery would be great, especially for certain kinds of "sit there and run" apps such as music players, art toys, note/calendar displays, or clocks. The kinds of apps that will be perfect for the display dock down the road!

For example: I might want to add constant animation to come of my clocks--but only when docked/charging, and then I'd like to disable those effects automatically whenever running on battery.

Being able to distinguish cable-charging vs. dock-charging could be neat too—but not vital!

(From the SDK you can read battery level, and thus judge over time if it's rising or falling, but that's a less-than-ideal workaround.)

1 Like

I believe playdate.getPowerStatus() should do the trick. And if the console is charging but not plugged to USB, you can assume this is on the dock.

If I remember correctly long time ago it was a bit different and some function was returning the charging method. It could return something like "screws" and it was before the dock was announced so we were wondering what screw charging was (or something like that) :smile:


Excellent! Sorry for the oversight—I searched the docs and somehow missed it.