Fatespinner
Posts: 4
Joined: Sun Dec 16, 2018 1:42 am

Sense Hat Resources

Sun Dec 16, 2018 1:51 am

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.
Last edited by Fatespinner on Sun Dec 30, 2018 3:29 pm, edited 1 time in total.

User avatar
neilgl
Posts: 349
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Sense Had Resources

Sun Dec 16, 2018 7:26 pm


Fatespinner
Posts: 4
Joined: Sun Dec 16, 2018 1:42 am

Re: Sense Had Resources

Sun Dec 16, 2018 9:26 pm

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

User avatar
bensimmo
Posts: 3579
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Sense Had Resources

Mon Dec 17, 2018 8:17 am

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?

Fatespinner
Posts: 4
Joined: Sun Dec 16, 2018 1:42 am

Re: Sense Had Resources

Wed Dec 19, 2018 2:51 am

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.

Fatespinner
Posts: 4
Joined: Sun Dec 16, 2018 1:42 am

Re: Sense Had Resources

Sat Dec 29, 2018 8:06 pm

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.

alphanumeric
Posts: 1548
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Sense Hat Resources

Wed Jan 16, 2019 2:16 pm

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?

User avatar
bensimmo
Posts: 3579
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Sense Hat Resources

Wed Jan 16, 2019 4:26 pm

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)

Return to “Astro Pi”