Arduino-LCD
LCD library for Arduino
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Clock.ino
Go to the documentation of this file.
1
#include "GPIO.h"
2
3
#include "RTC.h"
4
#include "Driver/DS1302.h"
5
#include "Driver/DS1307.h"
6
7
#include "TWI.h"
8
#include "Software/TWI.h"
9
#include "Hardware/TWI.h"
10
11
#include "
LCD.h
"
12
#include "
Driver/MAX72XX.h
"
13
#include "
Driver/PCD8544.h
"
14
#include "
Driver/HD44780.h
"
15
#include "
Adapter/Debug.h
"
16
#include "
Adapter/PP7W.h
"
17
#include "
Adapter/SR3W.h
"
18
#include "
Adapter/SR4W.h
"
19
#include "
Adapter/MJKDZ.h
"
20
#include "
Adapter/GY_IICLCD.h
"
21
#include "
Adapter/DFRobot_IIC.h
"
22
#include "
Shield/LCD4884.h
"
23
#include "
Shield/LCD_Keypad.h
"
24
25
// Configure: HD44780 Adapter; Debug, PP7W, SR3W or TWI PCF8574
26
// LCD::Debug io(Serial);
27
// LCD::PP7W<BOARD::D4, BOARD::D5, BOARD::D6, BOARD::D7, BOARD::D8, BOARD::D9, BOARD::D10> io;
28
// LCD::SR3W<BOARD::D7, BOARD::D6, BOARD::D5> io;
29
// LCD::SR4W<BOARD::D7, BOARD::D6, BOARD::D5, BOARD::D4> io;
30
Software::TWI<BOARD::D1, BOARD::D2>
twi
;
31
// Software::TWI<BOARD::D8, BOARD::D9> twi;
32
// Software::TWI<BOARD::D18, BOARD::D19> twi;
33
// Hardware::TWI twi(100000UL);
34
// Hardware::TWI twi(400000UL);
35
// LCD::MJKDZ io(twi);
36
LCD::GY_IICLCD
io
(
twi
);
37
// LCD::DFRobot_IIC io(twi);
38
39
// Configure: LCD; HD44780, MAX72XX, or PCD8544, LCD4884 or LCD_Keypad
40
HD44780
lcd
(
io
);
41
// MAX72XX<BOARD::D10, BOARD::D11, BOARD::D13> lcd;
42
// PCD8544<BAORD::D5, BOARD::D4, BOARD::D3, BOARD::D2> lcd;
43
// LCD4884 lcd;
44
// LCD_Keypad lcd;
45
46
// Configure: RTC; DS1302 or DS1307
47
// DS1302<BOARD::D11, BOARD::D12, BOARD::D13> rtc;
48
DS1307
rtc
(
twi
);
49
50
void
setup
()
51
{
52
// Initiate display
53
lcd
.
begin
();
54
55
// Set the real-time clock
56
#if defined(AVR)
57
struct
tm now(SUNDAY, 2017, DECEMBER, 31, 23, 59, 00);
58
rtc
.set_time(now);
59
#endif
60
}
61
62
void
loop
()
63
{
64
// Get current time
65
struct
tm now;
66
rtc
.get_time(now);
67
68
// Convert to iso datetime string
69
char
buf[32];
70
isotime_r(&now, buf);
71
72
// Split datetime string and replace colon
73
buf[10] = 0;
74
if
(
lcd
.
HEIGHT
== 1) {
75
static
int
n = 1;
76
lcd
.
cursor_home
();
77
if
(n == 4) {
78
lcd
.print(buf + 2);
79
n = 0;
80
}
81
else
{
82
lcd
.print(buf + 11);
83
n += 1;
84
}
85
}
86
else
{
87
lcd
.
cursor_home
();
88
lcd
.print(buf);
89
lcd
.
cursor_set
(0, 1);
90
lcd
.print(buf + 11);
91
}
92
delay(1000);
93
lcd
.
display_clear
();
94
}
PCD8544.h
HD44780::begin
virtual bool begin()
Definition:
HD44780.h:132
Debug.h
MJKDZ.h
MAX72XX.h
GY_IICLCD.h
SR4W.h
setup
void setup()
Definition:
Clock.ino:50
HD44780::display_clear
virtual void display_clear()
Definition:
HD44780.h:212
HD44780::cursor_set
virtual void cursor_set(uint8_t x, uint8_t y)
Definition:
HD44780.h:245
lcd
HD44780 lcd(io)
LCD::GY_IICLCD
Definition:
GY_IICLCD.h:49
HD44780::HEIGHT
const uint8_t HEIGHT
Definition:
HD44780.h:106
DFRobot_IIC.h
LCD_Keypad.h
rtc
DS1307 rtc(twi)
LCD4884.h
loop
void loop()
Definition:
Clock.ino:62
HD44780
Definition:
HD44780.h:34
LCD.h
SR3W.h
PP7W.h
HD44780.h
io
LCD::GY_IICLCD io(twi)
twi
Software::TWI< BOARD::D1, BOARD::D2 > twi
Definition:
Clock.ino:30
HD44780::cursor_home
virtual void cursor_home()
Definition:
HD44780.h:259
examples
Clock
Clock.ino
Generated on Sat Oct 14 2017 03:06:11 for Arduino-LCD by
1.8.11