1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

add extra gpoio support to neopixel node

This commit is contained in:
Dave Conway-Jones 2020-12-12 14:26:31 +00:00
parent c61e8b60b7
commit 8130f8c007
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
4 changed files with 17 additions and 4 deletions

View File

@ -47,6 +47,8 @@ MODE = sys.argv[3]
LED_BRIGHTNESS = min(255,int(max(0,float(sys.argv[4])) * 255 / 100))
if (sys.argv[5].lower() != "true"):
LED_GAMMA = range(256)
LED_CHANNEL = int(sys.argv[6])
LED_PIN = int(sys.argv[7])
def getRGBfromI(RGBint):
blue = RGBint & 255

View File

@ -1,8 +1,15 @@
<script type="text/x-red" data-template-name="rpi-neopixels">
<script type="text/html" data-template-name="rpi-neopixels">
<div class="form-row">
<label for="node-input-pixels"><i class="fa fa-sun-o"></i> LEDs</label>
<input type="text" id="node-input-pixels" placeholder="number" style="width:60px;"> in the string
<span style="margin-left:50px;">Pin Number </span>
<select id="node-input-gpio" style="width:50px; margin-left:5px;">
<option value="18">12</option>
<option value="12">32</option>
<option value="13">33</option>
<option value="19">35</option>
</select>
</div>
<div class="form-row">
<label for="node-input-mode"><i class="fa fa-cogs"></i> Mode</label>
@ -48,7 +55,7 @@
</div>
</script>
<script type="text/x-red" data-help-name="rpi-neopixels">
<script type="text/html" data-help-name="rpi-neopixels">
<p>Raspberry Pi node to drive a string of neopixel or ws2812 LEDs.</p>
<p>Defaults to a bar chart style mode using configured foreground and background colours.
It can also display a needle (single pixel) type gauge.</p>
@ -76,6 +83,7 @@
color:"#c6dbef",
defaults: {
name: { value:"" },
gpio: { value:18 },
pixels: { value:"", required:true, validate:RED.validators.number() },
bgnd: { value:"" },
fgnd: { value:"" },

View File

@ -40,6 +40,9 @@ module.exports = function(RED) {
this.rgb = n.rgb || "rgb";
this.gamma = n.gamma;
if (this.gamma === undefined) { this.gamma = true; }
this.gpio = n.gpio || 18;
this.channel = 0;
if (this.gpio == 13 || this.gpio == 19) { this.channel = 1; }
this.brightness = Number(n.brightness || 100);
this.wipe = Number(n.wipe || 40);
if (this.wipe < 0) { this.wipe = 0; }
@ -114,7 +117,7 @@ module.exports = function(RED) {
}
if (allOK === true) {
node.child = spawn(piCommand, [node.pixels, node.wipe, node.mode, node.brightness, node.gamma]);
node.child = spawn(piCommand, [node.pixels, node.wipe, node.mode, node.brightness, node.gamma, node.channel, node.gpio]);
node.status({fill:"green",shape:"dot",text:"ok"});
node.on("input", inputlistener);

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-pi-neopixel",
"version" : "0.0.25",
"version" : "0.1.0",
"description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.",
"dependencies" : {
},