Skip to content

Instantly share code, notes, and snippets.

@rozek
Last active December 4, 2019 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozek/1fd3b5bb423c9b7811441c74624398e8 to your computer and use it in GitHub Desktop.
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?
// 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