# Battery Charge level support by Haxe Std or Sys?

**URL:** <https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627>\
**Category:** Haxe\
**Created:** [March 27, 2019, 4:59pm UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627 "2019-03-27T16:59:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RMax](https://community.haxe.org/user_avatar/community.haxe.org/rmax/32/662_2.png) [@RMax](https://community.haxe.org/u/RMax)\
**Post date:** [March 27, 2019, 4:59pm UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627/1 "2019-03-27T16:59:03Z")

</div>

Since practically all devices except Desktops and Servers are Battery powered I wanted my app to be a “good citizen” by not draining down the Battery. In latest 4.0 rc2 the only Battery API found was for JavaScript ( Haxe\_Toolkit\_4\_0\_rc2/haxe/std/js/html/BatteryManager.hx )

**Are there plans for a cross Language (and hopefully cross OS) Battery API anytime soon ?**  
Nice if info about Charging status (Charging or running on Batteries) was part of API.  
Thanks!

---

<div class="post-metadata">

**Author:** ![mark.knol](https://community.haxe.org/user_avatar/community.haxe.org/mark.knol/32/50_2.png) [@mark.knol](https://community.haxe.org/u/mark.knol)\
**Post date:** [March 27, 2019, 5:20pm UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627/2 "2019-03-27T17:20:55Z")

</div>

Not on all platforms “battery” is a thing, so I’m not sure if that’s even doable.

---

<div class="post-metadata">

**Author:** ![Kyliathy](https://community.haxe.org/user_avatar/community.haxe.org/kyliathy/32/452_2.png) [@Kyliathy](https://community.haxe.org/u/Kyliathy)\
**Post date:** [March 27, 2019, 11:42pm UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627/3 "2019-03-27T23:42:26Z")

</div>

@RMax even if desktops and servers don’t have a battery, both Windows and Linux have plenty of API support for that.

@mark.knol Why would it not be doable? Does something in std have to work everywhere? (maybe I’m missing something 🙂). There are plenty of cases where only certain targets are supported for certain Haxe features.

I think battery is more of a cross-platform thing than many other things 🙂. Don’t several of Haxe targets such as C# and Java already have plenty of power management API? Is there even any OS without such API? Perhaps some variants of \*nix, without certain kernel features.

In any case, perhaps a third party lib could handle this. In any case, more and more devices rely on batteries as the world goes more and more mobile.

---

<div class="post-metadata">

**Author:** ![kevinresol](https://community.haxe.org/user_avatar/community.haxe.org/kevinresol/32/272_2.png) [@kevinresol](https://community.haxe.org/u/kevinresol)\
**Post date:** [March 28, 2019, 7:04am UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627/4 "2019-03-28T07:04:46Z")

</div>

This should be done in a library.

---

<div class="post-metadata">

**Author:** ![RMax](https://community.haxe.org/user_avatar/community.haxe.org/rmax/32/662_2.png) [@RMax](https://community.haxe.org/u/RMax)\
**Post date:** [March 28, 2019, 2:30pm UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627/5 "2019-03-28T14:30:03Z")

</div>

I am OK with the Battery Charge info and some related Power Management info being in a library.

I think that this is so important that when a library is created it should be supported by the Haxe Foundation just like the various target languages are supported.

---

<div class="post-metadata">

**Author:** ![mark.knol](https://community.haxe.org/user_avatar/community.haxe.org/mark.knol/32/50_2.png) [@mark.knol](https://community.haxe.org/u/mark.knol)\
**Post date:** [April 1, 2019, 9:13am UTC](https://community.haxe.org/t/battery-charge-level-support-by-haxe-std-or-sys/1627/6 "2019-04-01T09:13:46Z")

</div>

I agree creating a library for this would probably be good idea. I wouldn’t wait until the Haxe Foundation will create one. So feel free to roll out your own.
