File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Adafruit PyPortal display of Twin Peaks
2+ # Liz (BlitzCityDIY) for Adafruit Industries MIT License
3+ # Tutorial: https://learn.adafruit.com/twin-peaks-light-reactive-pyportal-picture-frame
4+ import time
5+ import board
6+ import displayio
7+ from analogio import AnalogIn
8+ from adafruit_pyportal import PyPortal
9+
10+ analogin = AnalogIn (board .LIGHT )
11+
12+ cwd = ("/" + __file__ ).rsplit ('/' , 1 )[0 ]
13+
14+ laura = (cwd + "/laura.bmp" )
15+
16+ woodsman = (cwd + "/woodsman.bmp" )
17+
18+ gottaLight = (cwd + "/gottaLight.wav" )
19+
20+ pyportal = PyPortal (default_bg = laura )
21+
22+ def getVoltage (pin ): # helper
23+ return (pin .value * 3.3 ) / 65536
24+
25+ while True :
26+
27+ if getVoltage (analogin ) > 0.175 :
28+ pyportal .set_background (laura )
29+ time .sleep (1 )
30+ else :
31+ pyportal .set_background (woodsman )
32+ pyportal .play_file (gottaLight )
33+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments