Have a look here,
https://pythonhosted.org/sense-hat/api/#joystick
I use it on mine to do things. here is some of my code. I have my sense hat rotated 180 degrees, its essentially upside down. Can't help you with the node red stuff though.
Code: Select all
import os
import time, datetime
from sense_hat import SenseHat, ACTION_PRESSED, ACTION_HELD, ACTION_RELEASED
sense = SenseHat()
sense.set_rotation(180)
sense.set_imu_config(False, False, False)
sense.low_light = True
s=(0.065) # scroll speed
w=(0) # color all white toggle
x=(2) #shutdown variable
# is really stick down
def pushed_up(event):
if event.action == ACTION_PRESSED:
sense.low_light = True
# is really stick up
def pushed_down(event):
if event.action == ACTION_PRESSED:
sense.low_light = False
#is really stick right
def pushed_left(event):
global w
if event.action == ACTION_PRESSED:
w = (255)
# is really stick left
def pushed_right(event):
global w
if event.action == ACTION_PRESSED:
w = (0)
def pushed_middle(event):
global x
if event.action == ACTION_PRESSED:
x = 0
sense.stick.direction_up = pushed_up
sense.stick.direction_down = pushed_down
sense.stick.direction_left = pushed_left
sense.stick.direction_right = pushed_right
sense.stick.direction_middle = pushed_middle
while True: