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:
parent
c61e8b60b7
commit
8130f8c007
@ -47,6 +47,8 @@ MODE = sys.argv[3]
|
|||||||
LED_BRIGHTNESS = min(255,int(max(0,float(sys.argv[4])) * 255 / 100))
|
LED_BRIGHTNESS = min(255,int(max(0,float(sys.argv[4])) * 255 / 100))
|
||||||
if (sys.argv[5].lower() != "true"):
|
if (sys.argv[5].lower() != "true"):
|
||||||
LED_GAMMA = range(256)
|
LED_GAMMA = range(256)
|
||||||
|
LED_CHANNEL = int(sys.argv[6])
|
||||||
|
LED_PIN = int(sys.argv[7])
|
||||||
|
|
||||||
def getRGBfromI(RGBint):
|
def getRGBfromI(RGBint):
|
||||||
blue = RGBint & 255
|
blue = RGBint & 255
|
||||||
|
@ -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">
|
<div class="form-row">
|
||||||
<label for="node-input-pixels"><i class="fa fa-sun-o"></i> LEDs</label>
|
<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
|
<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>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-mode"><i class="fa fa-cogs"></i> Mode</label>
|
<label for="node-input-mode"><i class="fa fa-cogs"></i> Mode</label>
|
||||||
@ -48,7 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</script>
|
</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>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.
|
<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>
|
It can also display a needle (single pixel) type gauge.</p>
|
||||||
@ -76,6 +83,7 @@
|
|||||||
color:"#c6dbef",
|
color:"#c6dbef",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value:"" },
|
name: { value:"" },
|
||||||
|
gpio: { value:18 },
|
||||||
pixels: { value:"", required:true, validate:RED.validators.number() },
|
pixels: { value:"", required:true, validate:RED.validators.number() },
|
||||||
bgnd: { value:"" },
|
bgnd: { value:"" },
|
||||||
fgnd: { value:"" },
|
fgnd: { value:"" },
|
||||||
|
@ -40,6 +40,9 @@ module.exports = function(RED) {
|
|||||||
this.rgb = n.rgb || "rgb";
|
this.rgb = n.rgb || "rgb";
|
||||||
this.gamma = n.gamma;
|
this.gamma = n.gamma;
|
||||||
if (this.gamma === undefined) { this.gamma = true; }
|
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.brightness = Number(n.brightness || 100);
|
||||||
this.wipe = Number(n.wipe || 40);
|
this.wipe = Number(n.wipe || 40);
|
||||||
if (this.wipe < 0) { this.wipe = 0; }
|
if (this.wipe < 0) { this.wipe = 0; }
|
||||||
@ -114,7 +117,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allOK === true) {
|
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.status({fill:"green",shape:"dot",text:"ok"});
|
||||||
|
|
||||||
node.on("input", inputlistener);
|
node.on("input", inputlistener);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-pi-neopixel",
|
"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.",
|
"description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user