Last active
December 4, 2019 09:49
-
-
Save rozek/1fd3b5bb423c9b7811441c74624398e8 to your computer and use it in GitHub Desktop.
Bangle.js: which character glyphs are available in the code range 0...255?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// which 8-bit character glyphs are available? | |
const LineHeight = 10; | |
let yPosition; | |
/**** clear ****/ | |
function clear () { | |
Bangle.setLCDMode(); // use normal display mode | |
g.clear(); | |
g.setFont('4x6'); | |
yPosition = 0; | |
} | |
/**** println ****/ | |
function println () { | |
let StringToDraw = ''; | |
for (let i = 0, l = arguments.length; i < l; i++) { | |
StringToDraw += arguments[i]; // implicitly also does "toString" | |
} | |
g.drawString(StringToDraw, 0,yPosition); | |
yPosition += LineHeight; | |
} | |
/**** draw a simple ASCII table ****/ | |
let HexDigits = '0123456789ABCDEF'; | |
clear(); | |
println(); | |
println(' | -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F |'); | |
println(' ---+-------------------------------------------------+---'); | |
for (let i = 0; i < 16; i++) { | |
let StringToDraw = ' ' + HexDigits[i] + '- | '; | |
for (let j = 0; j < 16; j++) { | |
let CharCode = i*16 + j; | |
StringToDraw += ' ' + ( | |
(CharCode < 32) || ((CharCode >= 127) && (CharCode < 160)) | |
? ' ' | |
: String.fromCharCode(CharCode) | |
) + ' '; | |
} | |
println(StringToDraw + '| ' + HexDigits[i] + '-'); | |
} | |
println(' ---+-------------------------------------------------+---'); | |
println(' | -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -A -B -C -D -E -F |'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment