As always, we can make things better and introduce 'nice to have' features. Previously I called them "Distractions (of the Year)". Now, I'll just call them "Decorate Your Robot". But, this is not completely decorative function of the robot - it serves good purpose as well: to keep batteries safe.
Lithium Polymer (and Lithium Ion) batteries are very 'fussy'. They don't like being too cold, or too warm or being overcharged (fortunately today's chargers do cater for that) or, in this case important thing, over-discharged! From my RC days I've learnt that nominal voltage of LiPo battery's is 3.7V per cell. And batteries are quite sensitive of each cell's voltage going much lower. Some specs say that 3.3V its fine, another even go down to 3V, but my experience taught me that if resting voltage of battery, after being used, is at 3.7 or lower - that battery's lifespan is being shortened.
So, to protect battery I have implemented proper monitoring of power status. Flig monitors current and voltage of servos and electronics at every moment and caters for voltage changes by BECs: electronics current is measured on input voltage from battery, while servos current on servos voltage (currently 5V). As both are present we can easily calculate mAh that is taken out of the battery and knowing capacity of battery (in this case 2100mAh) and knowing that we shouldn't ever discharge them more than 80% (for safety reasons I adopted 60-70%) we can make a proper battery monitor which would give us the state of the battery at any time.
As the voltage of each cell is important and cells voltage can be deducted by overall voltage of the battery (by just dividing it by 2) we can interpolate those two information: amount of mAh used and current voltage of the battery to deduct percentage battery is at.
With brand new batteries voltage would stay high up for long and amount mAh is important, while with older batteries voltage would drop quite quickly so for health of cells we should prevent it going too low (below 3.7V). So, all we need to do is take lower of the two to calculate percentage.
Also, our 1.3" screen is perfect for the result:
When battery percentage goes below 20% (due to mAh used or voltage being close to 3.7A) display will start flashing last two boxes in red.
In the last picture we can see that if measured voltage is over 8.5V, we know we used power adapter instead of the battery, so all the warning (different colours of the 'boxes') are going to be disabled.
Also, same display is now used for displaying current current usage. If it goes over 1/3 of nominal (over 130% of resting current) it'll show current on the display. All way to 3500mA (or 3.5A) where it'll display red, flashing full circle...