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

Update LEDborg - to match Pi node colours and update python

This commit is contained in:
Dave Conway-Jones 2015-11-16 23:12:35 +00:00
parent b6bbcbd52f
commit ddacd61ab0
4 changed files with 23 additions and 24 deletions

View File

@ -26,15 +26,15 @@
<p>PiBorg LedBorg LED output node. Expects a <b>msg.payload</b> with a three digit rgb triple, from <b>000</b> to <b>222</b>.</p> <p>PiBorg LedBorg LED output node. Expects a <b>msg.payload</b> with a three digit rgb triple, from <b>000</b> to <b>222</b>.</p>
<p>See <i><a href="http://www.piborg.com/ledborg/install" target="_new">the PiBorg site</a></i> for more information.</p> <p>See <i><a href="http://www.piborg.com/ledborg/install" target="_new">the PiBorg site</a></i> for more information.</p>
<p>You can also use a <b>msg.payload</b> in the standard hex format "#rrggbb".</p> <p>You can also use a <b>msg.payload</b> in the standard hex format "#rrggbb".</p>
<p>You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yellow, orange, pink, purple, <p>You can also use the @cheerlight colour names - red, amber, green, blue,
white, warmwhite, black</p> cyan, magenta, yellow, orange, pink, purple, white, warmwhite, black</p>
<p>You may also supply a comma seperated rrr,ggg,bbb where the value can be between 0 and 255.</p> <p>You may also supply a comma separated rrr,ggg,bbb where each value can be between 0 and 255.</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('ledborg',{ RED.nodes.registerType('ledborg',{
category: 'Raspberry Pi', category: 'Raspberry Pi',
color:"GoldenRod", color:"#c6dbef",
defaults: { defaults: {
name: {value:""} name: {value:""}
}, },

View File

@ -1,3 +1,4 @@
#!/bin/bash
# #
# Copyright 2014 IBM Corp. # Copyright 2014 IBM Corp.
# #

View File

@ -19,6 +19,10 @@ import sys
bounce = 20 # bounce time in mS to apply bounce = 20 # bounce time in mS to apply
if sys.version_info >= (3,0):
print("Sorry - currently only configured to work with python 2.x")
sys.exit(1)
if len(sys.argv) > 1: if len(sys.argv) > 1:
cmd = sys.argv[1].lower() cmd = sys.argv[1].lower()
pin = int(sys.argv[2]) pin = int(sys.argv[2])
@ -34,11 +38,10 @@ if len(sys.argv) > 1:
while True: while True:
try: try:
data = raw_input() data = raw_input()
if data == "close": if 'close' in data:
GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
p.ChangeDutyCycle(float(data)) p.ChangeDutyCycle(float(data))
except EOFError: # hopefully always caused by us sigint'ing the program except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
GPIO.cleanup(pin) GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
except Exception as ex: except Exception as ex:
@ -53,15 +56,14 @@ if len(sys.argv) > 1:
while True: while True:
try: try:
data = raw_input() data = raw_input()
if data == "close": if 'close' in data:
GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
elif float(data) == 0: elif float(data) == 0:
p.stop() p.stop()
else: else:
p.start(50) p.start(50)
p.ChangeFrequency(float(data)) p.ChangeFrequency(float(data))
except EOFError: # hopefully always caused by us sigint'ing the program except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
GPIO.cleanup(pin) GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
except Exception as ex: except Exception as ex:
@ -76,11 +78,10 @@ if len(sys.argv) > 1:
while True: while True:
try: try:
data = raw_input() data = raw_input()
if data == "close": if 'close' in data:
GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
data = int(data) data = int(data)
except EOFError: # hopefully always caused by us sigint'ing the program except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
GPIO.cleanup(pin) GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
except: except:
@ -109,10 +110,9 @@ if len(sys.argv) > 1:
while True: while True:
try: try:
data = raw_input() data = raw_input()
if data == "close": if 'close' in data:
GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
except EOFError: # hopefully always caused by us sigint'ing the program except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
GPIO.cleanup(pin) GPIO.cleanup(pin)
sys.exit(0) sys.exit(0)
@ -124,11 +124,10 @@ if len(sys.argv) > 1:
while True: while True:
try: try:
data = raw_input() data = raw_input()
if data == "close": if 'close' in data:
GPIO.cleanup()
sys.exit(0) sys.exit(0)
data = int(data) data = int(data)
except EOFError: # hopefully always caused by us sigint'ing the program except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
GPIO.cleanup() GPIO.cleanup()
sys.exit(0) sys.exit(0)
except: except:
@ -155,14 +154,13 @@ if len(sys.argv) > 1:
while True: while True:
try: try:
data = raw_input() data = raw_input()
if data == "close": if 'close' in data:
GPIO.cleanup()
sys.exit(0) sys.exit(0)
c = data.split(",") c = data.split(",")
r.ChangeDutyCycle(float(c[0])) r.ChangeDutyCycle(float(c[0]))
g.ChangeDutyCycle(float(c[1])) g.ChangeDutyCycle(float(c[1]))
b.ChangeDutyCycle(float(c[2])) b.ChangeDutyCycle(float(c[2]))
except EOFError: # hopefully always caused by us sigint'ing the program except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program
GPIO.cleanup() GPIO.cleanup()
sys.exit(0) sys.exit(0)
except: except:
@ -196,4 +194,4 @@ if len(sys.argv) > 1:
sys.exit(0) sys.exit(0)
else: else:
print "Bad parameters - {in|out|pwm} {pin} {value|up|down}" print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|ver pin {value|up|down}"

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-ledborg", "name" : "node-red-node-ledborg",
"version" : "0.0.7", "version" : "0.0.9",
"description" : "A Node-RED node to control a PiBorg LedBorg board for a Raspberry Pi.", "description" : "A Node-RED node to control a PiBorg LedBorg board for a Raspberry Pi.",
"dependencies" : { "dependencies" : {
}, },