From 031910249b4256eb520cbf3c447808cb8cdbfa5f Mon Sep 17 00:00:00 2001 From: Fredrik Wahlberg Date: Sat, 29 Jan 2022 09:48:05 +0000 Subject: [PATCH] =?UTF-8?q?Gamla=20=C3=A4ndringar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cover.py | 12 ++++++++++++ loop.sh | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) 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