From b539f42b87a4e3a1312442c1d54ddc848d39774c Mon Sep 17 00:00:00 2001 From: KemoNine Date: Sun, 16 Aug 2020 01:52:21 -0400 Subject: [PATCH] Add slidshow album controls --- docs/lcd_controls.md | 33 +++++++ docs/slideshow.md | 6 +- lcd_controls.py | 222 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 docs/lcd_controls.md create mode 100644 lcd_controls.py diff --git a/docs/lcd_controls.md b/docs/lcd_controls.md new file mode 100644 index 0000000..7b79460 --- /dev/null +++ b/docs/lcd_controls.md @@ -0,0 +1,33 @@ +# LCD Controls + +The below will setup an Adafruit mini LCD with 2 buttons as a controller for selecting which photo albums are displayed on a PiFrame. This setup also includes the Adafruit stemma/qwiic LUX sensor setup which will be integrated further in the future. + +``` sh + +apt install -y python3-pip ttf-dejavu python3-pil python3-numpy + +pip3 install adafruit-circuitpython-rgb-display adafruit-circuitpython-bh1750 RPI.GPIO +pip3 install --upgrade --force-reinstall spidev + +git clone https://git.kemonine.info/kemonine/piframe.git /opt/piframe +cp /opt/piframe/lcd_control.py /usr/local/bin/ +chmod a+x /usr/local/bin/lcd_control.py +cat > /etc/systemd/system/lcd_control.service < /etc/default/fim_album_path < /usr/local/bin/fim-slideshow.sh < /etc/systemd/system/fim.service <= len(albums): + selected_album = 0 + refresh_screen() + write_selected_album() + watchdog.reset() + +# Interrupt callback for changing albums (dn) +def dn_button(channel): + global selected_album, albums, backlight + backlight.value = True + selected_album -= 1 + if selected_album < 0: + selected_album = len(albums) - 1 + refresh_screen() + write_selected_album() + watchdog.reset() + +# Setup button interrupts +GPIO.add_event_detect(23, GPIO.FALLING, callback=up_button, bouncetime=300) +GPIO.add_event_detect(24, GPIO.FALLING, callback=dn_button, bouncetime=300) + +# Draw initial screen state +refresh_screen() + +# Kick off watchdog to start the 10s initial 'on' status +watchdog.reset() + +# Work with the LCD / Buttons in an infinate loop +while True: + time.sleep(300)