pimoroni / pirate-audio

Examples and documentation for the Pirate Audio range of Raspberry Pi add-ons
MIT License
248 stars 50 forks source link

How can I write an image to the screen? #40

Closed DeadpoolDiego closed 1 year ago

DeadpoolDiego commented 3 years ago

I have looked through the code (I have the small speaker board) but am still unsure how to select an image in the image example code. How do I select an image from files? Does the image need to be a certain format? What can I do?

rnsi commented 3 years ago

https://github.com/pimoroni/st7789-python/blob/master/examples/image.py

python image.py /path/to/image/file.jpg

DeadpoolDiego commented 3 years ago

Ok I'm kind of a noob. Do I run the script using the Pi's console and put the path to the image after typing image.py or do I have to edit the script in some way.

rnsi commented 3 years ago

Right. From the console, and put the image after image.py

DeadpoolDiego commented 3 years ago

Is there a way I can get it to do this automatically when the pi powers on?

rnsi commented 3 years ago

https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/all

DeadpoolDiego commented 3 years ago

If I use crontab -e to allow the pi to run a script from startup I have to type below it: "@reboot python /path/to/script.py &". Where do I put the path to the image in this command?

rnsi commented 3 years ago

Just put it in /etc/rc.local

/path/to/python /path/to/script.py /path/to/image &

Find your path to python with: which python

DeadpoolDiego commented 3 years ago

There is an error when running the script regularly. It says "/usr/local/lib/python2.7/dist-packages/ST7789/_.init.py", line 124, in init" No such file or directory. I did also install the st7789 library. How do I fix this? It is important to note that when checking the file explorer, the specified file does exist.

duracell80 commented 3 years ago

Was the st7789 library installed via pip?

sudo apt-get update sudo apt-get install python-rpi.gpio python-spidev python-pip python-pil python-numpy

sudo pip install st7789