najnesnaj / pinetime-zephyr

pinetime smartwatch nrf52 zephyr
Apache License 2.0
105 stars 20 forks source link

Add battery monitor module #12

Closed nordic-krch closed 4 years ago

nordic-krch commented 4 years ago

Add module for monitoring battery level and detecting charging and external power. Module contains also shell commands for debugging.

Discharge curve probably needs to be tuned in future. battery.c contains two approaches to controlling ADC: zephyr adc api, nrfx driver api. zephyr api is used but it is synchronous so requires that all battery reads are performed from thread context. If it become issue in future we can use nrfx driver directly and get asynchronous callback. Because of that i would keep both implementations for now (nrfx part is not compiled in).

I'm using shell RTT in the example. Will provide short guide how to use shell over RTT in separate PR.

Fixes #9.

nordic-krch commented 4 years ago

Please do not merge it yet. There is an issue with external power connection that i need to solve (and conflict).