-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay-util.js
61 lines (51 loc) · 1.23 KB
/
display-util.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
var run = function(display, options) {
options = options || {};
var showPrompt = function() {
if (options.prompt) {
if (typeof options.prompt === "function") {
options.prompt();
} else {
display.print(options.prompt);
}
}
};
var process = function(command) {
try {
if (display.caps) {
command = command.toLowerCase();
}
var result = eval(command);
if (result !== undefined) {
display.println(result);
}
} catch (error) {
display.println(error);
}
showPrompt();
display.input(process);
};
showPrompt();
display.input(process);
};
var __font = function(to) {
display.println();
for (var i = 32; i <= to; i++) {
display.print(String.fromCharCode(i));
}
display.println();
for (var i = 32; i <= to; i++) {
display.print(String.fromCharCode(i));
}
display.println();
};
var font7 = function() {
__font(127);
};
var font8 = function() {
__font(255);
};
var clear = function() {
display.reset();
};
var math = Math;
var array = Array;