mattrossman / forecaswatch2

Open source revival of the beloved ForecasWatch Pebble watchface
https://apps.rebble.io/en_US/application/5dcdca6ac393f50cf6dbc264
GNU General Public License v3.0
36 stars 13 forks source link

Battery level incorrect when loading watch after battery level has changed #29

Closed clach04 closed 4 years ago

clach04 commented 4 years ago

I think this is true for all battery level changes but I'm documenting what I saw today:

This appears to be due to the watchface persisting and then reading the battery level to storage. I'm not sure why it does this. I'll attach a quick fix but I think the persistence code should be removed.

clach04 commented 4 years ago

Recommend removing:

mattrossman commented 4 years ago

Good catch. I think the reason I persisted the battery level was because I was dead set on using the battery level that I already received from battery_state_service_subscribe rather than making another call to battery_state_service_peek. In hindsight, peeking the battery level is probably more efficient than saving and accessing from storage.

I'll merge that in and remove the persistence stuff sometime soon.

clach04 commented 4 years ago

I've been thinking about this. I still think my quick fix is the best thing for now. One idea would be to refactor the persist battery code to use a static/global variable then the peek in my quick fix could be removed.

That way the form would be the same but the location and name of the function calls would be the same.

mattrossman commented 4 years ago

Included in v1.11.0