cryptoadvance / specter-diy

DIY airgapped hardware wallet that uses QR codes for communication with the host
MIT License
447 stars 75 forks source link

Misleading battery status #224

Open moneymanolis opened 1 year ago

moneymanolis commented 1 year ago

After fully charging the battery is never showing a full bar and it very quickly deteriorates from green to orange. I am not sure whether this is due to my device or a more general problem, e.g. rounding errors. Using Specter Shield with battery.

Related to this, it would be a better UX to see a charging symbol when charging the DIY while on. Or is the charging too minimal when on? @stepansnigirev

stepansnigirev commented 1 year ago

The battery status is implemented here: https://github.com/cryptoadvance/specter-diy/blob/master/src/platform.py#L267

Right now it's a simple linear interpolation based on some values from the datasheet.

If you want to make a proper display of the battery status you can calibrate it. For that I'd suggest writing a script that will:

Then you can charge the battery to 100%, and keep the script running until the device turns off. Then we can plot the results and see how we should change the function to return better estimates.

Charging is close to zero when the device is on, depending on the device can be even negative. It should be possible to optimize the power consumption but I didn't put any effort into that. For example, currently the display is fully refreshed even if nothing happens on the screen, but most screens are static. So one optimization would be to refresh the display only when touch is detected.