espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 742 forks source link

E.getPowerUsage to estimate power consumption #2492

Closed gfwilliams closed 5 months ago

gfwilliams commented 5 months ago

We don't know exactly how much power is being used by certain things, but on some devices we do have an idea, and we could expose that to the user.

So it could report:

>E.getPowerUsage()
={
 usage : 5.5, // mA
 d : [
  code : 2,
  BLE : 1,
  accel : 0.5,
  LCD : 2,
  // ...
 ]
}

We could implement something using build_jswrapper.py so it's easy to extend for different devices.

Any thoughts? It feels like a good feature as users often don't have a way to easily check power usage.

halemmerich commented 5 months ago

I like this, it would reduce the code of the powermanager widget by a lot. Backlight power use on the bangles depending on current brightness would be nice too as it is a huge draw.

gfwilliams commented 5 months ago

Fixed with fa73e3103165573bf18f75a8e40e46dee6189ccc