mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
more node-red-nodes hardware section info updates
and update Pibrella to use latest nrgpio debounce thinking
This commit is contained in:
parent
c60d62f27b
commit
b0c8b1e83f
@ -39,8 +39,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="rpi-pibrella in">
|
<script type="text/x-red" data-help-name="rpi-pibrella in">
|
||||||
<p>Raspberry Pi Pibrella input node. Generates a <b>msg.payload</b> with either a 0 or 1 depending on the state of the input pin.</p>
|
<p>Raspberry Pi Pibrella input node. Generates a <code>msg.payload</code> with either a 0 or 1 depending on the state of the input pin.</p>
|
||||||
<p>The <b>msg.topic</b> is set to <i>pibrella/{the pin id}</i>, A, B, C, D or R</p>
|
<p>The <code>msg.topic</code> is set to <i>pibrella/{the pin id}</i>, A, B, C, D or R</p>
|
||||||
<p>Requires the RPi.GPIO python library version 0.5.8 (or better) in order to work.</p>
|
<p>Requires the RPi.GPIO python library version 0.5.8 (or better) in order to work.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -110,9 +110,10 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="rpi-pibrella out">
|
<script type="text/x-red" data-help-name="rpi-pibrella out">
|
||||||
<p>Raspberry Pi Pibrella output node. The Pibrella board must be fitted.</p>
|
<p>Raspberry Pi Pibrella output node. The Pibrella board must be fitted.</p>
|
||||||
<p>Will set the selected output high (on) or low (off) depending on the value passed in. Expects a <b>msg.payload</b> with either a 0 or 1 (or true or false).</p>
|
<p>Will set the selected output high (on) or low (off) depending on the value passed in. Expects a
|
||||||
|
<code>msg.payload</code> with either a 0 or 1 (or true or false).</p>
|
||||||
<p>In PWM mode you can dim the onboard LEDs - expects a number from 0 - 100 (%).</p>
|
<p>In PWM mode you can dim the onboard LEDs - expects a number from 0 - 100 (%).</p>
|
||||||
<p>The Buzzer takes a number in Hz (up to about 4000), or 0 for off, and 1 is a shortcut for 262.</div></p>
|
<p>The Buzzer takes a number in Hz (up to about 4000), or 0 for off, and 1 is a shortcut for a buzz at about 262Hz.</p>
|
||||||
<p>Requires the RPi.GPIO python library version 0.5.8 (or better) in order to work.</p>
|
<p>Requires the RPi.GPIO python library version 0.5.8 (or better) in order to work.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ module.exports = function(RED) {
|
|||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
var gpioCommand = __dirname+'/nrgpio.py';
|
var gpioCommand = __dirname+'/nrgpio';
|
||||||
|
|
||||||
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
|
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
|
||||||
//util.log("Info : Ignoring Raspberry Pibrella specific node.");
|
//util.log("Info : Ignoring Raspberry Pibrella specific node.");
|
||||||
@ -90,7 +90,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node.pin !== undefined) {
|
if (node.pin !== undefined) {
|
||||||
node.child = spawn(gpioCommand, ["in",node.pin]);
|
node.child = spawn(gpioCommand, ["in",node.pin,"down",35]);
|
||||||
node.running = true;
|
node.running = true;
|
||||||
node.status({fill:"green",shape:"dot",text:"OK"});
|
node.status({fill:"green",shape:"dot",text:"OK"});
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Copyright 2014 IBM Corp.
|
# Copyright 2014 IBM Corp.
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# Copyright 2014 IBM Corp.
|
# Copyright 2014,2016 IBM Corp.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@ -15,15 +15,19 @@
|
|||||||
|
|
||||||
# Import library functions we need
|
# Import library functions we need
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
bounce = 20 # bounce time in mS to apply
|
bounce = 25;
|
||||||
|
|
||||||
if sys.version_info >= (3,0):
|
if sys.version_info >= (3,0):
|
||||||
print("Sorry - currently only configured to work with python 2.x")
|
print("Sorry - currently only configured to work with python 2.x")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 2:
|
||||||
cmd = sys.argv[1].lower()
|
cmd = sys.argv[1].lower()
|
||||||
pin = int(sys.argv[2])
|
pin = int(sys.argv[2])
|
||||||
GPIO.setmode(GPIO.BOARD)
|
GPIO.setmode(GPIO.BOARD)
|
||||||
@ -92,18 +96,18 @@ if len(sys.argv) > 1:
|
|||||||
|
|
||||||
elif cmd == "in":
|
elif cmd == "in":
|
||||||
#print "Initialised pin "+str(pin)+" to IN"
|
#print "Initialised pin "+str(pin)+" to IN"
|
||||||
|
bounce = int(sys.argv[4])
|
||||||
def handle_callback(chan):
|
def handle_callback(chan):
|
||||||
|
sleep(bounce/1000)
|
||||||
print GPIO.input(chan)
|
print GPIO.input(chan)
|
||||||
|
|
||||||
if len(sys.argv) == 4:
|
|
||||||
if sys.argv[3].lower() == "up":
|
if sys.argv[3].lower() == "up":
|
||||||
GPIO.setup(pin,GPIO.IN,GPIO.PUD_UP)
|
GPIO.setup(pin,GPIO.IN,GPIO.PUD_UP)
|
||||||
elif sys.argv[3].lower() == "down":
|
elif sys.argv[3].lower() == "down":
|
||||||
GPIO.setup(pin,GPIO.IN,GPIO.PUD_DOWN)
|
GPIO.setup(pin,GPIO.IN,GPIO.PUD_DOWN)
|
||||||
else:
|
else:
|
||||||
GPIO.setup(pin,GPIO.IN)
|
GPIO.setup(pin,GPIO.IN)
|
||||||
else:
|
|
||||||
GPIO.setup(pin,GPIO.IN)
|
|
||||||
print GPIO.input(pin)
|
print GPIO.input(pin)
|
||||||
GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=bounce)
|
GPIO.add_event_detect(pin, GPIO.BOTH, callback=handle_callback, bouncetime=bounce)
|
||||||
|
|
||||||
@ -166,12 +170,6 @@ if len(sys.argv) > 1:
|
|||||||
except:
|
except:
|
||||||
data = 0
|
data = 0
|
||||||
|
|
||||||
elif cmd == "rev":
|
|
||||||
print GPIO.RPI_REVISION
|
|
||||||
|
|
||||||
elif cmd == "ver":
|
|
||||||
print GPIO.VERSION
|
|
||||||
|
|
||||||
elif cmd == "mouse": # catch mice button events
|
elif cmd == "mouse": # catch mice button events
|
||||||
file = open( "/dev/input/mice", "rb" )
|
file = open( "/dev/input/mice", "rb" )
|
||||||
oldbutt = 0
|
oldbutt = 0
|
||||||
@ -193,5 +191,40 @@ if len(sys.argv) > 1:
|
|||||||
file.close()
|
file.close()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
elif cmd == "kbd": # catch keyboard button events
|
||||||
|
try:
|
||||||
|
while not os.path.isdir("/dev/input/by-path"):
|
||||||
|
time.sleep(10)
|
||||||
|
infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip()
|
||||||
|
infile_path = "/dev/input/by-path/" + infile
|
||||||
|
EVENT_SIZE = struct.calcsize('llHHI')
|
||||||
|
file = open(infile_path, "rb")
|
||||||
|
event = file.read(EVENT_SIZE)
|
||||||
|
while event:
|
||||||
|
(tv_sec, tv_usec, type, code, value) = struct.unpack('llHHI', event)
|
||||||
|
#if type != 0 or code != 0 or value != 0:
|
||||||
|
if type == 1:
|
||||||
|
# type,code,value
|
||||||
|
print("%u,%u" % (code, value))
|
||||||
|
event = file.read(EVENT_SIZE)
|
||||||
|
print "0,0"
|
||||||
|
file.close()
|
||||||
|
sys.exit(0)
|
||||||
|
except:
|
||||||
|
file.close()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
elif len(sys.argv) > 1:
|
||||||
|
cmd = sys.argv[1].lower()
|
||||||
|
if cmd == "rev":
|
||||||
|
print GPIO.RPI_REVISION
|
||||||
|
elif cmd == "ver":
|
||||||
|
print GPIO.VERSION
|
||||||
|
elif cmd == "info":
|
||||||
|
print GPIO.RPI_INFO
|
||||||
else:
|
else:
|
||||||
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|ver pin {value|up|down}"
|
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}"
|
||||||
|
print " only ver (gpio version) and info (board information) accept no pin parameter."
|
||||||
|
|
||||||
|
else:
|
||||||
|
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|kbd|ver|info {pin} {value|up|down}"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-pibrella",
|
"name" : "node-red-node-pibrella",
|
||||||
"version" : "0.0.9",
|
"version" : "0.0.10",
|
||||||
"description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board",
|
"description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="blink1">
|
<script type="text/x-red" data-help-name="blink1">
|
||||||
<p>ThingM Blink1 output node.</p>
|
<p>ThingM Blink1 output node.</p>
|
||||||
<p>Expects a <b>msg.payload</b> with either a three part csv string of
|
<p>Expects a <code>msg.payload</code> with either a three part csv string of
|
||||||
<i>r,g,b</i> or a hex colour <i>#rrggbb</i></p>
|
<i>r,g,b</i> or a hex colour <i>#rrggbb</i></p>
|
||||||
<p>You can also use the <a href="http://www.cheerlights.com/control-cheerlights" target="_new">@cheerlights</a>
|
<p>You can also use the <a href="http://www.cheerlights.com/control-cheerlights" target="_new">@cheerlights</a>
|
||||||
colour names - red, green, blue, cyan, magenta, yellow, orange, pink,
|
colour names - red, green, blue, cyan, magenta, yellow, orange, pink,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-blink1",
|
"name" : "node-red-node-blink1",
|
||||||
"version" : "0.0.12",
|
"version" : "0.0.13",
|
||||||
"description" : "A Node-RED node to control a Thingm Blink(1)",
|
"description" : "A Node-RED node to control a Thingm Blink(1)",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"node-blink1" : "0.2.3"
|
"node-blink1" : "0.2.3"
|
||||||
|
@ -57,16 +57,16 @@
|
|||||||
<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>
|
||||||
<p>It can accept a number in <b>msg.payload</b> that can be either the
|
<p>It can accept a number in <code>msg.payload</code> that can be either the
|
||||||
number of pixels, or a percentage of the total length.</p>
|
number of pixels, or a percentage of the total length.</p>
|
||||||
<p>If you want to change the foregound colour, you can send a CSV of <i>html colour,length</i>.</p>
|
<p>If you want to change the foregound colour, you can send a CSV of <i>html colour,length</i>.</p>
|
||||||
<p>To set the background just send an <i>html colour</i> name.
|
<p>To set the background just send an <i>html colour</i> name.
|
||||||
<a href="http://html-color-codes.info/color-names/" target="_top">Here
|
<a href="http://html-color-codes.info/color-names/" target="_top">Here
|
||||||
is a list</a> of html colour names.<p>
|
is a list</a> of html colour names.<p>
|
||||||
<p>You can also select shift modes where a single colour pixel is added to either the start or the end of the strip.</p>
|
<p>You can also select shift modes where a single colour pixel is added to either the start or the end of the strip.</p>
|
||||||
<p>The <i>nth</i> pixel is set by <b>msg.payload</b> with a CSV string <i>n,r,g,b</i>
|
<p>The <i>nth</i> pixel is set by <code>msg.payload</code> with a CSV string <i>n,r,g,b</i>
|
||||||
<!-- <p>The whole strip is set by <b>msg.payload</b> with a CSV string <i>r,g,b</i> -->
|
<!-- <p>The whole strip is set by <code>msg.payload</code> with a CSV string <i>r,g,b</i> -->
|
||||||
<p>A range of pixels from <i>x</i> to <i>y</i> can be set by <b>msg.payload</b>
|
<p>A range of pixels from <i>x</i> to <i>y</i> can be set by <code>msg.payload</code>
|
||||||
with a CSV string <i>x,y,r,g,b</i>
|
with a CSV string <i>x,y,r,g,b</i>
|
||||||
<p>The pixels data line should be connected to Pi physical pin 12 - GPIO 18. <i>Note:</i>
|
<p>The pixels data line should be connected to Pi physical pin 12 - GPIO 18. <i>Note:</i>
|
||||||
this may conflict with audio playback.</p>
|
this may conflict with audio playback.</p>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-pi-neopixel",
|
"name" : "node-red-node-pi-neopixel",
|
||||||
"version" : "0.0.7",
|
"version" : "0.0.8",
|
||||||
"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