This program written in node is an interface for controlling small scripts / games to use on a led matrix.
cd dev/
docker-compose up
- Set
Dirto correct directory in run - Create docker container with:
docker-compose up -d - If you want to restart it from now on just run:
docker-compose restart
You can find a small collection of scripts here. Download them to your /scripts folder.
- start buffering of leds before updating and send after update
- add wiimote api for srcipts
- add step by step button to debug scripts
- add service worker with offline cache for pwa support
A script is a small program / game that renders the led matrix. It can handle user input from a wiimote.
- A script can be hot reloaded. So you only have to reload it inside the interface.
var Matrix
// EXPORTS
exports = module.exports = {
'name': 'Skeleton', // name of your script
'init': init
}
function init (_matrix) {
Matrix = _matrix // save matrix api object
Matrix.setTick(1000) // set tick rate to 1 tick per 1000 ms
Matrix.on('started', () => {
console.log(exports.name) // executed when your script should start
})
Matrix.on('stopped', () => {
// executed when your script should stop
})
Matrix.on('update', () => {
// executed when matrix loop tick is send.
// this is the point you should handle your logic.
})
Matrix.on('draw', () => {
// executed when your script should render leds
})
}
Use this api to set leds, get user input and run your logic.
- Matrix.on(event, callback)
- Matrix.size
- Matrix.setTick(speed)
- Matrix.led(x, y, rgb)
- Matrix.ledXY(x, y, rgb)
- Matrix.fill()
- Matrix.clear()
- new Matrix.Drops(chance, multiple, rgb)
- new Matrix.Rect(name, rgb, x, y, width, height)
- Matrix.RGB(r, g, b)
- Matrix.HSV_TO_RGB(h, s, v)
- Matrix.RND(min, max)
- Matrix.RND_COLOR()
Listen to matrix events.
event: The name of the event.callback: Your callback function which is executed after the event is fired.
See this list for possible events:
function () {}
Emitted when matrix is ready and script can start. After this event the update, draw loop is started.
function () {}
Emitted when script is called to stops. After this event the update, draw loop is stopped.
function () {}
Emitted when loop is resumed again.
function () {}
Emitted when loop is paused.
function () {}
Emitted when the matrix loop calls your script to update. This is where your scripts logic should mainly happen.
function () {}
Emitted when the matrix loop calls your script to render.
function (key, value) {}
Emitted when a user sends input via the web interface.
Int : Size of the matrix.
Set the speed you want your scripts logic (update callback) to be executed with.
speedSpeed in milliseconds.
Alias for Matrix.led(x, y, rgb)
Sets a led to rgb at (x / y).
xx coordinate on the matrix (0 is left)yy coordinate on the matrix (0 is top)rgbColor object of type rgb. Normally generated with Matrix.RGB(r, g, b)
Sets all matrix leds to rgb.
rgbColor object of type rgb. Normally generated with Matrix.RGB(r, g, b)
Sets all matrix leds to off / back.
Object to create colored drops falling down from top row.
chanceChance in percent a row will or will not have drops.multipleChance to get more than one drop per time. (1 is minimum and [Matrix.size] is maximum)rgbColor object of type rgb. Normally generated with Matrix.RGB(r, g, b)
Call to update the drops. Each time the drops will fall down one row.
Call to draw the drops.
Object to create a colored rectangle.
nameThe name for the rectanglergbColor object of type rgb. Normally generated with Matrix.RGB(r, g, b)xx position if the rectangle top left corner (0 is at the left of the matrix)yy position of the rectangle top left corner (0 is at the top of the matrix)widthWidth of the rectangleheightHeight of the rectangle
Call to draw the rectangle.
Returns a rgb color object.
Matrix.RGB(255, 0, 0) is red. Matrix.RGB(0, 255, 0) is green. Matrix.RGB(0, 0, 255) is blue. Matrix.RGB(0, 0, 0) is black. Matrix.RGB(255, 255, 255) is white.
rThe red porpotion of the color. (0 is nothing, 255 is max)gThe green porpotion of the color. (0 is nothing, 255 is max)bThe blue porpotion of the color. (0 is nothing, 255 is max)
Converts a hsv color to a Matrix.RGB(r, g, b) color object.
hHue of the color. (0 is red, 120 is green, 240 is blue)sSaturation of the color in percentage. (0% = no, 100% = full)vValue / brightness of the color in percentage. (0% = no, 100% = full)
Returns a random integer.
minMinimum of the possible random range.maxMaximum of the possible random range.
Returns a random Matrix.RGB(r, g, b) color object.