diff --git a/hardware/unicorn/README.md b/hardware/unicorn/README.md index cdc287e2..cc75f665 100644 --- a/hardware/unicorn/README.md +++ b/hardware/unicorn/README.md @@ -29,13 +29,12 @@ png image, or by specifying a single colour using an r,g,b triple. The brightness can also be set in the configuration. Defaults to 20% so as not to blind you. -A pixel is set by `msg.payload` with a CSV string `x,y,r,g,b` , where x and y -are 0 to 7, and r, g and b are 0 - 255. -If `x` or `y` are set to `*` then the complete row or column can be set. -Setting both `x` and `y` to `*` fills the background. -Multiple pixels can be specified at once by using `x1,y1,r1,g1,b1,x2,y2,r2,g2,b2,...` etc +A pixel is set by a `payload` containing a CSV string `x,y,r,g,b` . +`x` and `y` can be a single pixel `0` to `7`, a range of pixels, eg `2-5`, or +`*` to indicate the whole line. Multiple pixels strings can also be sent as +`x1,y1,r1,g1,b1,x2,y2,r2,g2,b2,...` . -The background can also be set to a colour by setting `msg.payload` to an r,g,b triple. +The background can also be set to a colour by setting `msg.payload` to an `r,g,b` triple. Any msg with a `msg.topic` identifies a 'sprite', which can then be moved independently of the background. A 'sprite' can be a single pixel, or a group of pixels. @@ -46,6 +45,6 @@ Setting `msg.payload` to `DEL` delete any sprites - leaving the background. Setting `msg.payload` to `CLS` will clear the display to off and delete any sprites. -The overall brightness may be set by setting `msg.payload` to `brightness,nn`, where `nn` is 0 to 100. +The overall brightness may be set by setting `msg.payload` to `brightness,nn`, where `nn` is `0 to 100`. -The rotation may be set by setting `msg.payload` to 'rotate,rr', where 'rr' is 0, 90, 180 or 270. +The rotation may be set by setting `msg.payload` to `rotate,rr`, where `rr` is `0`, `90`, `180` or `270`. diff --git a/hardware/unicorn/examples/Basic.json b/hardware/unicorn/examples/Basic.json new file mode 100644 index 00000000..a29d1488 --- /dev/null +++ b/hardware/unicorn/examples/Basic.json @@ -0,0 +1 @@ +[{"id":"651b51cb.9ae4b","type":"rpi-unicorn","z":"40b203f2.bf4dfc","name":"","png":"0,0,0","bright":"20","x":670,"y":120,"wires":[]},{"id":"738418f2.8c7be8","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":80,"wires":[["f4b1a57c.0b4e58"]]},{"id":"f4b1a57c.0b4e58","type":"function","z":"40b203f2.bf4dfc","name":"Random pixel","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\",\"+rnd(8)+\",\"+rnd(256)+\",\"+rnd(256)+\",\"+rnd(256);\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":80,"wires":[["651b51cb.9ae4b"]]},{"id":"521bcb52.cdacd4","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":240,"wires":[["339d717e.b7dcbe"]]},{"id":"1ead517.f6ea2af","type":"function","z":"40b203f2.bf4dfc","name":"Random block","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\"-\"+rnd(8)+\",\"+rnd(8)+\"-\"+rnd(8)+\",\"+rnd(256)+\",\"+rnd(256)+\",\"+rnd(256);\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":280,"wires":[["651b51cb.9ae4b"]]},{"id":"3b0f093.055fdf6","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":280,"wires":[["1ead517.f6ea2af"]]},{"id":"78fb1275.1edcfc","type":"function","z":"40b203f2.bf4dfc","name":"Random partial horzontal line","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\"-\"+rnd(8)+\",\"+rnd(8)+\",\"+rnd(256)+\",\"+rnd(256)+\",\"+rnd(256);\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":200,"wires":[["651b51cb.9ae4b"]]},{"id":"39a26a50.73f696","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":200,"wires":[["78fb1275.1edcfc"]]},{"id":"a64899c7.7a26a8","type":"comment","z":"40b203f2.bf4dfc","name":"Unicorn Examples","info":"Simple exmplaes of drawing random colour pixels\n, full lines, partial lines and rectangles.\n\nAnd two simple \"sprites\", named by their `msg.topic` \nproperty that can move independantly of the background.","x":160,"y":40,"wires":[]},{"id":"300f653.741879a","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":160,"wires":[["d8af4e17.7d6fb"]]},{"id":"6f424fd0.170e4","type":"function","z":"40b203f2.bf4dfc","name":"Random horizontal line","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = \"*,\"+rnd(8)+\",\"+rnd(256)+\",\"+rnd(256)+\",\"+rnd(256);\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":120,"wires":[["651b51cb.9ae4b"]]},{"id":"63f3f789.31d5b8","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":120,"wires":[["6f424fd0.170e4"]]},{"id":"d8af4e17.7d6fb","type":"function","z":"40b203f2.bf4dfc","name":"Random vertical line","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\",*,\"+rnd(256)+\",\"+rnd(256)+\",\"+rnd(256);\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":160,"wires":[["651b51cb.9ae4b"]]},{"id":"339d717e.b7dcbe","type":"function","z":"40b203f2.bf4dfc","name":"Random partial vertical line","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\",\"+rnd(8)+\"-\"+rnd(8)+\",\"+rnd(256)+\",\"+rnd(256)+\",\"+rnd(256);\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":240,"wires":[["651b51cb.9ae4b"]]},{"id":"70b1ae04.a9fc8","type":"inject","z":"40b203f2.bf4dfc","name":"Clear screen","topic":"","payload":"CLS","payloadType":"str","repeat":"","crontab":"","once":false,"x":390,"y":40,"wires":[["651b51cb.9ae4b"]]},{"id":"85a534a6.be6a18","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":340,"wires":[["19299a90.447b95"]]},{"id":"19299a90.447b95","type":"function","z":"40b203f2.bf4dfc","name":"Random red sprite","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\",\"+rnd(8)+\",255,0,0\";\nmsg.topic = \"s1\"; // give the sprite a name\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":340,"wires":[["651b51cb.9ae4b"]]},{"id":"6936a42e.a0abfc","type":"inject","z":"40b203f2.bf4dfc","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":130,"y":380,"wires":[["9478822a.49e9d"]]},{"id":"9478822a.49e9d","type":"function","z":"40b203f2.bf4dfc","name":"Random blue sprite","func":"\nfunction rnd(r) {\n return parseInt(Math.random()*r);\n}\n\nmsg.payload = rnd(8)+\",\"+rnd(8)+\",0,0,255\";\nmsg.topic = \"s2\"; // give the sprite a name (different from the red one)\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":380,"wires":[["651b51cb.9ae4b"]]}] diff --git a/hardware/unicorn/package.json b/hardware/unicorn/package.json index 4f07a4bc..2451fc8e 100644 --- a/hardware/unicorn/package.json +++ b/hardware/unicorn/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-unicorn-hat", - "version" : "0.0.7", + "version" : "0.0.8", "description" : "A Node-RED node to output to a Raspberry Pi Unicorn HAT from Pimorini.", "dependencies" : { "pngjs": "2.2.*" diff --git a/hardware/unicorn/unicorn.html b/hardware/unicorn/unicorn.html index 54dd3ddb..bbdde34d 100644 --- a/hardware/unicorn/unicorn.html +++ b/hardware/unicorn/unicorn.html @@ -33,18 +33,18 @@