UCSD-E4E / smartfin-fw2

Smartfin FW 2
GNU General Public License v3.0
1 stars 0 forks source link

Calibration Sleep is not true sleep #28

Open ntlhui opened 3 years ago

ntlhui commented 3 years ago

Currently, calibration sleep is a busy loop until the proper time.

Particle Sleep does not appear to be reliable. Need to either find reliable way to wrap and wait, or alternative method.

ntlhui commented 2 years ago

The current busy loop is in https://github.com/UCSD-E4E/smartfin-fw2/blob/a49e54ead88dc8d0dcd56a6ba210ba82b62e8297/src/tempCal.cpp#L96.

This simply does a busy wait until the appropriate time to capture new data.

With a sufficiently sparse schedule, a significant amount of energy will be burnt here. Is it possible to do an intelligent sleep here?

Proposal:

define time to wait as t.

if t < n, busy wait otherwise use STOP or ULTRA_LOW_POWER (see https://docs.particle.io/reference/device-os/api/sleep-sleep/stop-systemsleepmode/) on resume from STOP or ULTRA_LOW_POWER, it will be critical to check the current time and wait until the correct time to resume sampling.

n needs to be time it takes to drop into the aggressive sleep and resume, plus some buffer time