-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsleep_mode.cpp
41 lines (37 loc) · 2.32 KB
/
sleep_mode.cpp
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
/* ********************************************************************************************** */
/* */
/* Smart Watch Firmware ::::::::: ::: */
/* sleep_mode.cpp :+: :+: :+: :+: */
/* +:+ +:+ +:+ +:+ */
/* By: Roman Alexandrov <r.aleksandroff@gmail.com> +#++:++#: +#++:++#++: */
/* +#+ +#+ +#+ +#+ */
/* Created: 2023/06/28 14:49:16 #+# #+# #+# #+# */
/* Updated: 2023/11/12 13:48:41 ### ### ### ### */
/* */
/* */
/* This mode turns on during the user's incativity. It shows full-screen analog clock and */
/* updates it once every minute. The mode is adapted to be as power-saving as possible, so */
/* everything Wi-Fi related is unavailable. In this mode the watch sleeps almost all the time. */
/* */
/* ********************************************************************************************** */
#include "header.h"
void ft_sleep_mode(void)
{
int sleep_time;
ft_encoder_handle();
ft_system_clock();
if (rtcMng.second == 0)
{
if (ft_battery_level() < 10)
rtcMng.state_switch = LOWCHARGE;
}
display.clearDisplay();
ft_maxi_analog_clock_ui();
display.display();
ft_encoder_handle();
if (rtcMng.state_switch != LOWCHARGE && rtcMng.controls_tracker == 0)
rtcMng.state_switch = WORK;
system_rtc_mem_write(64, &rtcMng, sizeof(rtcMng)); // save variables in RTC memory
sleep_time = (1000 - millis()) * 1000;
ESP.deepSleep(sleep_time, WAKE_RF_DEFAULT); // go to sleep, keep the work/sleep cycle within 1 second (1000 millis), no Wi-Fi sync needed
}