-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_modul.h
More file actions
85 lines (66 loc) · 2.21 KB
/
Copy pathtime_modul.h
File metadata and controls
85 lines (66 loc) · 2.21 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
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef TIME_MODUL_HPP
#define TIME_MODUL_HPP
#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "rgb_lights.h"
//LiquidCrystal_I2C lcd(0x3f,16,2); // 0x3f address of display // columns // rows
#include "main_menu.h"
class Time_modul: public Main_menu{
private:
const RTC_DS1307 rtc; //inicialize class
const m_RGB_LIGHTS *m_rgb; //inicialize class
const LiquidCrystal_I2C *lcd; // 0x3f address of display // columns // rows
public:
Time_modul() : lcd (new LiquidCrystal_I2C (0x3f,16,2)), m_rgb(new m_RGB_LIGHTS){}
void settings(){
lcd->init(); //init for inicialize display
Serial.println("test");
lcd->begin (16,2); // initialize the lcd
lcd->backlight();//To Power ON the back light
if (!this->rtc.begin()){
lcd->print("Couldn't find RTC");
while (1);
}
if (!this->rtc.isrunning()){ // check if rtc module is running
lcd->print("RTC is NOT running!");
}
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
//rtc.adjust(DateTime(2022, 5, 4, 3, 0, 0));// to set the time manually
delay(4900);
}
~Time_modul(){
delete m_rgb;
//delete lcd;
};
void loops(){
m_rgb->m_RGB_color(255, 255, 125); //red
DateTime now = this->rtc.now(); //create object with rtc module
lcd->setCursor(0, 1); // second column on display
lcd->print("TIME"); //printing data on the lcd screen
lcd->print(" ");
lcd->print(now.hour());
lcd->print(':');
lcd->print(now.minute());
lcd->print(':');
lcd->print(now.second());
lcd->print(" ");
lcd->setCursor(0, 0); // first column on display
lcd->print("DATE");
lcd->print(" ");
//lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
//lcd.print(" ");
lcd->print(now.day());
lcd->print('/');
lcd->print(now.month());
lcd->print('/');
lcd->print(now.year());
lcd->print(" ");
delay(4900);
lcd->clear();
}
LiquidCrystal_I2C *lcd_getter(){
return this->lcd;
}
};
#endif