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
24from PIL import Image
35from time import sleep
46from spotify_auth import HandleAuth
1012import urllib .request as urllib
1113
1214COM_PORT = "AUTO"
15+ COM_REV = LcdCommRevA
1316WIDTH , HEIGHT = 480 , 320
1417BRIGHTNESS = 45
1518BGCOL = (50 , 50 , 50 )
2225SP : spotipy .Spotify
2326
2427class 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