-
Notifications
You must be signed in to change notification settings - Fork 0
/
demoTime.js
144 lines (130 loc) · 3.44 KB
/
demoTime.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict';
const pngtolcd = require('png-to-lcd');
const Oled = require('../');
const font = require('oled-font-5x7');
const temporal = require('temporal');
var oled = new Oled({
width: 128,
height: 64,
});
(async() => {
await test(oled);
})();
// sequence of test displays
async function test(oled) {
// // if it was already scrolling, stop
// oled.stopScroll();
// clear first just in case
await oled.update();
// make it prettier
// await oled.dimDisplay(true);
temporal.queue([
{
delay: 100,
task: async function() {
// draw some test pixels
await oled.drawPixel([
[0, 0, 1],
[127, 0, 1],
[0, 63, 1],
[127, 63, 1],
]);
}
},
{
delay: 2000,
task: async function() {
await oled.clearDisplay();
// display a bitmap
pngtolcd(__dirname + '/images/cat-128x64.png', true, async function(err, bitmapbuf) {
oled.buffer = bitmapbuf;
await oled.update();
});
}
},
{
delay: 2000,
task: async function() {
await oled.clearDisplay();
// display text
await oled.setCursor(0, 0);
await oled.writeString(font, 1, 'Cats and dogs are really cool animals, you know.', 1, true, 2);
}
},
{
delay: 2000,
task: async function() {
await oled.clearDisplay();
// draw some lines
await oled.drawLine(0, 0, 127, 63, 1);
await oled.drawLine(0, 63, 127, 0, 1);
await oled.drawLine(63, 0, 63, 63, 1);
await oled.drawLine(0, 31, 127, 31, 1);
}
},
{
delay: 2000,
task: async function() {
await oled.clearDisplay();
// draw a rectangle
await oled.fillRect(0, 0, 10, 20, 1);
}
},
{
delay: 2000,
task: async function() {
// create concenctric rectangle outlines
await oled.clearDisplay();
//calc how many squares we can fit on the screen
var padding = 2;
var square_count = ((128 / 2 ) / (padding * 2) ) - 1;
for(var i = 0; i < square_count; i ++){
var x = ((i + 1) * padding);
var y = ((i + 1) * padding);
var w = 128 - (x * padding);
var h = 64 - (y * padding);
await oled.drawRect(x, y, w, h, 1, false);
}
await oled.update();
}
},
{
delay: 2000,
task: async function() {
// create concenctric circle outlines
await oled.clearDisplay();
var x = 128 / 2;
var y = 64 / 2;
var radius = 64 - 1
//calc how many circles we can fit on the screen
var circle_count = radius / 3;
for(var i = 0; i < circle_count; i++){
var r = radius - (i * 3);
await oled.drawCircle(x, y, r, 1, false);
}
await oled.update();
}
},
// {
// delay: 2000,
// task: async function() {
// oled.clearDisplay();
// // display text
// oled.setCursor(0, 7);
// oled.writeString(font, 2, 'SCROLL!', 1, true, 1);
// oled.startScroll('left', 0, 6);
// }
// },
// {
// delay: 2000,
// task: async function() {
// oled.stopScroll();
// oled.clearDisplay();
// oled.update();
// oled.setCursor(0, 7);
// oled.writeString(font, 2, 'DIAGONAL SCROLL', 1, true, 1);
// oled.startScroll('left diagonal', 0, 15);
// }
// }
]);
}