-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystem_clock.cpp
More file actions
73 lines (70 loc) · 3.46 KB
/
system_clock.cpp
File metadata and controls
73 lines (70 loc) · 3.46 KB
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
63
64
65
66
67
68
69
70
71
72
73
/* ********************************************************************************************** */
/* */
/* Smart Watch Firmware ::::::::: ::: */
/* system_clock.cpp :+: :+: :+: :+: */
/* +:+ +:+ +:+ +:+ */
/* By: Roman Alexandrov <r.aleksandroff@gmail.com> +#++:++#: +#++:++#++: */
/* +#+ +#+ +#+ +#+ */
/* Created: 2023/06/28 14:49:16 #+# #+# #+# #+# */
/* Updated: 2023/11/12 13:48:41 ### ### ### ### */
/* */
/* */
/* The function updates values of seconds, minutes, hours, days of the week, days of the */
/* months, months itselves. */
/* */
/* Leap year correction is not yet implemented! */
/* */
/* ********************************************************************************************** */
#include "header.h"
void ft_system_clock(void)
{
rtcMng.second += 1;
if (rtcMng.second == 60)
{
rtcMng.minute += 1;
rtcMng.second = 0;
}
if (rtcMng.minute == 60)
{
rtcMng.hour += 1;
rtcMng.minute = 0;
}
if (rtcMng.hour == 24)
{
rtcValues.day += 1;
rtcValues.week_day += 1;
rtcMng.hour = 0;
rtcMng.minute = 0;
rtcMng.second = 0;
}
if (rtcValues.week_day == 8)
rtcValues.week_day = 1;
switch (rtcValues.month)
{
case 1: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 2: if (rtcValues.day == 29) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 3: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 4: if (rtcValues.day == 31) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 5: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 6: if (rtcValues.day == 31) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 7: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 8: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 9: if (rtcValues.day == 31) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 10: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 11: if (rtcValues.day == 31) { rtcValues.day=1; rtcValues.month+=1; }
break;
case 12: if (rtcValues.day == 32) { rtcValues.day=1; rtcValues.month+=1; }
break;
}
if (rtcValues.month == 13) rtcValues.month = 1;
}