[AstroPi] emulator SenseHat and matrix of LEDs


the presence of Thomas Pesquet in Station international space (ISS) has helped with the ESA propose a contest to schoolchildren, college students and European students.
Many french participants were selected to provide applications that will run on the Raspberry Pi embarked on the ISS.
I received several aid applications to which I answer my best. To help those who start and struggling to work on their programs with the SenseHat, let’s see how to install an emulator of cards SenseHat on the Raspberry Pi, then an emulator of matrix led to the SenseHat who will help to create animations or crests/logos to accompany the programs.


reminder of the features of the SenseHat



I presented the SenseHat upon its release, end of 2015.



the card is equipped with accelerometers and gyroscopes made in nano-technology, which record movement according to the 3 Pitch, Yaw and Roll axes. If it’s not about you, the diagram below should enlighten you 😉



map SenseHat Board


  • a display 8 × 8 LED matrix

  • an accelerometer, a gyroscope and a magnetometer

  • an atmospheric pressure sensor

  • the sensor of temperature and humidity

  • a miniature Joystick

emulator of SenseHat


there are two emulators for the card SenseHat: an online emulator proposed by Trinket a partner company of the emulator to install on the Raspberry Pi Foundation Raspberry Pi and um.


online emulator


online Emulator allows writing Python programs which can be tested on the Simulator (right of image).


sliders located at the bottom right of the window allow to simulate the temperature sensors, pressure and moisture content of the map. This is used to test programs that must react based on the value returned by the sensors.


this emulator can be used with any browser and allows participants to test their accomplishments, even if there are no SenseHat or Raspberry Pi available in the challenge.


emulator on the Raspberry Pi


for participants who have already one or more Raspberry Pi, it is possible to install an emulator, d developed by Dave Jones, that allows to simulate the SenseHat card. D are sliders are also used to change the values sent by the sensors while the code is running.


why did you create this second version?


  • for use offline, what is the most common use of the Raspberry Pi in a classroom.

  • to allow the use of the older models of Raspberry Pi 256 MB that cannot run the web version.

  • to allow you to use a SenseHAT program with all the Python modules available, or with other features of the Raspberry Pi as the camera module.


you can find the emulator in the programming of Menu Raspbian pixel. When you click it, the window Sense Hat Emulator opens.


you have sliders simulating sensors and buttons instead of the mini joystick.


you’re going to be able to control the card emulator in Python SenseHat: for my tests I opened a Python 2 (IDLE) and entered


 from sense_emu import SenseHat sense = red SenseHat() = (255, 0, 0) sense.show_message ('framboise314', text_colour = red) 


and the message appears in red on the display (here the beginning of ‘framboise314’).


a matrix led emulator


this is Denis, teacher of technology in Brioude (43) who asked me questions about this emulator. The original version is available on the github to AstroPi .


I made a fork I’ve francized , adapted to the new version of SenseHat (former calls were on AstroPi). I also did a few cosmetic changes that the texts in french held in the buttons. This version is of course available if you want to modify or adapt it to your needs.


install the emulator of LED matrix


[$19459056]pi@raspberrypi:~ git clone https://href.li/?https://github.com/framboise314/RPi_8x8GridDraw clone in ‘RPi_8x8GridDraw’… remote: Counting objects: 81, done.]

Remote: Compressing objects: 100% (27/27), done.

Remote: Total 81 (delta 16), reused 0 (delta 0), pack-reused 54 unpacking objects: 100% (81/81), done.

Connectivity… checked.

PI@raspberrypi:~ $

a copy of the directory is fast and should not be a problem.


[$19459056]pi@raspberrypi:~/RPi_8x8GridDraw ls 8x8grid – astropi.py 8x8grid – unicorn.py buttons.py led.py licence.md README.md

in the folder we find classes led and buttons necessary for the operation of the emulator program matrix: 8x8grid – astropi.py .]


feel free to rename it. I found the name is a bit long, I renamed him 8 × 8 .py…


run emulation


in the terminal type python 8x8grid – astropi.py


[$19459056]pi@raspberrypi:~/RPi_8x8GridDraw python 8x8grid – astropi.py

which will open the window for the emulator:


If you click on a LED she will take the selected color (red by default).] He will have to click the button plays on LED at the bottom right to transfer the image onto the LED of the matrix.


it is possible to record an animation frame by frame, and save it for later charging.




note


the animation or image backup is always done with the same name. If you want to keep the files, it will consider rename them, otherwise it will be overwritten when the next backup.



the video below shows you the functioning of this emulator.



with the tools presented in this article you can prepare the challenge of ESA or simply train yourself to the programming of the SenseHat without the card.


for those who might be tempted by the purchase of the SenseHat , these emulators will give you the means to verify if it matches your expectations.



Sense HAT emulator




No comments:

Powered by Blogger.