Page 1 of 1

Sense Hat Resources

Posted: Sun Dec 16, 2018 1:51 am
by Fatespinner
So I have a Sense hate I'm looking to get heading pith and roll info and have it scroll across the screen. I want to do it based off the joy stick move. up heading, left and right roll, and down pitch ( or something like that)

I can do each thing on it's own but i can't tie them together. wondering if someone can point me in the right direction for some resources to help me.

Re: Sense Had Resources

Posted: Sun Dec 16, 2018 7:26 pm
by neilgl

Re: Sense Had Resources

Posted: Sun Dec 16, 2018 9:26 pm
by Fatespinner
I have, i've gotten the stats to display on the computer interface, i'm struggling to figure out how to bind that command to the joystick button

Re: Sense Had Resources

Posted: Mon Dec 17, 2018 8:17 am
by bensimmo
The joystick documents
https://pythonhosted.org/sense-hat/api/#joystick

Strart up the SenseHAT emulator.
In the examples you will have the menu selection.
Then try and figure out how they are doing it.
They can also be found
https://github.com/RPi-Distro/python-se ... u/examples


Also more examples
https://github.com/RPi-Distro/python-se ... r/examples


Buy this part of the getting started shows you joystick selection.
https://projects.raspberrypi.org/en/pro ... nse-hat/10 did you get that far?

Re: Sense Had Resources

Posted: Wed Dec 19, 2018 2:51 am
by Fatespinner
So I'm going to start over, i actually ordered a new pi for this and i'm going to take it one step at a time following those links. The python script would show me the info but i couldn't get it to display on the screen or bind it to the button. going to start over and i'll keep you posted.

Re: Sense Had Resources

Posted: Sat Dec 29, 2018 8:06 pm
by Fatespinner
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.

Re: Sense Hat Resources

Posted: Wed Jan 16, 2019 2:16 pm
by alphanumeric
I'm struggling a bit to understand what your doing and why your doing it? Curiosity killed the cat, lol.
Anyway doesn't

Code: Select all

sense.get_orientation() 
get the orientation from the IMU?

But then your doing something with the joystick? Displaying the different values depending on which way you move the joystick?

Re: Sense Hat Resources

Posted: Wed Jan 16, 2019 4:26 pm
by bensimmo
alphanumeric, run the program above on your Pi in IDLE3 or Thonny and you'll find out.*

The idea is to select which measurement to display, the pitch, the roll or the orientation. yes all from that sense.get_orientation(), it return a list of all three measurements.



or even Trinket
https://trinket.io/python/b7278e7b57

on trinket use the keyboard arrow keys as the joystick (which are what the joystick on the sensehat actually emulates iirc)