-
-
Save rwaldron/3827388 to your computer and use it in GitHub Desktop.
Trying spaces over zeroes for led-matrix
This file contains hidden or 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
" 11 11 ", | |
"1 11 1", | |
"1 1", | |
"1 1", | |
" 1 1 ", | |
" 1 1 ", | |
" 11 ", | |
" " | |
vs | |
"01100110", | |
"10011001", | |
"10000001", | |
"10000001", | |
"01000010", | |
"00100100", | |
"00011000", | |
"00000000" |
This file contains hidden or 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
five.LedControl.prototype.draw = function( addr, input ) { | |
// Arrays of strings, numbers | |
if ( Array.isArray(input) ) { | |
// Enumerate input and queue a task to write | |
// each "row" on nextTick | |
input.forEach(function( row, k ) { | |
// If |input| is an array of strings, | |
// normalize each "row" by converting | |
// spaces to "0". This allows users to create | |
// human readable "art". | |
// parse the string to int with a base 2 radix | |
if ( typeof row === "string" ) { | |
row = parseInt( row.replace(/ /g, "0"), 2 ); | |
} | |
process.nextTick(function() { | |
// console.log( row ); | |
this.row( 0, k, row ); | |
}.bind(this)); | |
}, this); | |
} else { | |
// TODO: | |
// - handling byte arrays for MATRIX CHARS | |
// - seven segment | |
// - ? | |
if ( LedControl.MATRIX_CHARS[ input ] ) { | |
this.char( addr, input /* ? */ ); | |
} | |
} | |
return this; | |
}; |
This file contains hidden or 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
var lc = new five.LedControl(); | |
[ | |
{ | |
type: "zeros", | |
data: [ | |
"01100110", | |
"10011001", | |
"10000001", | |
"10000001", | |
"01000010", | |
"00100100", | |
"00011000", | |
"00000000" | |
], | |
}, | |
{ | |
type: "spaces", | |
data: [ | |
" 11 11 ", | |
"1 11 1", | |
"1 1", | |
"1 1", | |
" 1 1 ", | |
" 1 1 ", | |
" 11 ", | |
" " | |
] | |
} | |
].forEach(function( test ) { | |
console.log( test.type ); | |
lc.draw( 0, test.data ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment