Pixelblaze Advanced Features. 

 
 

Connecting a Button

Pixelblaze supports a button on pin 0. This pin has a pull-up resistor, and when shorted to ground momentarily will change the pattern. If pressed for more than 3.5 seconds, it will put Pixelblaze into WiFi setup mode. 

To wire a button, connect the top pin and the bottom pin to the button. 

Websocket API

Pixelblaze is controlled by a websocket connection on port 81. JSON and binary frames are sent to control and edit the patterns.

Getting and Setting Variables

Pattern variables can be controlled over the network using websockets. 

Version 1: If your expression uses but does not initialize some variables, you can set these. They default to 0 if otherwise uninitialized. If you do set them to a value in the pattern, they are overwritten each time and setVars won't take effect.

Version 2: You can export top-level variables to make them public and initialize them to default values. e.g.


export var myVar = 2
export var var2 = 0

 

To set variables, send a JSON text frame like this:


{
	"setVars": {
		"myVar": 3.14159,
		"var2": 42
	}
}

To get variables, send a frame like this:


{
	"getVars": true
}

And you'll get a response with all variables. Note that this will only show variable state AFTER the last pixel has been rendered. 


{
	vars: {
		"myVar": 3.14159, 
		"var2": 42,
		...
	}
}

Listing Patterns (V1 only)


{
	"listPrograms": true
}

The pattern list returned contains the name and id, along with some other fields about storage space in memory.


{
	"programList": [
		{
			"name": "my pattern",
			"id": "x1234567890",
			"sourceSize": 123,
			"globalSourceSize": 123,
			"compiledSize": 134,
			"imgSize": 5123
		}, ...
	]
}

Changing The Active Pattern

With a pattern ID handy, you can activate any previously stored pattern. This change is saved and will persist if the device restarts. 


{
	"activeProgramId": "x1234567890"
}