Skip to content

Commit aefa8ce

Browse files
committed
Merge pull request beyondscreen#24 from usefulthink/new-index-mapping
add new index-mapping for LED-panels wired in alternating rows
2 parents e7c10e2 + e6be847 commit aefa8ce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = function(width, height) {
2+
var map = new Uint16Array(width*height);
3+
for(var i = 0; i<map.length; i++) {
4+
var row = Math.floor(i/width), col = i % width;
5+
6+
if((row % 2) === 0) {
7+
map[i] = i;
8+
} else {
9+
map[i] = (row+1) * width - (col+1);
10+
}
11+
}
12+
13+
return map;
14+
};

0 commit comments

Comments
 (0)