@@ -81,8 +81,8 @@ def HWPlayToneBlocked(freq: int, duration: int):
8181 "1:lost" , ],
8282 [
8383 "1:but" ,
84- "1 :now" ,
85- "1 :am" ,
84+ "2 :now" ,
85+ "2 :am" ,
8686 "1:found" , ],
8787 [
8888 "1:Was" ,
@@ -171,8 +171,8 @@ def __init__(self):
171171 self .playToSpeaker = False
172172 self .restart = False
173173 self .adhocFreq = - 1
174- self .lyricX = - 1
175- self .lyricY = - 1
174+ # self.lyricColIdx = -1
175+ # self.lyricRowIdx = -1
176176
177177 dd .recordLayerSetupCommands ()
178178
@@ -186,10 +186,21 @@ def __init__(self):
186186 self .playLayer = self .setupButton ("⏯" )
187187 self .restartLayer = self .setupButton ("⏮" )
188188 self .targetLayer = self .setupButton ("📢" )
189- self .lyricLayer = LayerLcd (dd , 40 , 4 )
189+ self .lyricLayer = LayerGraphical (dd , 260 , 50 )
190190 self .lyricLayer .margin (2 )
191- self .lyricLayer .border (1 , "blue" , "round" )
192- self .lyricLayer .writeCenteredLine ("hello" , 1 )
191+ self .lyricLayer .border (2 , "blue" , "round" )
192+ self .lyricLayer .backgroundColor ("lightgray" )
193+ self .lyricLayer .setTextColor ("violet" )
194+ if True :
195+ #self.lyricLayer.setTextSize(12)
196+ self .lyricLayer .print ("hello " )
197+ self .lyricLayer .setTextColor ("blue" )
198+ #self.lyricLayer.setTextSize(16)
199+ self .lyricLayer .print ("world " )
200+ # self.lyricLayer = LayerLcd(dd, 40, 4)
201+ # self.lyricLayer.margin(2)
202+ # self.lyricLayer.border(1, "blue", "round")
203+ # self.lyricLayer.writeCenteredLine("hello", 1)
193204
194205 if not HWPlayToneBlocked :
195206 self .targetLayer .disabled ()
@@ -204,14 +215,20 @@ def __init__(self):
204215
205216 def run (self ):
206217 while True :
207- i = 0
218+ songIdx = 0
219+ targetLyricI = 0
220+ targetLyricSkip = 0
221+ lyricRowIdx = 0
222+ lyricColIdx = 0
208223 while True :
209224 dd .timeslice ()
210225 if self .adhocFreq != - 1 :
211226 # key on DumbDisplay pressed ... play the note/tone of the key press
212227 if not self .play :
213228 self .lyricLayer .clear ()
214- self .lyricLayer .writeCenteredLine (f"🎵 { self .adhocFreq } " , 1 )
229+ self .lyricLayer .setCursor (0 , 0 )
230+ self .lyricLayer .setTextColor ("blue" )
231+ self .lyricLayer .print (f" 🎵 { self .adhocFreq } " )
215232 PlayTone (self .adhocFreq , 200 , self .playToSpeaker )
216233 self .adhocFreq = - 1
217234 if self .restart :
@@ -221,15 +238,7 @@ def run(self):
221238 if not self .play :
222239 continue
223240
224- if self .lyricX != - 1 and self .lyricY != - 1 :
225- lyeric1 = ""
226- lyeric2 = ""
227- lyerics1 = Lyrics [self .lyricY ]
228- for l1 in lyerics1 :
229- noteCount = int (l1 [0 :1 ])
230- lyeric1 = lyeric1 + l1 [2 :] + " "
231- self .lyricLayer .writeCenteredLine (lyeric1 , 1 )
232- self .lyricLayer .writeCenteredLine (lyeric2 , 2 )
241+ i = songIdx * 2
233242 noteName = Song [i ]
234243 if noteName == "Z" :
235244 # reached end of song => break out of loop
@@ -244,11 +253,43 @@ def run(self):
244253 # get the how to to play the note/tone for
245254 duration = BeatSpeed * (ord (Beat [i ]) - ord ('0' ))
246255
256+ # show the lyric
257+ dd .recordLayerCommands ()
258+ self .lyricLayer .clear ()
259+ self .lyricLayer .setCursor (0 , 0 )
260+ lyricRow = Lyrics [lyricRowIdx ]
261+ for i , lyric in enumerate (lyricRow ):
262+ if i == targetLyricI :
263+ noteCount = int (lyric [0 :1 ])
264+ if (noteCount - targetLyricSkip ) <= 1 :
265+ # targetLyricI = targetLyricI + 1
266+ # targetLyricSkip = 0
267+ advance = True
268+ else :
269+ advance = False
270+ targetLyricSkip = targetLyricSkip + 1
271+ print (lyric [2 :])
272+ lyric = " " + lyric [2 :]
273+ self .lyricLayer .print (lyric )
274+ dd .playbackLayerCommands ()
275+ if advance :
276+ if lyricColIdx < len (lyricRow ) - 1 :
277+ lyricColIdx = lyricColIdx + 1
278+ targetLyricI = targetLyricI + 1
279+ targetLyricSkip = 0
280+ else :
281+ lyricColIdx = 0
282+ targetLyricI = 0
283+ targetLyricSkip = 0
284+ if lyricRowIdx < len (Lyrics ) - 1 :
285+ lyricRowIdx = lyricRowIdx + 1
286+ else :
287+ lyricRowIdx = 0
288+
247289 # play the note/tone
248290 PlayTone (freq , duration , self .playToSpeaker )
249291
250- # increment i by 2
251- i = i + 2
292+ songIdx = songIdx + 1
252293
253294
254295 def setupKey (self , octaveOffset : int , noteIdx : int ) -> LayerGraphical :
@@ -300,8 +341,8 @@ def feedbackHandler(self, layer, type, x, y):
300341 self .play = not self .play
301342 if self .play :
302343 self .playLayer .backgroundColor ("lightgreen" )
303- self .lyricX = 0
304- self .lyricY = 0
344+ # self.lyricColIdx = 0
345+ # self.lyricRowIdx = 0
305346 else :
306347 self .playLayer .noBackgroundColor ()
307348 elif layer == self .targetLayer :
@@ -312,8 +353,8 @@ def feedbackHandler(self, layer, type, x, y):
312353 self .targetLayer .noBackgroundColor ()
313354 elif layer == self .restartLayer :
314355 self .restart = True
315- self .lyricX = 0
316- self .lyricY = 0
356+ # self.lyricColIdx = 0
357+ # self.lyricRowIdx = 0
317358 else :
318359 octaveOffset = layer .octaveOffset
319360 noteIdx = layer .noteIdx
0 commit comments