Skip to content

Instantly share code, notes, and snippets.

@HotoRas
Last active February 3, 2024 14:16
Show Gist options
  • Save HotoRas/85163c0884312c802a2f0676c3a96263 to your computer and use it in GitHub Desktop.
Save HotoRas/85163c0884312c802a2f0676c3a96263 to your computer and use it in GitHub Desktop.
ZP-0172 OLED monitor setup batch

To run the shell file:

  1. Copy the file into editor and save, or just wget it.
    • wget command:
      wget https://gist.github.com/HotoRas/85163c0884312c802a2f0676c3a96263/raw/07192a59b0e1efc9fa73205e115a1ce0df73713f/zp-0172-monitor.sh
  2. chmod +x zp-0172-monitor.sh
  3. ./zp-0172-monitor.sh
    • You don't have to and shouldn't pass sudo into the script: stuff will break so disabled in it.
  4. Profit!

All the details are considerably written down.

But if you want to get detailed setup or visualized information, you can visit the wiki to find out.

#!/bin/bash
#info0
echo "This shell script is from
https://wiki.52pi.com/index.php?spm=a2g0o.detail.1000023.1.71427e02hq4nqq&title=ZP-0172
and carefully copied and optimized into single shell file.
"
#info1
echo "This shell script assume you've checked the command
i2cdetect -y 1
after enabling it with raspi-config.
To make sure I'm executing it:"
i2cdetect -y 1
echo ""
#info2
echo "You'll be asked some passwords to run some command.
DO NOT RUN THIS SCRIPT AS SUPER USER! STUFF WILL BREAK!
(If run as SUPER USER or SUDO the script will exit.)
"
#set $USERNAME to the output of whoami
whoami | grep -q 'root' && exit
USRNAME="$(whoami)"
#step 3
sudo apt -y install python3 python3-pip python3-pil libjpeg-dev \
zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7
#step 4 - grant privilleges to user
sudo usermod -a -G gpio,i2c "$USERNAME"
#step 5 - git clone and move to
git clone https://github.com/geeekpi/luma.examples.git
cd luma.examples
#step 6 - install python script
sudo -H pip3 install -e . --break-system-packages
#step 7 - run examples
cd examples
echo "If you want to run the program, you can simply type
cd $(pwd)
and run one of the '.py' files listed here:
"
ls
echo "If you want to edit service, type
sudo nano /lib/systemd/system/minitower_oled.service
(you can use your beloved editor if you want but should pass sudo)
and edit the path after \"ExecStart=/bin/bash -c 'python3\"
to $(pwd)/your-script.py
and restart service with:
sudo systemctl daemon-reload
sudo systemctl restart minitower_oled.service
Here is the basic clock display service. Please check the display."
python3 clock.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment