Page 1 of 1

BIP battery icon behavior, differs between watch and editor

Posted: 12 Mar 2019, 10:09
by bestego
This difference in behavior can lead to unexpected results, especially when battery icons are used to represent precise battery levels. With the information below, differences can be accounted for and precise behavior can be achieved when being aware of the actual calculation methods.

ImageIndex (defined in JSON file)
ImagesCount (defined in JSON file)
BatteryLevel [0 .. 100] (given by Watch OR WatchFaceEditor)

offset = BatteryLevel * (ImageCount - 1)/100 + 0.5 // WatchFaceEditor
offset = BatteryLevel * (ImageCount - 1)/100 + 1 // Watch

ImageNumber = ImageIndex + INTEGER(offset)


For Watch:
- the needed change in BatteryLevel to get the next ImageNumber, is equal for the whole BatteryLevel range. In other words: equal battery step size over the whole range.
- The image with IndexNumber equal to ImageIndex, will never be selected! The calculation shows that offset is 1 for a BatteryLevel of 0
- the calculation presented above, is derived from extensive measurements

For WatchFaceEditor:
- The first battery stepsize (starting a BatterryLevel 0) and the last battery stepsize (ending at BatteryLevel 100) have half the size of the other battery steps
- The image with IndexNumber equal ti ImageIndex, will be selected at the lowest BatteryLevel close tot 0

Re: BIP battery icon behavior, differs between watch and editor

Posted: 13 Mar 2019, 13:28
by mikebounds
I noticed this too - here is a practical example to make it clearer:

Suppose you want 10 divisions, each representing 10%, then you need to create 11 icons:
1 - 10 icons representing 10%, 20%, ... 90, 100% and an 11th icon representing 0%

On the editor the range for each icon is 0-4, 5-14, 15-24, ... 85-94, 95-100
So each range is 10 except the first and last which are 5 and the way to think about this, is that the image is representing the midpoint and so the 90% icon means the battery is 90% +/- about 5% - so between 85-94 and so then the 100% icon represents 95 - 104, but of course, over 100 is not possible which is why it is half the range. These icons make sense and this would be a good way to implement, however the watch is not implemented like this:

So on the watch, you still need 11 icons - but the ranges are:
0, 1-10, 11-20, .... 81-90, 91-100

So here the first icon is never actually used unless the watch can still be powered with less than 1% battery. The way to think about this, is that the image is representing the maximum percentage and so that the 90% icon means, at best it is 90%, but could be anywhere from 81-90.

Note, if you only use 10 icons representing 10%, 20%, ... 90, 100%, then each range will actually be representing 100 / 9 = 11.11 and the 10% icon will never be shown and so the 20% icon will actually be used for range 1-11% and for example the 50% icon will be used for range 34-44%