From f4971aff69c944e6738603f5a51b0da8c15173ed Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 4 Mar 2016 20:13:03 +0000 Subject: [PATCH] Fix colour/color type and add set_letter for single char msg --- hardware/sensehat/README.md | 5 ++++- hardware/sensehat/package.json | 2 +- hardware/sensehat/sensehat.html | 4 +++- hardware/sensehat/sensehat.js | 2 +- hardware/sensehat/sensehat.py | 8 ++++++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hardware/sensehat/README.md b/hardware/sensehat/README.md index 8a5693ca..32460d83 100644 --- a/hardware/sensehat/README.md +++ b/hardware/sensehat/README.md @@ -110,8 +110,11 @@ Format: `R` If `msg.payload` is not recognised as any of the above commands, it is treated as a text message to be scrolled across the screen. +If the text is a single character, it will be displayed without scrolling. To +scroll a single character, append a blank space after it - `"A "`.

+ The following message properties can be used to customise the appearance: - - `msg.colour` - the colour of the text, default: `white` + - `msg.color` - the colour of the text, default: `white` - `msg.background` - the colour of the background, default: `off` - `msg.speed` - the scroll speed. A value in the range 1 (slower) to 5 (faster), default: `3` diff --git a/hardware/sensehat/package.json b/hardware/sensehat/package.json index a2971c48..fa39522f 100644 --- a/hardware/sensehat/package.json +++ b/hardware/sensehat/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-sense-hat", - "version" : "0.0.4", + "version" : "0.0.5", "description" : "A Node-RED node to interact with a Raspberry Pi Sense HAT", "repository" : { "type":"git", diff --git a/hardware/sensehat/sensehat.html b/hardware/sensehat/sensehat.html index 2370ea9b..90bd2b9d 100644 --- a/hardware/sensehat/sensehat.html +++ b/hardware/sensehat/sensehat.html @@ -122,9 +122,11 @@ the horizontal or vertical axis respectively.

Scroll a message

If msg.payload is not recognised as any of the above commands, it is treated as a text message to be scrolled across the screen.

+

If the text is a single character, it will be displayed without scrolling. +To scroll a single character, append a blank space after it - "A ".

The following message properties can be used to customise the appearance:

diff --git a/hardware/sensehat/sensehat.js b/hardware/sensehat/sensehat.js index 7ce45d35..76fb3800 100644 --- a/hardware/sensehat/sensehat.js +++ b/hardware/sensehat/sensehat.js @@ -232,7 +232,7 @@ module.exports = function(RED) { HAT.close(this,done); }); var handleTextMessage = function(line,msg) { - var textCol = colours.getRGB(msg.color); + var textCol = colours.getRGB(msg.color||msg.colour); var backCol = colours.getRGB(msg.background); var speed = null; if (!isNaN(msg.speed)) { diff --git a/hardware/sensehat/sensehat.py b/hardware/sensehat/sensehat.py index 24f807d8..f74c30b7 100644 --- a/hardware/sensehat/sensehat.py +++ b/hardware/sensehat/sensehat.py @@ -17,6 +17,7 @@ # R[rot] - rotate by rot (0,90,180,270) # P[x,y,R,G,B]+ - set individual pixel(s) to a colour # T[R,G,B[,R,G,B][,S]:]Message - scroll a message (nb: if message contains ':' it must be prefixed with ':') +# if message is a single char, uses show_letter instead # F[H|V] - flip horizontal|vertical # X[0|1] - high frequency reporting (accel/gyro/orientation/compass) off|on # Y[0|1] - low frequency reporting (temperature/humidity/pressure) off|on @@ -173,8 +174,11 @@ def process_command(data): tcol = (int(c[0]),int(c[1]),int(c[2])) bcol = (int(c[3]),int(c[4]),int(c[5])) speed = float(c[6]) - scroll = ScrollThread(tcol,bcol,speed,data); - scroll.start() + if len(data) > 1: + scroll = ScrollThread(tcol,bcol,speed,data); + scroll.start() + else: + SH.show_letter(data,text_colour=tcol,back_colour=bcol) elif data[0] == "F": if data[1] == "H": SH.flip_h()