-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed exports changed default mapping function to snake cabling
- Loading branch information
Showing
20 changed files
with
864 additions
and
25 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// sendSimple.js | ||
|
||
var Canvas = require("canvas"); | ||
var CanvastoE131 = require("../"); | ||
|
||
var canvas = new Canvas(10,10); | ||
|
||
//create a simple canvas with an image on it | ||
var context = canvas.getContext('2d'); | ||
context.fillStyle="white"; | ||
context.fillRect(0,0,10,10); | ||
|
||
|
||
// connect the canvas to the sender with mapping | ||
var output = new CanvastoE131(canvas, {host: "10.1.1.5"}); | ||
|
||
|
||
output.send(); | ||
|
||
|
||
process.on ("SIGINT", function(){ | ||
output.close(); | ||
process.exit(1); | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// sendSimpleFlipped.js | ||
|
||
|
||
var Canvas = require("canvas"); | ||
var CanvastoE131 = require("../"); | ||
|
||
var canvas = new Canvas(10,10); | ||
|
||
//create a simple canvas with an image on it | ||
var context = canvas.getContext('2d'); | ||
context.fillStyle="white"; | ||
context.fillRect(0,0,10,10); | ||
|
||
// console.log(CanvastoE131); | ||
// connect the canvas to the sender with mapping | ||
// Pass in the mapping function this time - you can pass your own | ||
// CanvastoE131.mapping.snake is the default, we are passing it through the flip function to flip the matrix diagonally | ||
var output = new CanvastoE131(canvas, {host: "10.1.1.5"}, CanvastoE131.mapping.flipDiagonalFunction(CanvastoE131.mapping.snake)); | ||
|
||
|
||
output.send(); | ||
|
||
|
||
process.on ("SIGINT", function(){ | ||
output.close(); | ||
process.exit(1); | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// simpleAnimation.js | ||
|
||
|
||
var Canvas = require("canvas"); | ||
var CanvastoE131 = require("../"); | ||
|
||
var canvas = new Canvas(16,16); | ||
|
||
|
||
var output = new CanvastoE131(canvas, {host: "10.1.1.5"}); | ||
|
||
|
||
|
||
function draw(x, y) { | ||
var context = canvas.getContext('2d'); | ||
context.save(); | ||
// Each time before drawing the Rectangle in a new position the previous one was deleted | ||
context.clearRect(0, 0, 16, 16); | ||
context.fillStyle = "white"; | ||
context.fillRect(0, 0, 16, 16); | ||
|
||
context.fillStyle = "black"; | ||
//We will create an rectangle whose X cordinate we will change in a loop . | ||
context.fillRect(x, 5, 5, 5); | ||
|
||
x++; | ||
if(x > 15) { x = 0;} | ||
|
||
// Uncomment the following to see snaps of the canvas | ||
// var fs = require('fs'), | ||
// out = fs.createWriteStream(__dirname + '/simpleAnimation.png'), | ||
// stream = canvas.pngStream(); | ||
|
||
// stream.on('data', function(chunk){ | ||
// out.write(chunk); | ||
// }); | ||
|
||
|
||
context.restore(); | ||
output.send(); | ||
setTimeout(function() {draw(x,y);}, 40); | ||
} | ||
|
||
draw(0,0); | ||
|
||
|
||
|
||
|
||
process.on ("SIGINT", function(){ | ||
output.close(); | ||
process.exit(1); | ||
}); | ||
|
||
// output.close(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
// index.js | ||
|
||
module.exports = require("./lib/CanvastoE131.js"); | ||
var CanvastoE131 = require("./lib/CanvastoE131.js"); | ||
|
||
CanvastoE131.mapping = { | ||
rows : require("./lib/mapping/rows.js"), | ||
snake : require("./lib/mapping/snake.js"), | ||
flipDiagonalFunction : require("./lib/mapping/flipDiagonalFunction.js") | ||
}; | ||
|
||
module.exports = CanvastoE131; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//flipDiagonalFunction.js | ||
|
||
module.exports = function(fn){ | ||
return function(sourceX, sourceY, width, height){ | ||
return fn(sourceY, sourceX, height, width); | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//rows.js | ||
|
||
module.exports = function(sourceX, sourceY, width, height){ | ||
var channelNumber = (sourceX * 3) + (sourceY * width * 3) + 1; | ||
return{universe: (Math.floor(channelNumber / 512) + 1), channel: channelNumber % 512}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// snake.js | ||
|
||
|
||
module.exports = function(sourceX, sourceY, width, height){ | ||
var channelNumber; | ||
if(sourceY % 2){ | ||
//We are on an odd row | ||
channelNumber = ((width - sourceX - 1) * 3) + (sourceY * width * 3) + 1; | ||
}else{ | ||
channelNumber = (sourceX * 3) + (sourceY * width * 3) + 1; | ||
} | ||
|
||
return{universe: (Math.floor(channelNumber / 512) + 1), channel: channelNumber % 512}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
REPORTER = landing | ||
|
||
test: | ||
@NODE_ENV=test ./node_modules/.bin/mocha --reporter $(REPORTER) | ||
|
||
test-debug: | ||
@NODE_ENV=test ./node_modules/.bin/mocha debug --reporter $(REPORTER) | ||
|
||
test-w: | ||
@NODE_ENV=test ./node_modules/.bin/mocha \ | ||
--reporter $(REPORTER) \ | ||
--growl \ | ||
--watch | ||
|
||
.PHONY: test test-w |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ output.close(); | |
|
||
|
||
|
||
|
||
//send the image to the server | ||
|
||
|
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
var Controller = require("../lib/E131Controller.js"); | ||
var Controller = require("../../lib/E131Controller.js"); | ||
|
||
var aController = new Controller("10.1.1.5"); | ||
|
||
|
||
|
||
var i =0; | ||
|
||
setInterval(function(){ | ||
i++; | ||
i = Math.min(i, 512); | ||
console.log(i); | ||
aController.setChannel(1,i,255); | ||
|
||
aController.setChannel(2,i,255); | ||
|
||
aController.send(); | ||
},40); |
Oops, something went wrong.