Display 8x8 icons on an Astro-Pi / Sense HAT based on sensor values and APIs
And how to satisfy them on a Raspberry Pi
dateutil
: sudo apt-get install python3-dateutil
sudo apt-get install sense-hat
pip3 install --user unicornhathd
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.
./display_digit.py
.loop.py
can display data from any available source.
./loop.py digit samples/digit
will display the digit from above, but with a banner icon../loop.py random 1 10
will 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.
random
source has parameters min
and max
which control the lowest and highest random number the source will produce.digit
source has parameter filename
which 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:
wipe
scroll
(To do)
refresh_trains.sh ORG DST
will update the train data (ORG and DST are the 3-letter codes for origin and destination station)refresh_weather.sh STATION
will 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
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.