Finally got everything to work in the emulator.
Code: Select all
from sense_hat import SenseHat
sense = SenseHat()
while True:
orientation = sense.get_orientation()
pitch = orientation['pitch']
roll = orientation['roll']
yaw = orientation['yaw']
for event in sense.stick.get_events():
# Check if the joystick was pressed
if event.action == "pressed":
# Check which direction
if event.direction == "up":
sense.show_message("%.2f " % yaw, scroll_speed=0.10, text_colour=[0, 255, 0])
if event.direction == "down":
sense.show_message("%.2f " % pitch, scroll_speed=0.10, text_colour=[0, 255, 0])
if event.direction == "left":
sense.show_message("%.2f " % roll, scroll_speed=0.10, text_colour=[0, 255, 0])
if event.direction == "right":
sense.show_message("%.2f " % roll, scroll_speed=0.10, text_colour=[0, 255, 0])
if event.direction == "middle":
sense.show_message("%.2f " % pitch, scroll_speed=0.10, text_colour=[0, 255, 0])
Now i just need to get it on the pi to see if it will work there.