-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathmain.js
More file actions
81 lines (73 loc) · 1.73 KB
/
Copy pathmain.js
File metadata and controls
81 lines (73 loc) · 1.73 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
/*
* Copyright (c) 2016-2017 Moddable Tech, Inc.
* Copyright (c) 2019 Wilberforce
*
* This file is part of the Moddable SDK.
*
* This work is licensed under the
* Creative Commons Attribution 4.0 International License.
* To view a copy of this license, visit
* <http://creativecommons.org/licenses/by/4.0>.
* or send a letter to Creative Commons, PO Box 1866,
* Mountain View, CA 94042, USA.
*
*/
import Timer from "timer";
import HD44780 from "HD44780";
let lcd = new HD44780({
sda: 12,
scl: 13,
address: 0x27,
});
// Degree symbol
lcd.createChar( 2,[ 0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00] );
lcd.setCursor(0, 0);
lcd.cursor(true);
// Moddable logo Left and Right parts, 6x8 matrix
lcd.createChar( 0,
[
0b00001110,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00010000,
0b00001110,
] );
lcd.createChar( 1,
[
0b00000000,
0b00111100,
0b00000010,
0b00000010,
0b00000010,
0b00000010,
0b00111100,
0b00000000,
] );
lcd.blink(true);
lcd.blink(false);
lcd.blink(true);
lcd.cursor(false);
lcd.cursor(true);
lcd.setCursor(0, 0);
lcd.setCursor(5, 1);
lcd.setCursor(0, 0);
lcd.print('Moddable '+String.fromCharCode(0)+String.fromCharCode(1));
Timer.repeat(() => {
let date = new Date();
let hours = String(date.getHours());
let minutes = String(date.getMinutes());
let seconds = String(date.getSeconds());
let ampm = (hours > 11 ? ' pm' : ' am');
if (hours > 12)
hours -= 12;
if (1 == minutes.length)
minutes = '0' + minutes;
if (1 == seconds.length)
seconds = '0' + seconds;
let time = hours + ':' + minutes + ':' + seconds + ampm;
lcd.setCursor(0,1).print(time);
lcd.print( ' 20'+String.fromCharCode(2)+'c');
}, 1000);