-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.html
More file actions
72 lines (59 loc) · 1.46 KB
/
convert.html
File metadata and controls
72 lines (59 loc) · 1.46 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
<html>
<head>
<title>SystemFont5x7C string converter</title>
<script>
function gen(arr) {
arr = arr.replace("\r",'').split("\n");
var chr = '';
var map = '\nPROGMEM const char * const qdata_map[] = {\n';
var maxl = 0;
arr.forEach(function(x, k){
var newstr = '';
if(maxl<x.length)
{
maxl = x.length;
}
x = x.replace('"','\\"');
for(i=0;i<x.length;i++)
{
var cc = x.charCodeAt(i);
if(cc==1117) cc = 1067;
else if(cc>1099) cc--;
if(cc>1100) cc--;
if(cc>1067) cc-=2;
cc-=912;
newstr += (cc<92) ? x[i] : '\\x'+cc.toString(16).toUpperCase();
}
chr += 'const prog_char qdata_'+k+'[] PROGMEM = "'+newstr+'";\n';
map += '\tqdata_'+k+',\n';
});
map += '};\n';
more = 'unsigned int element_count = '+arr.length+';\n';
more += 'char buffer['+(maxl+1)+'];\n'
document.getElementById('p').innerHTML = '';
document.getElementById('p').appendChild(document.createTextNode(chr+map+more));
}
</script>
<style>
html, body {
padding: 0;
margin: 0;
}
#p, #t {
box-sizing: border-box;
width: 95%;
margin: 20px auto;
height: 45%;
border: 1px solid gray;
padding: 10px;
display: block;
resize: no-resize;
overflow: scroll;
}
</style>
</head>
<body>
<textarea id="t" onchange="gen(this.value)"></textarea>
<pre id="p"></pre>
</body>
</html>