blogmywiki
Posts: 5
Joined: Tue May 15, 2012 7:25 am
Location: SE London
Contact: Website

Sense HAT joystick problem

Fri Apr 21, 2017 11:51 am

Hi there - I have an odd and quite specific problem with the joystick which I can't find covered elsewhere.

I have a newly-updated PIXEL Raspbian install and the SenseHAT (version 1.0) display works perfectly with Python code on a Raspberry Pi 2 (Model B v1). The joystick works perfectly with Pygame examples such as the one here: https://www.raspberrypi.org/learning/as ... oystick.md

However, I would like to use the joystick in a headless application so I have installed evdev and am trying to use the example listed on the cheatsheet at https://www.raspberrypi.org/learning/as ... tsheet.pdf

I can't get it to work. It prints UP / DOWN / LEFT / RIGHT / ENTER when I press those keys on the _keyboard_ but not on the SenseHAT joystick. The SenseHAT joystick DOES however move the cursor up/down/left/right in the console window, so it is doing something. I have triple-checked the code for typos and am reasonably confident I have typed it correctly.

Any ideas?! Grateful for any help.

PS I have now tried the evdev example here: https://github.com/RPi-Distro/python-sense-hat/issues/9
and it works! - so I am even more confused... is there a typo in the cheatsheet? I copied and pasted and put all the spaces and indents back carefully. Is the cheatsheet example not compatible with my setup?

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

Re: Sense HAT joystick problem

Sun Apr 23, 2017 8:02 pm

There is now python support for the joystick built into the latest Raspbian Jessie. It's what I'm using. evdev caused weird things to happen for me when I pressed certain keys on my keyboard when my python file was running.
https://pythonhosted.org/sense-hat/api/#joystick

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

Re: Sense HAT joystick problem

Sun Apr 23, 2017 8:06 pm

It's been a while since I used evdev, but I seem to remember things not working as intended if you launch your python file from idle. Auto run it in the background though and I think it works? Memory is not what it used to be though. ;)

blogmywiki
Posts: 5
Joined: Tue May 15, 2012 7:25 am
Location: SE London
Contact: Website

Re: Sense HAT joystick problem

Mon Apr 24, 2017 7:26 pm

alphanumeric wrote:There is now python support for the joystick built into the latest Raspbian Jessie. It's what I'm using. evdev caused weird things to happen for me when I pressed certain keys on my keyboard when my python file was running.
https://pythonhosted.org/sense-hat/api/#joystick
Most grateful, I wasn't aware of this, will give it a spin as I'm using Raspbian Jessie.

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

Re: Sense HAT joystick problem

Mon Apr 24, 2017 7:42 pm

I found it a little confusing at first but persevered and got it to do what I wanted it to do. I'm no python expect and learning as o go along.

Return to “Astro Pi”