-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.js
84 lines (70 loc) · 1.81 KB
/
display.js
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
var pngtolcd = require('png-to-lcd'),
Oled = require('oled-ssd1306-i2c');
font = require('oled-font-5x7');
temporal = require('temporal');
var oled = new Oled({
width: 128,
height: 64,
});
var invert = true;
var timing = 1000;
function init(){
oled.stopScroll();
oled.clearDisplay();
oled.update();
oled.dimDisplay(true);
temporal.queue([{
delay: 1000,
task: function(){ test_1(); }
},{
delay: 1000,
task: function(){ test_2();}
},{
delay: 10000,
task: function(){
for(let i = 0; i < 36 ; i++){
timing+=1000/(i*0.6+1);
setTimeout(function(){
oled.invertDisplay(invert);
invert=!invert;
}, timing)
}
}
}]);
}
function test_1(){
oled.clearDisplay();
oled.setCursor(0, 0);
oled.writeString(font, 1, 'Launching notMAIL Application', 1, true, 2);
}
function test_2(){
oled.clearDisplay();
pngtolcd(__dirname + '/logo.png', true, function(err, bitmapbuf) {
oled.buffer = bitmapbuf;
oled.update();
});
}
function screen_saver(){
oled.clearDisplay();
pngtolcd(__dirname + '/logo.png', true, function(err, bitmapbuf) {
oled.buffer = bitmapbuf;
oled.update();
});
}
function new_message(title, data, sub, time){
oled.clearDisplay();
oled.stopScroll();
oled.setCursor(0, 0);
oled.writeString(font, 1, sub, 1, false, 2);
oled.drawLine(0,9,127,9,1);
oled.setCursor(0, 12);
oled.writeString(font, 1, title, 1, false, 1);
oled.setCursor(0, 23);
oled.writeString(font, 1, data, 1, true, 1);
//oled.startScroll('right', 0, 18);
}
module.exports = {
init: init,
new_message: new_message,
screen_saver: screen_saver
}