diff --git a/cover.py b/cover.py index 8fef9bb..55f76e5 100755 --- a/cover.py +++ b/cover.py @@ -1,8 +1,10 @@ from PIL import Image import ST7789 as ST7789 +import RPi.GPIO as GPIO import urllib2 as urllib import requests import io +import time # My music server URL url = "http://192.168.0.114:6680/mopidy/rpc" @@ -36,6 +38,13 @@ HEIGHT = disp.height # Initialize display. disp.begin() +# Setup to be able to change backlight +GPIO.setmode(GPIO.BCM) +GPIO.setup(13, GPIO.OUT) +backlight = GPIO.PWM(13, 500) +# Set max backlight +backlight.start(100) + # Load an image. print('Loading image: {}...'.format(image_file)) image = Image.open(image_file) @@ -47,3 +56,6 @@ image = image.resize((WIDTH, HEIGHT)) print('Drawing image') disp.display(image) +time.sleep(120) +backlight.ChangeDutyCycle(1) + diff --git a/loop.sh b/loop.sh index c3a4774..3299c1f 100755 --- a/loop.sh +++ b/loop.sh @@ -3,6 +3,5 @@ while [ "a" != "b" ] do python cover.py - sleep 30 mpc --host 192.168.0.114 -q idle player done