Elfen
Posts: 34
Joined: Tue Apr 07, 2015 8:03 pm

How will GPIOZero Effect Astro Pi Programming?

Sat Oct 21, 2017 8:55 pm

Having built one, I'm just rather confused on accessing the GPIO buttons. And now that the last Jessie and new Scratch has GPIO Zero, how will that change how the buttons and the rest of the Sense hat be accessed?

I'm trying to write a simple program that when one of the buttons are pressed, it accessed a subroutine, like display temperature. But I'm scratching my head as to how GPIO Zero does this now.

User avatar
scruss
Posts: 1399
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How will GPIOZero Effect Astro Pi Programming?

Sat Oct 21, 2017 9:45 pm

Since Ben Nuttall has had a big hand in developing both GPIO Zero and the Sense Hat software, he might be able to answer the best.

The Sense Hat seems mostly to use I²C for device communication, where GPIO Zero (currently) focuses on SPI devices. So you can't (?) currently use GPIO Zero to talk to the Sense Hat.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
Davespice
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1634
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website Twitter

Re: How will GPIOZero Effect Astro Pi Programming?

Mon Oct 23, 2017 2:57 pm

So you don't need to use gpiozero or any GPIO library, there's a device tree overlay that you enable and this causes the buttons to type the letters u, d, l, r (top quad), and a, b (bottom pair) when pressed. Since the Sense HAT joystick is mapped to the cursor keys and Enter (for the middle click) this allows you to use something like Pygame or Evdev to read input from both at the same time.

Check out the "Test the buttons" step on this resource: https://projects.raspberrypi.org/en/pro ... light-case
The code in the pygame_test.py example shows how to do both buttons and joystick at the same time.

The Astro Pi FAQ (https://astro-pi.org/missions/space-lab/faq/) also suggests not to use any GPIO library because a device tree overlay like this will already be hogging the edge detection events for those GPIO lines on the flight units on board the ISS. So if you do include gpio code in your entry it wouldn't run on a flight unit, it would just throw a runtime error.

Good luck with it!

Elfen
Posts: 34
Joined: Tue Apr 07, 2015 8:03 pm

Re: How will GPIOZero Effect Astro Pi Programming?

Mon Oct 23, 2017 5:48 pm

Interesting Davespice...

I'm using the last version of Jessie for my AstroPi, which according to the docs I find says that GPIOZero is part of the Library, thus my concern and query about GPIOZero and the AstroPi GPIO Buttons.

Thus far I have not used GPIOZero Statements in my program and it seems to work fine. Basically, I mashed up the pygame.py and the scrolling_env.py programs to get the basic of what I want as 'my first serious program.' Just ran into a possible bug which is more of a Python issues and not a hardware issue with the R-Pi and/or the Sense_Hat. Also ran into another issue which is hardware but mine AstroPi is not a "standard" AstroPi, as it uses the R-Pi 3, which is causing the problem. I'll post up a separate post on this forum section about it. In the least it is an interesting and confirmed observation in using an R-Pi 3 for the AstroPi.

Many thanks for the help! I seem to be going in the right direction.

bensimmo
Posts: 1914
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: How will GPIOZero Effect Astro Pi Programming?

Mon Oct 23, 2017 6:59 pm

Other problems of using the Pi3/Pi2 you may or may not run in to.
It has more memory and more processing power.
We use them here and developed on our 2 and 3 for our A+'s to then run in our rockets.

Well turns out we didn't count on the A+'s not liking the setting we used for all out data collection, camera video (and GPS).

While the B+ used does have twice the memory of our A+'s the speed is the same 700MHz and single core assuming. (We ran the A+ @ 1000MHz like the Zero's.)

If you are doing a lot of stuff, it may be worth testing on a Pi Zero and clocking it down at 700MHz as a check.

User avatar
Davespice
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1634
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
Contact: Website Twitter

Re: How will GPIOZero Effect Astro Pi Programming?

Tue Oct 24, 2017 11:25 am

It's perfectly valid and okay to use a Pi 3 in an Astro Pi, there's even a printable base file which has the LED holes moved over to the other side. The only advice we give out to people is to avoid using a metal stand-off next to the little white WiFi chip, as this will degrade WiFi performance.

Return to “Astro Pi”

Who is online

Users browsing this forum: No registered users and 1 guest