Skip to content

Commit 5d221ed

Browse files
author
BytequillPC
committed
Cleanup + README
1 parent 9722781 commit 5d221ed

11 files changed

Lines changed: 26 additions & 8 deletions

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
**/__pycache
1+
**/__pycache__
22
.vscode
33
.cache
44
log.log
55

66
# Came with the library as an example program, used it for API reference
7-
simple-program.py
7+
simple-program.py
8+
9+
tmp
10+
screencap.png

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
![Demonstration](demonstration.png)
2+
Spotify display for screens compatible with https://github.com/mathoudebine/turing-smart-screen-python/
3+
4+
DISCLAIMER: Environment variable configuration is not currently implemented, you have to change constants
-3.68 KB
Binary file not shown.

demonstration.png

62.8 KB
Loading
-2.85 KB
Binary file not shown.
-8.21 KB
Binary file not shown.
-840 Bytes
Binary file not shown.
-8.81 KB
Binary file not shown.
-34.6 KB
Binary file not shown.

main.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from library.lcd.lcd_comm_rev_a import LcdCommRevA, Orientation
1+
from library.lcd.lcd_comm_rev_a import LcdCommRevA
2+
from library.lcd.lcd_simulated import LcdSimulated
3+
from library.lcd.lcd_comm import LcdComm, Orientation
24
from PIL import Image
35
from time import sleep
46
from spotify_auth import HandleAuth
@@ -10,6 +12,7 @@
1012
import urllib.request as urllib
1113

1214
COM_PORT = "AUTO"
15+
COM_REV = LcdCommRevA
1316
WIDTH, HEIGHT = 480, 320
1417
BRIGHTNESS = 45
1518
BGCOL = (50, 50, 50)
@@ -22,7 +25,7 @@
2225
SP: spotipy.Spotify
2326

2427
class App:
25-
def __init__(self, comm: LcdCommRevA) -> None:
28+
def __init__(self, comm: LcdComm) -> None:
2629
self.comm = comm
2730
self.sp: spotipy.Spotify = None
2831
self.lock = GLOBAL_LOCK
@@ -57,7 +60,7 @@ def _checkForNewSong(self):
5760
if playback["currently_playing_type"] != "track":
5861
print(f"[WARN] This playback type has not been implemented: {playback["currently_playing_type"]}");return
5962
except TypeError: pass
60-
def screenOFFProcedure(self):
63+
def screenOFFProcedure(self: App):
6164
if self.isSong: self.isSong = False
6265
self.current_id = ""
6366
self.lock.acquire()
@@ -100,7 +103,7 @@ def _updateSongBar(self):
100103
i = 0
101104
while RUN:
102105
if i % CHECK_EVERY == 0:
103-
threading.Thread(target=self._checkForNewSong).start() #Runs asynchronously to not disrupt the play bar with internet requests
106+
threading.Thread(target=self._checkForNewSong).start() # Runs asynchronously to not disrupt the play bar with internet requests
104107
i += 1
105108
if self.isSong:
106109
self.lock.acquire()
@@ -187,10 +190,14 @@ def stopall(signum, frame):
187190
signal.signal(signal.SIGTERM, stopall)
188191
signal.signal(signal.SIGINT, stopall)
189192

190-
lcd_comm = LcdCommRevA(com_port=COM_PORT, display_width=WIDTH, display_height=HEIGHT)
193+
if type(COM_REV) == LcdCommRevA:
194+
lcd_comm = COM_REV(com_port=COM_PORT, display_width=WIDTH, display_height=HEIGHT)
195+
else:
196+
lcd_comm = COM_REV(com_port=COM_PORT, display_width=HEIGHT, display_height=WIDTH)
191197
lcd_comm.Reset()
192198
lcd_comm.InitializeComm()
193199
lcd_comm.SetBrightness(level=BRIGHTNESS)
200+
194201
#lcd_comm.Clear() # This is not actually needed since we restart and use ClearWithBG. Just takes up time on init
195202
lcd_comm.SetOrientation(orientation=Orientation.LANDSCAPE)
196203
lcd_comm.ScreenOn()
@@ -207,4 +214,6 @@ def stopall(signum, frame):
207214
while RUN:
208215
pass
209216

210-
lcd_comm.closeSerial()
217+
lcd_comm.closeSerial()
218+
219+
# TODO: add .env configuration

0 commit comments

Comments
 (0)