diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76ce7fc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.jpg diff --git a/epic.desktop b/epic.desktop deleted file mode 100644 index 7b64b06..0000000 --- a/epic.desktop +++ /dev/null @@ -1,5 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Epic Photos -Exec=/home/pi/code/epic/start-epic.sh -StartupNotify=true \ No newline at end of file diff --git a/epic.py b/epic.py index f4a3341..4638f3b 100644 --- a/epic.py +++ b/epic.py @@ -24,7 +24,7 @@ screen.fill((0,0,0)) # Display loading image -image = pygame.image.load(r"./loading.jpg") +image = pygame.image.load(r"/home/pi/code/epic/loadingimage/loading.jpg") screen.blit(image, (0,0)) pygame.display.flip() @@ -60,7 +60,7 @@ def save_photos(imageurls): cropped.blit(image,(0,0),(125,125,830,830)) cropped = pygame.transform.scale(cropped, (480,480)) - pygame.image.save(cropped,"./"+str(counter)+".jpg") + pygame.image.save(cropped,"/home/pi/code/epic/images/"+str(counter)+".jpg") counter+=1 print("photos saved") @@ -73,7 +73,7 @@ def rotate_photos(num_photos, rotate_delay): pygame.quit() # Create a surface object and draw image on it. - image = pygame.image.load(r"./"+str(counter)+".jpg") + image = pygame.image.load(r"/home/pi/code/epic/images/"+str(counter)+".jpg") # Display image screen.blit(image, (0,0)) diff --git a/epic.service b/epic.service new file mode 100644 index 0000000..4117b10 --- /dev/null +++ b/epic.service @@ -0,0 +1,17 @@ +[Unit] +Description=Epic Globe Display +Wants=network.target +After=network.target + +[Service] +Environment=DISPLAY=:0 +Environment=XAUTHORITY=/home/pi/.Xauthority +ExecStart=/usr/bin/python3 /home/pi/code/epic/epic.py +Restart=always +RestartSec=10s +KillMode=process +TimeoutSec=infinity + + +[Install] +WantedBy=graphical.target diff --git a/images/.gitignore b/images/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/images/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/loading.jpg b/loadingimage/loading.jpg similarity index 100% rename from loading.jpg rename to loadingimage/loading.jpg diff --git a/readme.md b/readme.md index 2751df5..5bdf91d 100644 --- a/readme.md +++ b/readme.md @@ -18,16 +18,22 @@ I've been fiddling with this for over a year now, so I've never followed these i I'll assume you've already followed Pimoroni's instructions for getting the Hyperpixel Round screen going. 1. Use the terminal or log in as pi via ssh. -1. Create the directory `mkdir ~pi/code/epic/` -1. Go into the directory `cd ~pi/code/epic/` +1. Create the directory `mkdir ~/code/epic/` +1. Go into the directory `cd ~/code/epic/` +1. Crate image directory `mkdir images` 1. Copy the code from this repository in - * `git clone https://github.com/MattGrayYes/epic.git .` -1. make sure `start-epic.sh` is executable (`chmod +x start-epic.sh`) -1. Copy the autostart file `cp epic.desktop ~pi/.config/autostart/` + * `git clone https://github.com/vwillcox/epic.git .` +1. move Service file into place + * `sudo cp epic.service /etc/systemd/system` + * `sudo systemctl daemon-reload` + * `sudo systemctl enable epic.service` + * `sudo reboot` +1. On reboot the screen should load into the display with a slight delay. + +## Errors running + 1. Install any python requirements `pip3 install -r requirements.txt` -1. Test you can run it `./start-epic.sh` - * If that doesn't work, test you can run it directly `python3 -u epic.py` - * If it still doesn't work check the output for errors, and google them. +1. Test you can run it directly `python3 -u epic.py` 1. If the test works, kill it with CTRL+C 1. Reboot and hope it runs automatically `sudo reboot` diff --git a/requirements.txt b/requirements.txt index 3856a2d..d91afd7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -pygame==1.9.4.post1 -requests==2.21.0 \ No newline at end of file +pygame +requests diff --git a/start-epic.sh b/start-epic.sh deleted file mode 100755 index 4f35a49..0000000 --- a/start-epic.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -cd ~pi/code/epic -bash brightness.sh 50 -python3 -u epic.py > /dev/null