Battery

From Playdate Community Wiki
Revision as of 03:53, 5 April 2024 by Paulstraw (talk | contribs) (Create Battery page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Playdate, like many other portable electronic devices, is powered by a lithium-ion battery. It contains a single 3.7 V cell rated at 740 mAh[1].

Battery life

Panic rates Playdate's battery for "14 days standby clock" and "8 hours active"[2]. Just like any other piece of electronics, performing different tasks places different demands on Playdate's battery. Purchasing and downloading games is one example of an energy-intensive task that surprises many people. Using the Wi-Fi radio and doing lots of disk writes are both power-hungry operations. Apps and games all have unique energy needs depending on what they do and how heavily they've been optimized.

Unlike smartphones and some other portable electronics, Playdate lacks the necessary circuitry to accurately track state of charge (SoC)[3]. This means the percentage battery indicator is just an estimate. Playdate uses a map of voltages to percentages (likely some sort of lookup table or function) while charging or discharging. It also applies some logic when switching between charging states (and may take other things into account that haven't been made public). However, this approach will always be limited due to the issues described below.

State of charge

State of charge (SoC) is the term for how much capacity remains in a battery. Unlike a tank of water, it's not possible to look at or weigh a battery to determine its capacity. One way of estimating SoC is to check the battery voltage.

Batteries are commonly said to be "fully" charged or discharged when their resting voltage is some number depending on their chemistry. For 3.7 V nominal lithium-ion batteries, 4.2 V is usually fully charged, while fully discharged is around 3.4 V[4]. However, using voltage alone to determine state of charge is limited for several reasons.

First, batteries are designed to provide as close to a constant voltage as possible throughout their discharge cycle. This design goal is directly counter to the goal of getting a precise SoC measurement from voltage alone. Lithium-ion batteries also happen to have a particularly flat "discharge curve", making this approach even less accurate than usual.

Note that "resting" voltage is used when discussing a battery's state of charge. As the load on a battery changes, its voltage also changes. A large load causes the battery voltage to drop more than a small one. However, when the load is removed, the voltage will creep back up to a point. Therefore, reading instantaneous voltage can't accurately give the SoC unless the load (discharge current) is also known.

The varying load on the battery also plays a role in the battery's effective capacity! In an "ideal battery", it wouldn't matter how quickly you drained it. If you could pull 10 Wh from a battery, it wouldn't matter if you did it in 5 hours or 5 minutes. However, in the real world, draining a battery more quickly does reduce its effective capacity. This effect can be approximated using a formula called Peukert's law, but again, the discharge current must be known to apply it.

The varying load on the battery also plays a role in the battery's effective capacity. An "ideal" battery wouldn't change capacity based on its load size. That is, consuming 10 watt-hours from a battery would drain it the same amount whether consumed in 5 hours or 5 minutes. However, in the real world, draining a battery more quickly does reduce its effective capacity. This effect can be approximated using a formula called Peukert's law, but again, the discharge current must be known to apply it.

APIs

Panic provides several APIs related to the battery:

  1. getBatteryPercentage (C, Lua)
  2. getBatteryVoltage (C, Lua)
  3. getPowerStatus (Lua)
  4. Low power (kEventLowPower in C, deviceWillSleep in Lua)