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
/**** asString - can also convert Object.create(null) to string ****/ | |
asString = function asString (Value) { | |
switch (Value) { | |
case undefined: return '[object Undefined]'; | |
case null: return '[object Null]'; | |
default: | |
if (Array.isArray(Value)) { return '[object Array]' }; | |
return ( |
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
/**** basic JavaScript object whose properties could be used for unit testing ****/ | |
function newTestObject () { | |
return { | |
undefined:undefined, | |
null:null, | |
true:true, false:false, | |
negativeInteger:-123, zero:0, positiveInteger:123, | |
negativeInfinity:-Infinity, Number:Math.PI, positiveInfinity:Infinity, NaN:NaN, | |
emptyString:'', String:'Test', |
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
// how many characters can be shown per line on Bangle.js using the default font? | |
Bangle.setLCDMode(); // use normal display mode | |
g.clear(); | |
g.setFont('4x6'); | |
let Digits = '1234567890'; | |
let StringToDraw = ''; | |
for (let i = 0; i < 8; i++) { StringToDraw += Digits } | |
StringToDraw += '\n'; |
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(); |
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
// fills the display of a Bangle.js with a color stripe | |
Bangle.setLCDMode(); // use normal display mode | |
g.clear(); | |
/**** HSVtoRGB ****/ | |
// see https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB | |
function HSVtoRGB (h, s, v) { | |
let c = v*s; |
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
// fills the display of a Bangle.js with a color disc | |
Bangle.setLCDMode(); // use normal display mode | |
g.clear(); | |
/**** HSVtoRGB (especially for Bangle.js and its RGB565 encoding) ****/ | |
// see https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB | |
function HSVtoRGB (h, s, v) { | |
let c = v*s; |
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
Bangle.setLCDMode(); // use normal display mode | |
g.clear(); | |
const Width = g.getWidth(); | |
const Height = g.getHeight(); | |
/**** color mapping (especially for Bangle.js) ****/ | |
function rgb565 (r,g,b) { | |
return (r << 11) | (g << 5) | b; |
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
Bangle.setLCDMode('120x120'); | |
g.clear(); | |
g.setFont("6x8"); | |
const Width = g.getWidth(); | |
const Height = g.getHeight(); | |
/**** show screen ****/ | |
g.drawString('Accelerometer', 5,5); |
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
const CharsPerLine = 60; | |
const LineHeight = 10; | |
let yPosition; | |
/**** clear ****/ | |
function clear () { | |
Bangle.setLCDMode(); // use normal display mode | |
g.clear(); | |
g.setFont("4x6"); |
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
Bangle.setLCDMode('120x120'); | |
g.clear(); | |
const Width = g.getWidth(); | |
const Height = g.getHeight(); | |
/**** color mapping (especially for Bangle.js) ****/ | |
function PaletteEntry (r,g,b) { // 8-bit modes use the "web color palette" | |
return r*36 + g*6 + b; |
OlderNewer