Skip to content

Commit

Permalink
add extra gpoio support to neopixel node
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Conway-Jones committed Dec 12, 2020
1 parent c61e8b6 commit 8130f8c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions hardware/neopixel/neopix.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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
Expand Down
12 changes: 10 additions & 2 deletions hardware/neopixel/neopixel.html
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -76,6 +83,7 @@
color:"#c6dbef",
defaults: {
name: { value:"" },
gpio: { value:18 },
pixels: { value:"", required:true, validate:RED.validators.number() },
bgnd: { value:"" },
fgnd: { value:"" },
Expand Down
5 changes: 4 additions & 1 deletion hardware/neopixel/neopixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hardware/neopixel/package.json
Original file line number Diff line number Diff line change
@@ -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" : {
},
Expand Down

0 comments on commit 8130f8c

Please sign in to comment.