Skip to content

Dynamically scale system clock based on load

schneider requested to merge schneider/dynamic-clock-scaling into master

Requires at least !478 (merged) to be merged first.

This dynamically adapts the system clock speed based on the following parameters:

  • Is the second core currently waiting for epicardium to finish an API call?
  • Is USB connected?
  • Do we have enough time to reasonably go to sleep?

It tries to keep time on epicardium roughly in line with the wall clock. Slight drift is expected though.

@rahix I'm wondering if I should add a call to the epicardium API which explicitly turns on this behaviour. The current downside is that l0dables will experience a significant drift in their systick time.

Together with the other changes we achieve the following consumption (BLE off):

  • Simple time.sleep(1) loop with display off: 2.29 mA (before: 6.13 mA)
  • G-Watch: 3.99 mA (before 7.7 mA)

This equates to 90% - 160% longer battery life.

With BLE active, the consumption increases by 0.92 mA (no connection) / 1.43 mA (active connection). In this case we are looking at 68% to 100% longer battery life (assuming that the extra BLE consumption is the same in current master).

Edited by schneider

Merge request reports