-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpower_management.cpp
More file actions
38 lines (32 loc) · 909 Bytes
/
power_management.cpp
File metadata and controls
38 lines (32 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "power_management.h"
#include "Arduino_LPS22HB.h"
#include "Arduino_APDS9960.h"
#include <PDM.h>
#include <mbed.h>
using namespace mbed;
using namespace rtos;
// Light sleep - uses mbed RTOS sleep
void enterLightSleep(uint32_t durationMs) {
// This allows the CPU to enter low-power mode while maintaining peripherals
ThisThread::sleep_for(std::chrono::milliseconds(durationMs));
}
void sleepUnusedSensors(int currentMode) {
// Pressure sensor can be put to sleep when not in use
if (currentMode != 0) {
BARO.end();
}
// APDS9960 has lower power modes
if (currentMode != 1 && currentMode != 2 && currentMode != 3) {
// not using proximity, gesture, or color
// APDS.end();
}
// PDM microphone consumes power when running
if (currentMode != 7) {
// PDM.end();
}
}
void wakeAllSensors() {
BARO.begin();
// APDS.begin();
// PDM.begin(1, 16000);
}