How can I make a battery komponent in KLWP/KWGT?

So I was wondering if you could do the same as with weather icons, just with battery level (Maybe even Wi-Fi strength or Mobile signal) in a komponent. If it's possible, how can I do it? I am sorry that I'm such a noob at this :( Thanks for help anyway :)

Hi! Yes, for sure its possible, if you want to do it based on bitmaps like the weather icons the basic idea is the following:

  • Add a Komponent to your screen
  • Select the "new" icon to add an empty one
  • Go to the Globals section
  • Add a new Global of type Bitmap, call it for example "battlow"
  • Add an image of a low battery to it
  • Add new globals with other states like "battmed" "batthigh"
  • Go back to the main list of items
  • Add an "Image Module"
  • Go to the Image tab, select the "Bitmap" option, turn it into a formula with the formula icon
  • Now comes the trick, you need to select an image based on the battery status, a very simple one would be:
    • $if(bi(level) < 20, gv(battlow), bi(level) < 50, gv(battmed), gv(batthigh))$
  • The formula will select the global "battlow" if battery level is less then 20, the "battmed" one if less than 50 otherwise the batthigh
  • Done, you can save and press the export button on your komponent so it will be reusable, the user will be able to change the 3 bitmaps so it will be able to easily adapt it to their settings

Hi, great advice and I managed to get it working just fine so many thanks for that!

One additional question though; my battery theme also includes 5 "battery charging" icons, indicating the current battery level and a charging symbol. So, how can I integrate these icons in the formula so that whenever you hook up your phone it shows the charging icon with its appropiate level?

Like before, tou have to add more global images for the “chargingLevels”, something like battlowch, battmedch, batthighch.
Then based on the example above you need to check in your if statements if the phone is charging. This is done with bi(charging) which returns 1 when phone is charging, so:

$if(bi(level) < 20 & bi(charging)=0, gv(battlow), bi(level) < 50 & bi(charging)=0, gv(battmed), bi(level)>=50 & bi(charging)=0, gv(batthigh), bi(level) < 20, gv(battlowch), bi(level) < 50, gv(battmedch), gv(batthighch))$

The example features 3 states, you can add more for your five states once you decided how to divide the levels (I do for steps of 20, since you have 5 images)