forked from htotoo/TCarTrackerSim
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenergy.h
62 lines (49 loc) · 987 Bytes
/
energy.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
void InitEnergySave() //after power on, turn off stuff
{
btStop();
}
void SleepMe()
{
SerialMon.write("Sleeping...\n");
delay(300);
esp_sleep_enable_ext0_wakeup(GPIO_NUM_25, 1);
esp_sleep_enable_timer_wakeup(3600000000*3);
esp_deep_sleep_start();
}
void GpsOn()
{
modem.sendAT("+SGPIO=0,4,1,1");
modem.enableGPS();
modem.sendAT(GF("+CGNSPWR=1"));
lastMillisGpsGet = millis();
}
void GpsOff()
{
modem.sendAT("+SGPIO=0,4,1,0");
modem.sendAT(GF("+CGNSPWR=0"));
modem.disableGPS();
}
void modemPowerOn()
{
pinMode(PWR_PIN, OUTPUT);
digitalWrite(PWR_PIN, LOW);
delay(1000);
digitalWrite(PWR_PIN, HIGH);
}
void modemPowerOff()
{
pinMode(PWR_PIN, OUTPUT);
digitalWrite(PWR_PIN, LOW);
delay(1500);
digitalWrite(PWR_PIN, HIGH);
}
void PrepareSleep()
{
SerialMon.write("Prepare sleep.\n");
DisplayOff();
//todo put everything in prepare sleep mode
GpsOff();
modemPowerOff();
modem.poweroff();
delay(1000);
}