-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSmart_Watch_Firmware.ino
44 lines (40 loc) · 2.65 KB
/
Smart_Watch_Firmware.ino
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
/* ********************************************************************************************** */
/* */
/* Smart Watch Firmware ::::::::: ::: */
/* Smart_Watch_Firmware.ino :+: :+: :+: :+: */
/* +:+ +:+ +:+ +:+ */
/* By: Roman Alexandrov <r.aleksandroff@gmail.com> +#++:++#: +#++:++#++: */
/* +#+ +#+ +#+ +#+ */
/* Created: 2022/07/03 11:28:16 #+# #+# #+# #+# */
/* Updated: 2023/11/12 13:48:41 ### ### ### ### */
/* */
/* */
/* The main file of the project. Here main periferals get initialised then one of operational */
/* modes gets to be chosen. */
/* */
/* ********************************************************************************************** */
#include "header.h"
void setup(void)
{
#ifdef DEBUG
Serial.begin(115200);
#endif
DEBUG_PRINT("Power ON");
pinMode(BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), ft_button_handle, FALLING);
pinMode(TILT_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(TILT_PIN), ft_tilt_detector_handle, CHANGE);
Wire.begin(2,0); // I2C interface initialisation (SDA pin; SCK pin)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // OLED display initialisation (ssd1306 128x64)
system_rtc_mem_read(64, &rtcMng, sizeof(rtcMng)); // restore variables from RTC memory after reboot
display.clearDisplay();
if (rtcMng.state_switch == WORK)
ft_default_mode();
else if (rtcMng.state_switch == SLEEP)
ft_sleep_mode();
else if (rtcMng.state_switch == LOWCHARGE)
ft_low_charge_mode();
else
ft_power_down_recovery();
}
void loop(void) { /* NOTHING IS HERE */ }