Display 8x8 icons on an Astro-Pi / Sense HAT based on sensor values and APIs
And how to satisfy them on a Raspberry Pi
- Python 3 (out of the box)
dateutil:sudo apt-get install python3-dateutil- Sense HAT (https://pythonhosted.org/sense-hat/) :
sudo apt-get install sense-hat - Unicorn HAT :
pip3 install --user unicornhathd - For sunrise, moon phases etc :
pip3 install --user skyfield
NB. Install Sense HAT before skyfield to avoid having two conflicting copies of numpy floating about.
Run ./display_icon.py
It should display a single icon until you exit the program.
By default, the icon is output to your terminal. To display
on a connected Sense HAT, run ./display_icon.py -d sense
If it doesn't work, check the dependencies above. Also check SPI is enabled in raspi-config.
./display_digit.py looks in the file samples/digit for a single digit to display.
- Change the value in this file, then run
./display_digit.py. - Change the value while the program is running.
- What happens if you put something in the file that isn't a digit?
loop.py can display data from any available source.
./loop.py digit samples/digitwill display the digit from above, but with a banner icon../loop.py random 1 10will display random numbers from 1 to 10.
There may be more data sources installed. Run ./loop.py -h to see them all.
You can see help for a specific data source with ./loop.py <source> -h.
The -l parameter makes loop.py repeat the loop for a set time period:
./loop.py -l 5 makes it run for 5 minutes.
loop.py also takes the -d parameter to display the icons on your device.
The previous programs got their information from only one place: they had a single data source.
loop.py can use several data sources, and you can configure which ones it uses.
The supplied configuration displays the random number and the digit from samples/digit in turn.
The data sources for loop.py are configured in the file config.json
containing the sources in the order they appear in the loop.
Each data source has parameters which apply to that source.
- The
randomsource has parametersminandmaxwhich control the lowest and highest random number the source will produce. - The
digitsource has parameterfilenamewhich is the file it looks in for a digit.
Try adding a second random source with a different range, and running ./loop.py again.
You can add a parameter transition to any data source in config.json to specify a transition effect:
wipescroll
(To do)
refresh_trains.sh ORG DSTwill update the train data (ORG and DST are the 3-letter codes for origin and destination station)refresh_weather.sh STATIONwill update the weather data for station number STATION (there's a script in api/ to find your station)
Add these to your crontab as you see fit.
Data is saved into the samples/ directory.
Next edit the config.json file as you want. Here you can configure
- the walk time to your station
- the display speed
Once there is data in the samples file...
display.sh will output icons to the terminal for testing, just once.
sense_hat.sh N will display them on the Sense Hat, looping for N minutes.