|
@@ -1,4 +1,3 @@
|
1
|
|
-
|
2
|
1
|
import random
|
3
|
2
|
import time
|
4
|
3
|
import pygame
|
|
@@ -13,17 +12,37 @@ from datetime import date
|
13
|
12
|
import ast
|
14
|
13
|
import random
|
15
|
14
|
from pathlib import Path
|
16
|
|
-import socket
|
|
15
|
+#import socket
|
17
|
16
|
import FSM
|
18
|
17
|
|
19
|
18
|
import utils as u
|
20
|
19
|
import menus as m
|
21
|
20
|
|
22
|
21
|
#states
|
|
22
|
+from sMain import Main
|
|
23
|
+from sSelectSound import SelectSound
|
|
24
|
+from sSelectPattern import SelectPattern
|
|
25
|
+from sEditSong import EditSong
|
|
26
|
+from sEditSoundSequence import EditSoundSequence
|
|
27
|
+from sFile import File
|
|
28
|
+from sUtil import Util
|
|
29
|
+from sBall import Ball
|
|
30
|
+from sExit import Exit
|
|
31
|
+from sReboot import Reboot
|
|
32
|
+from sClock import Clock
|
|
33
|
+from sShutdown import Shutdown
|
|
34
|
+from sSelTheme import SelTheme
|
|
35
|
+from sOpenSong import OpenSong
|
|
36
|
+from sEnterText import EnterText
|
|
37
|
+from sLoadSound import LoadSound
|
|
38
|
+from sPing import Ping
|
|
39
|
+from sWifi import Wifi
|
|
40
|
+from sDefender import Defender
|
23
|
41
|
from sCalculator import Calculator
|
24
|
42
|
from sAbout import About
|
25
|
43
|
from sUpdate import Update
|
26
|
|
-
|
|
44
|
+from sSelectFolder import SelectFolder
|
|
45
|
+from sNewDir import NewDir
|
27
|
46
|
#====================================
|
28
|
47
|
|
29
|
48
|
State = type("State", (object,), {})
|
|
@@ -163,182 +182,6 @@ class LoadDefault(State):
|
163
|
182
|
|
164
|
183
|
#====================================
|
165
|
184
|
|
166
|
|
-class Main(State):
|
167
|
|
- def __init__(self,FSM):
|
168
|
|
- super(Main, self).__init__(FSM)
|
169
|
|
-
|
170
|
|
- def Enter(self):
|
171
|
|
- print('hello main')
|
172
|
|
- self.FSM.owner.pub.register("beat", self)
|
173
|
|
- self.FSM.stateLife = 1
|
174
|
|
- o = self.FSM.owner
|
175
|
|
- o.header_text = "Sound Select"
|
176
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
177
|
|
- pass
|
178
|
|
- else:
|
179
|
|
- u.draw_header(o)
|
180
|
|
- self.draw_square()
|
181
|
|
-
|
182
|
|
- u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
|
183
|
|
- u.text_box2(o, "BPM", str(o.bpm))
|
184
|
|
- u.text_box4(o, "Bank", str(o.note_bank))
|
185
|
|
- u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
|
186
|
|
- o.update_display(0)
|
187
|
|
-
|
188
|
|
- #o.soundSlots[2].volume = 2
|
189
|
|
- self.recording = True
|
190
|
|
- self.record_queue = []
|
191
|
|
- self.undo_queue = []
|
192
|
|
- super(Main, self).Enter()
|
193
|
|
-
|
194
|
|
- def Execute(self):
|
195
|
|
- o = self.FSM.owner
|
196
|
|
-
|
197
|
|
- # if o.keyState[16] == 2:
|
198
|
|
- # o.button_repeater(0, [8,9,14,15])
|
199
|
|
-
|
200
|
|
- #if o.keyState[17] == 2:
|
201
|
|
- # o.button_repeater(0, [4,5,6,7,8,9])
|
202
|
|
-
|
203
|
|
- m.menu1_actions(self, o)
|
204
|
|
- m.menu2_actions_sample(self, o)
|
205
|
|
- #self.FSM.ToTransition('toClock')
|
206
|
|
- if o.keyState[16] == 1:
|
207
|
|
- m.draw_menu1(o)
|
208
|
|
- o.update_display(0)
|
209
|
|
- elif o.keyState[16] == 4:
|
210
|
|
- u.draw_header(o)
|
211
|
|
- self.draw_square()
|
212
|
|
- #print('esound ', o.eSound)
|
213
|
|
- #print('oss ', o.soundSlots[o.eSound].volume)
|
214
|
|
- u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
|
215
|
|
- u.text_box2(o, "BPM", str(o.bpm))
|
216
|
|
- u.text_box4(o, "Bank", str(o.note_bank))
|
217
|
|
- u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
|
218
|
|
- o.button_repeater(1, [])
|
219
|
|
- o.update_display(0)
|
220
|
|
-
|
221
|
|
-
|
222
|
|
-
|
223
|
|
-
|
224
|
|
- if o.keyState[17] == 1:
|
225
|
|
- m.draw_menu2_sample(o)
|
226
|
|
- o.update_display(0)
|
227
|
|
- elif o.keyState[17] == 4:
|
228
|
|
- u.draw_header(o)
|
229
|
|
- self.draw_square()
|
230
|
|
- u.text_box1(o, "Vol", str(o.soundSlots[o.eSound].volume))
|
231
|
|
- u.text_box2(o, "BPM", str(o.bpm))
|
232
|
|
- u.text_box4(o, "Bank", str(o.note_bank))
|
233
|
|
- u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
|
234
|
|
- o.update_display(0)
|
235
|
|
-
|
236
|
|
- _id = 0
|
237
|
|
- for k in o.keyState:
|
238
|
|
- if _id > 15:
|
239
|
|
- pass
|
240
|
|
- else:
|
241
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
242
|
|
- pass
|
243
|
|
- else:
|
244
|
|
- if k == 1:
|
245
|
|
- note = _id + o.note_bank * 16
|
246
|
|
- self.record_queue = pygame.time.get_ticks()
|
247
|
|
- print('bpm is ', o.half_bpm, ' ', self.record_queue)
|
248
|
|
-
|
249
|
|
- o.soundSlots[note].play(o.note_vol)
|
250
|
|
- o.eSound = note
|
251
|
|
- #print('now editing sound ', o.eSound)
|
252
|
|
- u.draw_header(o)
|
253
|
|
- #u.text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
|
254
|
|
- u.text_box1(o, "SVol", str(o.slots[o.eSound].volume))
|
255
|
|
- u.text_box2(o, "BPM", str(o.bpm))
|
256
|
|
- u.text_box4(o, "Bank", str(o.note_bank))
|
257
|
|
- #u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
|
258
|
|
- u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
|
259
|
|
- self.draw_square()
|
260
|
|
- o.update_display(0)
|
261
|
|
- _id += 1
|
262
|
|
-
|
263
|
|
- def ReceiveMessage(self, message):
|
264
|
|
- o = self.FSM.owner
|
265
|
|
- u.play_seq(o, message)
|
266
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
267
|
|
- pass
|
268
|
|
- else:
|
269
|
|
- u.draw_header(o)
|
270
|
|
- self.draw_square()
|
271
|
|
- u.text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
|
272
|
|
- u.text_box2(o, "BPM", str(o.bpm))
|
273
|
|
- u.text_box4(o, "Bank", str(o.note_bank))
|
274
|
|
- u.text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
|
275
|
|
- o.update_display(0)
|
276
|
|
- if self.record_queue != []:
|
277
|
|
- cur_time = pygame.time.get_ticks()
|
278
|
|
- note_pos = (cur_time - self.record_queue) - (o.half_bpm / 2)
|
279
|
|
- #print(note_pos)
|
280
|
|
- if o.odub == True:
|
281
|
|
- if note_pos > (o.half_bpm):
|
282
|
|
- _note = 0
|
283
|
|
- if message[1] == 0:
|
284
|
|
- _note = 15
|
285
|
|
- else:
|
286
|
|
- _note = message[1] - 1
|
287
|
|
-
|
288
|
|
- if o.soundSlots[o.eSound].notes[message[0]][_note][0] != 1:
|
289
|
|
- o.soundSlots[o.eSound].notes[message[0]][_note][0] = 1
|
290
|
|
- o.soundSlots[o.eSound].notes[message[0]][_note][1] = o.note_vol
|
291
|
|
- o.undo_buf.append([o.eSound, message[0], _note])
|
292
|
|
- print(o.undo_buf)
|
293
|
|
-
|
294
|
|
- else:
|
295
|
|
- if o.soundSlots[o.eSound].notes[message[0]][message[1]][0] != 1:
|
296
|
|
- o.soundSlots[o.eSound].notes[message[0]][message[1]][0] = 1
|
297
|
|
- o.soundSlots[o.eSound].notes[message[0]][message[1]][1] = o.note_vol
|
298
|
|
- o.undo_buf.append([o.eSound, message[0], message[1]])
|
299
|
|
- print(o.undo_buf)
|
300
|
|
-
|
301
|
|
- self.record_queue = []
|
302
|
|
-
|
303
|
|
-
|
304
|
|
- def draw_square(self):
|
305
|
|
- o = self.FSM.owner
|
306
|
|
- size = 22
|
307
|
|
- og_x = (o.width / 2) - (size * 2)
|
308
|
|
- o_x = og_x
|
309
|
|
- o_y = 127
|
310
|
|
- _id = o.note_bank * 16
|
311
|
|
-
|
312
|
|
- while _id < ((o.note_bank * 16) + 16):
|
313
|
|
- if _id == o.eSound:
|
314
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
|
315
|
|
- elif o.notes_on[_id] == 1:
|
316
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.grey, width=1)
|
317
|
|
- #elif _id > (len(o.soundSlots) - 1):
|
318
|
|
- elif self.has_sample(o, _id) == False:
|
319
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.dark_grey, width=1)
|
320
|
|
-
|
321
|
|
-
|
322
|
|
- else:
|
323
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
|
324
|
|
- o_x = o_x + size
|
325
|
|
- _id += 1
|
326
|
|
- if _id % 4 == 0:
|
327
|
|
- o_y -= size
|
328
|
|
- o_x = og_x
|
329
|
|
-
|
330
|
|
- def has_sample(self, o, slot):
|
331
|
|
- if o.soundSlots[slot].file != None:
|
332
|
|
- return True
|
333
|
|
- else:
|
334
|
|
- return False
|
335
|
|
-
|
336
|
|
- def Exit(self):
|
337
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
338
|
|
-
|
339
|
|
-#====================================
|
340
|
|
-#====================================
|
341
|
|
-
|
342
|
185
|
class PadPlayer(State):
|
343
|
186
|
def __init__(self,FSM):
|
344
|
187
|
super(PadPlayer, self).__init__(FSM)
|
|
@@ -411,2166 +254,3 @@ class SeqPlayer(State):
|
411
|
254
|
self.FSM.owner.pub.unregister("beat", self)
|
412
|
255
|
|
413
|
256
|
#====================================
|
414
|
|
-#====================================
|
415
|
|
-
|
416
|
|
-class SelectSound(State):
|
417
|
|
- def __init__(self,FSM):
|
418
|
|
- super(SelectSound, self).__init__(FSM)
|
419
|
|
-
|
420
|
|
- def Enter(self):
|
421
|
|
- self.FSM.stateLife = 1
|
422
|
|
- o = self.FSM.owner
|
423
|
|
- o.header_text = "SelSou"
|
424
|
|
- o.pub.register("beat", self)
|
425
|
|
- u.draw_header(o)
|
426
|
|
- self.draw_square()
|
427
|
|
- o.update_display(0)
|
428
|
|
- super(SelectSound, self).Enter()
|
429
|
|
-
|
430
|
|
- def Execute(self):
|
431
|
|
- o = self.FSM.owner
|
432
|
|
- if o.keyState[16] == 1:
|
433
|
|
- m.draw_menu1(o)
|
434
|
|
- o.update_display(0)
|
435
|
|
- elif o.keyState[16] == 4:
|
436
|
|
- u.draw_header(o)
|
437
|
|
- self.draw_square()
|
438
|
|
- o.update_display(0)
|
439
|
|
-
|
440
|
|
- if o.keyState[16] == 2:
|
441
|
|
- if o.keyState[0] == 1:
|
442
|
|
- self.FSM.ToTransition('toMain')
|
443
|
|
- else:
|
444
|
|
- _id = 0
|
445
|
|
- for k in o.keyState:
|
446
|
|
- if _id > 15:
|
447
|
|
- pass
|
448
|
|
- else:
|
449
|
|
- if k == 1:
|
450
|
|
- o.eSound = _id
|
451
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
452
|
|
- o.draw.text((0, 0), "SelSou", font=o.h1, fill=o.light_blue)
|
453
|
|
- o.draw.text((20, 60), str(o.eSound), font=o.h2, fill=o.light_grey)
|
454
|
|
- self.draw_square()
|
455
|
|
- o.update_display(0)
|
456
|
|
- self.FSM.owner.soundSlots[_id].play()
|
457
|
|
- #print('now editing sound ', _id)
|
458
|
|
- _id += 1
|
459
|
|
-
|
460
|
|
- def ReceiveMessage(self, message):
|
461
|
|
- _id = 0
|
462
|
|
- o = self.FSM.owner
|
463
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
|
464
|
|
- o.draw.text((0, 0), "SelSou", font=o.h1, fill="#FFFFFF")
|
465
|
|
- o.draw.text((0, 20), str(o.eSound), font=o.h2, fill="#FFFFFF")
|
466
|
|
- o.update_display(0)
|
467
|
|
- u.play_seq(o, message)
|
468
|
|
-
|
469
|
|
- def draw_square(self):
|
470
|
|
- o = self.FSM.owner
|
471
|
|
- size = 32
|
472
|
|
- og_x = 110
|
473
|
|
- o_x = og_x
|
474
|
|
- o_y = 0
|
475
|
|
- _id = 0
|
476
|
|
-
|
477
|
|
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
|
478
|
|
- if _id == o.eSound:
|
479
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.light_grey)
|
480
|
|
- else:
|
481
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.dark_grey)
|
482
|
|
- o_x = o_x + size
|
483
|
|
- _id += 1
|
484
|
|
- if _id % 4 == 0:
|
485
|
|
- o_y += size
|
486
|
|
- o_x = og_x
|
487
|
|
-
|
488
|
|
-
|
489
|
|
- def Exit(self):
|
490
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
491
|
|
-
|
492
|
|
-#====================================
|
493
|
|
-
|
494
|
|
-class SelectPattern(State):
|
495
|
|
- def __init__(self,FSM):
|
496
|
|
- super(SelectPattern, self).__init__(FSM)
|
497
|
|
-
|
498
|
|
- def Enter(self):
|
499
|
|
- self.FSM.stateLife = 1
|
500
|
|
- o = self.FSM.owner
|
501
|
|
- o.header_text = "Select Pattern"
|
502
|
|
- o.pub.register("beat", self)
|
503
|
|
- self.cur_playing = 0
|
504
|
|
- self.active_patterns = []
|
505
|
|
- self.get_active_patterns(o)
|
506
|
|
-
|
507
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
508
|
|
- pass
|
509
|
|
- else:
|
510
|
|
- u.draw_header(o)
|
511
|
|
- self.draw_square()
|
512
|
|
- u.text_box1(o, "Pat", str(o.ePattern))
|
513
|
|
- u.text_box4(o, "Bank", str(o.pat_bank))
|
514
|
|
- o.update_display(0)
|
515
|
|
-
|
516
|
|
- super(SelectPattern, self).Enter()
|
517
|
|
-
|
518
|
|
- def Execute(self):
|
519
|
|
- o = self.FSM.owner
|
520
|
|
- m.menu1_actions(self, o)
|
521
|
|
- m.menu2_actions_pattern(self, o)
|
522
|
|
- if o.keyState[16] == 1:
|
523
|
|
- m.draw_menu1(o)
|
524
|
|
- o.update_display(0)
|
525
|
|
- elif o.keyState[16] == 4:
|
526
|
|
- u.draw_header(o)
|
527
|
|
- self.draw_square()
|
528
|
|
- u.text_box1(o, "Pat", str(o.ePattern))
|
529
|
|
- u.text_box4(o, "Bank", str(o.pat_bank))
|
530
|
|
- o.update_display(0)
|
531
|
|
-
|
532
|
|
- if o.keyState[17] == 1:
|
533
|
|
- m.draw_menu2_pattern(o)
|
534
|
|
- o.update_display(0)
|
535
|
|
- elif o.keyState[17] == 4:
|
536
|
|
- u.draw_header(o)
|
537
|
|
- self.get_active_patterns(o)
|
538
|
|
- self.draw_square()
|
539
|
|
- u.text_box1(o, "Pat", str(o.ePattern))
|
540
|
|
- u.text_box4(o, "Bank", str(o.pat_bank))
|
541
|
|
-
|
542
|
|
- o.update_display(0)
|
543
|
|
-
|
544
|
|
-
|
545
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
546
|
|
- pass
|
547
|
|
- else:
|
548
|
|
- _id = 0
|
549
|
|
- for k in o.keyState:
|
550
|
|
- if _id > 15:
|
551
|
|
- pass
|
552
|
|
- else:
|
553
|
|
- if k == 1:
|
554
|
|
- o.ePattern = (o.pat_bank * 16) +_id
|
555
|
|
-
|
556
|
|
- u.draw_header(o)
|
557
|
|
- self.draw_square()
|
558
|
|
-
|
559
|
|
- u.text_box1(o, "Pat", str(o.ePattern))
|
560
|
|
- u.text_box4(o, "Bank", str(o.pat_bank))
|
561
|
|
- o.update_display(0)
|
562
|
|
-
|
563
|
|
-
|
564
|
|
- _id += 1
|
565
|
|
-
|
566
|
|
- def ReceiveMessage(self, message):
|
567
|
|
- o = self.FSM.owner
|
568
|
|
- u.play_seq(o, message)
|
569
|
|
-
|
570
|
|
- if message[0] != self.cur_playing:
|
571
|
|
- #print('playing ', message)
|
572
|
|
- self.cur_playing = message[0]
|
573
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
574
|
|
- pass
|
575
|
|
- else:
|
576
|
|
- u.draw_header(o)
|
577
|
|
- self.draw_square()
|
578
|
|
- u.text_box1(o, "Pat", str(o.ePattern))
|
579
|
|
- u.text_box4(o, "Bank", str(o.pat_bank))
|
580
|
|
- o.update_display(0)
|
581
|
|
-
|
582
|
|
- def draw_square(self):
|
583
|
|
- o = self.FSM.owner
|
584
|
|
- size = 22
|
585
|
|
- og_x = (o.width / 2) - (size * 2)
|
586
|
|
- o_x = og_x
|
587
|
|
- o_y = 127
|
588
|
|
- _id = 0
|
589
|
|
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
|
590
|
|
- if (_id + (o.pat_bank * 16)) == o.ePattern:
|
591
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.olive, width=1)
|
592
|
|
- elif (_id + (o.pat_bank * 16)) == self.cur_playing:
|
593
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
|
594
|
|
- elif self.active_patterns[_id] == 1:
|
595
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
|
596
|
|
- else:
|
597
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.dark_grey, width=1)
|
598
|
|
- o_x = o_x + size
|
599
|
|
- _id += 1
|
600
|
|
- if _id % 4 == 0:
|
601
|
|
- o_y -= size
|
602
|
|
- o_x = og_x
|
603
|
|
-
|
604
|
|
- def get_active_patterns(self, o):
|
605
|
|
- #for n in o.soundSlots[o.eSound]
|
606
|
|
- self.active_patterns = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
|
607
|
|
- pat_iter = o.pat_bank * 16
|
608
|
|
- _iter = 0
|
609
|
|
- #print('is this note on? ', o.soundSlots[0].notes[0][0][0])
|
610
|
|
-
|
611
|
|
-
|
612
|
|
- while pat_iter < ((o.pat_bank * 16) + 16):
|
613
|
|
-
|
614
|
|
- for s in o.soundSlots:
|
615
|
|
- #print('checking soundSlot ', s.id)
|
616
|
|
- pat_used = 0
|
617
|
|
- for p in s.notes[pat_iter]:
|
618
|
|
- if self.active_patterns[_iter] == 1:
|
619
|
|
- break
|
620
|
|
- if p[0] == 1:
|
621
|
|
- #pat_used = 1
|
622
|
|
- self.active_patterns[_iter] = 1
|
623
|
|
- #print('found ', pat_iter, ' -- ', p[0])
|
624
|
|
- break
|
625
|
|
- #self.active_patterns.append(pat_used)
|
626
|
|
- pat_iter += 1
|
627
|
|
- _iter += 1
|
628
|
|
-
|
629
|
|
- #print('active patterns ', self.active_patterns)
|
630
|
|
-
|
631
|
|
- def Exit(self):
|
632
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
633
|
|
-
|
634
|
|
-#====================================
|
635
|
|
-
|
636
|
|
-class EditSoundSequence(State):
|
637
|
|
- def __init__(self,FSM):
|
638
|
|
- super(EditSoundSequence, self).__init__(FSM)
|
639
|
|
-
|
640
|
|
- def Enter(self):
|
641
|
|
- self.FSM.stateLife = 1
|
642
|
|
- o = self.FSM.owner
|
643
|
|
- o.header_text = "Note Edit"
|
644
|
|
- o.pub.register("beat", self)
|
645
|
|
- self.curPattern = o.ePattern
|
646
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
647
|
|
- pass
|
648
|
|
- else:
|
649
|
|
- u.draw_header(o)
|
650
|
|
- self.draw_square()
|
651
|
|
- u.text_box1(o, "Note Vol", str(o.note_vol))
|
652
|
|
- u.text_box3(o, "Pat", str(self.curPattern))
|
653
|
|
- o.update_display(0)
|
654
|
|
- super(EditSoundSequence, self).Enter()
|
655
|
|
-
|
656
|
|
- def Execute(self):
|
657
|
|
- o = self.FSM.owner
|
658
|
|
- m.menu1_actions(self, o)
|
659
|
|
- m.menu2_actions_note(self, o)
|
660
|
|
- if o.keyState[16] == 1:
|
661
|
|
- m.draw_menu1(o)
|
662
|
|
- o.update_display(0)
|
663
|
|
- elif o.keyState[16] == 4:
|
664
|
|
- u.draw_header(o)
|
665
|
|
- self.draw_square()
|
666
|
|
- u.text_box1(o, "Note Vol", str(o.note_vol))
|
667
|
|
- u.text_box3(o, "Pat", str(self.curPattern))
|
668
|
|
- o.update_display(0)
|
669
|
|
-
|
670
|
|
- if o.keyState[17] == 1:
|
671
|
|
- m.draw_menu2_note(o)
|
672
|
|
- o.update_display(0)
|
673
|
|
- elif o.keyState[17] == 4:
|
674
|
|
- u.draw_header(o)
|
675
|
|
- self.draw_square()
|
676
|
|
- u.text_box1(o, "Note Vol", str(o.note_vol))
|
677
|
|
- u.text_box3(o, "Pat", str(self.curPattern))
|
678
|
|
- o.update_display(0)
|
679
|
|
-
|
680
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
681
|
|
- pass
|
682
|
|
-
|
683
|
|
- else:
|
684
|
|
- _id = 0
|
685
|
|
- for k in self.FSM.owner.keyState:
|
686
|
|
- if _id < 16 and k == 1:
|
687
|
|
- if o.soundSlots[o.eSound].notes[self.curPattern][_id][0] == 1:
|
688
|
|
- #print('turn note off')
|
689
|
|
- o.soundSlots[o.eSound].notes[self.curPattern][_id][0] = 0
|
690
|
|
- o.soundSlots[o.eSound].notes[self.curPattern][_id][1] = 0
|
691
|
|
- else:
|
692
|
|
- #print('turn note on')
|
693
|
|
- o.soundSlots[o.eSound].notes[self.curPattern][_id][0] = 1
|
694
|
|
- o.soundSlots[o.eSound].notes[self.curPattern][_id][1] = o.note_vol
|
695
|
|
- u.draw_header(o)
|
696
|
|
- self.draw_square()
|
697
|
|
- u.text_box1(o, "Note Vol", str(o.note_vol))
|
698
|
|
- u.text_box3(o, "Pat", str(self.curPattern))
|
699
|
|
- o.update_display(0)
|
700
|
|
- _id += 1
|
701
|
|
-
|
702
|
|
-
|
703
|
|
-
|
704
|
|
- def draw_square(self):
|
705
|
|
- o = self.FSM.owner
|
706
|
|
- size = 22
|
707
|
|
- og_x = (o.width / 2) - (size * 2)
|
708
|
|
- o_x = og_x
|
709
|
|
- o_y = 127
|
710
|
|
- _id = 0
|
711
|
|
- for n in o.soundSlots[o.eSound].notes[self.curPattern]:
|
712
|
|
- if _id == o.playhead and o.playing:
|
713
|
|
- if o.curPattern == self.curPattern:
|
714
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.olive, width=1)
|
715
|
|
- else:
|
716
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.pink, width=1)
|
717
|
|
- elif n[0] == 1:
|
718
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
|
719
|
|
- else:
|
720
|
|
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
|
721
|
|
- o_x = o_x + size
|
722
|
|
- _id += 1
|
723
|
|
- if _id % 4 == 0:
|
724
|
|
- o_y -= size
|
725
|
|
- o_x = og_x
|
726
|
|
-
|
727
|
|
- def ReceiveMessage(self, message):
|
728
|
|
- _id = 0
|
729
|
|
- o = self.FSM.owner
|
730
|
|
- u.play_seq(o, message)
|
731
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
732
|
|
- pass
|
733
|
|
- else:
|
734
|
|
- u.draw_header(o)
|
735
|
|
- self.draw_square()
|
736
|
|
- u.text_box1(o, "Note Vol", str(o.note_vol))
|
737
|
|
- u.text_box3(o, "Pat", str(self.curPattern))
|
738
|
|
- if o.patternFollow:
|
739
|
|
- self.curPattern = message[0]
|
740
|
|
- else:
|
741
|
|
- self.curPattern = o.ePattern
|
742
|
|
- #print('message ', message)
|
743
|
|
- o.update_display(0)
|
744
|
|
-
|
745
|
|
- def Exit(self):
|
746
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
747
|
|
-
|
748
|
|
-
|
749
|
|
-class EditSong(State):
|
750
|
|
- def __init__(self,FSM):
|
751
|
|
- super(EditSong, self).__init__(FSM)
|
752
|
|
-
|
753
|
|
- def Enter(self):
|
754
|
|
- o = self.FSM.owner
|
755
|
|
- o.header_text = "Edit Song"
|
756
|
|
- o.pub.register("beat", self)
|
757
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
758
|
|
- pass
|
759
|
|
- else:
|
760
|
|
- u.draw_header(o)
|
761
|
|
- self.draw_main(o)
|
762
|
|
- # o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
|
763
|
|
- # o.draw.text((20, 50), str(o.song), font=o.h2, fill=o.light_grey)
|
764
|
|
- o.update_display(0)
|
765
|
|
- self.new_song = []
|
766
|
|
- super(EditSong, self).Enter()
|
767
|
|
-
|
768
|
|
- def Execute(self):
|
769
|
|
- o = self.FSM.owner
|
770
|
|
-
|
771
|
|
- m.menu1_actions(self, o)
|
772
|
|
- m.menu2_actions_song(self, o)
|
773
|
|
- if o.keyState[16] == 1:
|
774
|
|
- m.draw_menu1(o)
|
775
|
|
- o.update_display(0)
|
776
|
|
- elif o.keyState[16] == 4:
|
777
|
|
- u.draw_header(o)
|
778
|
|
- self.draw_main(o)
|
779
|
|
- # if self.new_song == []:
|
780
|
|
- # o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
|
781
|
|
- # o.draw.text((20, 50), str(o.song), font=o.h2, fill=o.light_grey)
|
782
|
|
- # else:
|
783
|
|
- # o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
|
784
|
|
- # o.draw.text((20, 50), str(self.new_song), font=o.h2, fill=o.pink)
|
785
|
|
- o.update_display(0)
|
786
|
|
-
|
787
|
|
- if o.keyState[17] == 1:
|
788
|
|
- m.draw_menu2_song(o)
|
789
|
|
- o.update_display(0)
|
790
|
|
- elif o.keyState[17] == 4:
|
791
|
|
- u.draw_header(o)
|
792
|
|
- self.draw_main(o)
|
793
|
|
- o.update_display(0)
|
794
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
795
|
|
-
|
796
|
|
- #if o.keyState[16] > 0:
|
797
|
|
- pass
|
798
|
|
- else:
|
799
|
|
- _id = 0
|
800
|
|
- for k in self.FSM.owner.keyState:
|
801
|
|
- if k == 1 and _id < 16:
|
802
|
|
- self.new_song.append((_id + (o.pat_bank * 16)))
|
803
|
|
- u.draw_header(o)
|
804
|
|
- self.draw_main(o)
|
805
|
|
- #o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
|
806
|
|
- #o.draw.text((20, 50), str(self.new_song), font=o.h2, fill=o.pink)
|
807
|
|
- o.update_display(0)
|
808
|
|
- _id += 1
|
809
|
|
-
|
810
|
|
-
|
811
|
|
- def draw_main(self, o):
|
812
|
|
- ypos = 35
|
813
|
|
- ysize = 20
|
814
|
|
- tmp_song = [8, 6, 7, 5, 3, 0, 9]
|
815
|
|
- lines = u.breakup_song_text(o.song)
|
816
|
|
- #lines = u.breakup_song_text(tmp_song)
|
817
|
|
-
|
818
|
|
- if self.new_song != []:
|
819
|
|
- #o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
|
820
|
|
- lines = u.breakup_song_text(self.new_song)
|
821
|
|
- o.center_block("New Song", o.h2, [0, ypos, o.width, ypos + ysize], o.pink)
|
822
|
|
- else:
|
823
|
|
- #o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
|
824
|
|
- o.center_block("Current Song", o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
|
825
|
|
-
|
826
|
|
- ypos += ysize
|
827
|
|
- o.center_block(lines[0], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
|
828
|
|
- ypos += ysize
|
829
|
|
- o.center_block(lines[1], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
|
830
|
|
- ypos += ysize
|
831
|
|
- o.center_block(lines[2], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
|
832
|
|
- ypos += ysize
|
833
|
|
- o.center_block(lines[3], o.h2, [0, ypos, o.width, ypos + ysize], o.light_grey)
|
834
|
|
-
|
835
|
|
- def ReceiveMessage(self, message):
|
836
|
|
- _id = 0
|
837
|
|
- o = self.FSM.owner
|
838
|
|
- u.play_seq(o, message)
|
839
|
|
-
|
840
|
|
- def Exit(self):
|
841
|
|
- o = self.FSM.owner
|
842
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
843
|
|
- if self.new_song != []:
|
844
|
|
- o.song = self.new_song
|
845
|
|
- o.songCycle = cycle(self.new_song)
|
846
|
|
- self.curPattern = next(o.songCycle)
|
847
|
|
- o.songStart = o.curPattern
|
848
|
|
-
|
849
|
|
-#====================================
|
850
|
|
-
|
851
|
|
-class File(State):
|
852
|
|
- def __init__(self,FSM):
|
853
|
|
- super(File, self).__init__(FSM)
|
854
|
|
-
|
855
|
|
- def Enter(self):
|
856
|
|
- self.FSM.stateLife = 1
|
857
|
|
- o = self.FSM.owner
|
858
|
|
- o.header_text = "File"
|
859
|
|
- o.pub.register("beat", self)
|
860
|
|
- self.cur_el = 0
|
861
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
862
|
|
- pass
|
863
|
|
- else:
|
864
|
|
- u.draw_header(o)
|
865
|
|
- self.draw_footer(o)
|
866
|
|
- self.draw_main(o)
|
867
|
|
- o.update_display(0)
|
868
|
|
- self.menu = ["Save", "Save As", "Open", "New"]
|
869
|
|
-
|
870
|
|
- super(File, self).Enter()
|
871
|
|
-
|
872
|
|
- def Execute(self):
|
873
|
|
- o = self.FSM.owner
|
874
|
|
- m.menu1_actions(self, o)
|
875
|
|
- if o.keyState[16] == 1:
|
876
|
|
- m.draw_menu1(o)
|
877
|
|
- #self.draw_footer(o)
|
878
|
|
- o.update_display(0)
|
879
|
|
- elif o.keyState[16] == 4:
|
880
|
|
- u.draw_header(o)
|
881
|
|
- self.draw_footer(o)
|
882
|
|
- self.draw_main(o)
|
883
|
|
- o.update_display(0)
|
884
|
|
-
|
885
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
886
|
|
- u.draw_header(o)
|
887
|
|
- self.draw_footer(o)
|
888
|
|
- self.draw_main(o)
|
889
|
|
- o.update_display(0)
|
890
|
|
- print('draw butt')
|
891
|
|
-
|
892
|
|
-
|
893
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
894
|
|
- pass
|
895
|
|
- else:
|
896
|
|
- if o.keyState[0] == 1:
|
897
|
|
- if self.cur_el > 0:
|
898
|
|
- self.cur_el -= 1
|
899
|
|
- print('cur el down is ', self.cur_el)
|
900
|
|
- if o.keyState[1] == 1:
|
901
|
|
- if self.cur_el < (len(self.menu) - 1):
|
902
|
|
- self.cur_el += 1
|
903
|
|
- print('cur el up is ', self.cur_el)
|
904
|
|
-
|
905
|
|
- if o.keyState[3] == 1:
|
906
|
|
- m.file_command(self, o, self.menu[self.cur_el])
|
907
|
|
- pass
|
908
|
|
-
|
909
|
|
- def draw_footer(self, o):
|
910
|
|
- _iter = 0
|
911
|
|
- width = o.width / 4
|
912
|
|
- xpos = 0
|
913
|
|
- yposa = 135 - 25
|
914
|
|
- yposb = 135
|
915
|
|
- opts = ["Up", "Down", "Esc", "OK"]
|
916
|
|
- while _iter < 4:
|
917
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
|
918
|
|
-
|
919
|
|
- if o.keyState[_iter] == 1:
|
920
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
|
921
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
|
922
|
|
- else:
|
923
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
|
924
|
|
-
|
925
|
|
- xpos += width
|
926
|
|
- _iter += 1
|
927
|
|
-
|
928
|
|
-
|
929
|
|
- def draw_main(self, o):
|
930
|
|
- al = []
|
931
|
|
- ypos = 30
|
932
|
|
- if self.cur_el == 0:
|
933
|
|
- _iter = 0
|
934
|
|
- while len(al) < 4:
|
935
|
|
- al.append(self.menu[_iter])
|
936
|
|
- _iter += 1
|
937
|
|
- elif self.cur_el == 1:
|
938
|
|
- al.append(self.menu[self.cur_el - 1])
|
939
|
|
- al.append(self.menu[self.cur_el])
|
940
|
|
- al.append(self.menu[self.cur_el + 1])
|
941
|
|
- al.append(self.menu[self.cur_el + 2])
|
942
|
|
- elif self.cur_el == (len(self.menu) - 2):
|
943
|
|
- al.append(self.menu[self.cur_el - 2])
|
944
|
|
- al.append(self.menu[self.cur_el - 1])
|
945
|
|
- al.append(self.menu[self.cur_el])
|
946
|
|
- al.append(self.menu[self.cur_el + 1])
|
947
|
|
- elif self.cur_el == (len(self.menu) - 1):
|
948
|
|
- al.append(self.menu[self.cur_el - 3])
|
949
|
|
- al.append(self.menu[self.cur_el - 2])
|
950
|
|
- al.append(self.menu[self.cur_el - 1])
|
951
|
|
- al.append(self.menu[self.cur_el])
|
952
|
|
- else:
|
953
|
|
- al.append(self.menu[self.cur_el - 1])
|
954
|
|
- al.append(self.menu[self.cur_el])
|
955
|
|
- al.append(self.menu[self.cur_el + 1])
|
956
|
|
- al.append(self.menu[self.cur_el + 2])
|
957
|
|
- _iter = 0
|
958
|
|
- for i in al:
|
959
|
|
- if i == self.menu[self.cur_el]:
|
960
|
|
- #if _iter == self.cur_el:
|
961
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
|
962
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
|
963
|
|
- else:
|
964
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
|
965
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
|
966
|
|
- ypos += 20
|
967
|
|
- _iter += 1
|
968
|
|
-
|
969
|
|
- def ReceiveMessage(self, message):
|
970
|
|
- o = self.FSM.owner
|
971
|
|
- u.play_seq(o, message)
|
972
|
|
-
|
973
|
|
- def Exit(self):
|
974
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
975
|
|
-
|
976
|
|
-class Util(State):
|
977
|
|
- def __init__(self,FSM):
|
978
|
|
- super(Util, self).__init__(FSM)
|
979
|
|
-
|
980
|
|
- def Enter(self):
|
981
|
|
- o = self.FSM.owner
|
982
|
|
- o.header_text = "Utilities"
|
983
|
|
- o.pub.register("beat", self)
|
984
|
|
- self.menu = ["Clock", "Balls", "Defender", "Calculator", "Exit", "Shutdown", "Reboot", "Theme", "Ping", "Wifi", "Update", "About"]
|
985
|
|
- self.cur_el = 0
|
986
|
|
-
|
987
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
988
|
|
- pass
|
989
|
|
- else:
|
990
|
|
- u.draw_header(o)
|
991
|
|
- self.draw_footer(o)
|
992
|
|
- self.draw_main(o)
|
993
|
|
- o.update_display(0)
|
994
|
|
-
|
995
|
|
-
|
996
|
|
- super(Util, self).Enter()
|
997
|
|
-
|
998
|
|
- def Execute(self):
|
999
|
|
- o = self.FSM.owner
|
1000
|
|
- m.menu1_actions(self, o)
|
1001
|
|
- if o.keyState[16] == 1:
|
1002
|
|
- m.draw_menu1(o)
|
1003
|
|
- o.update_display(0)
|
1004
|
|
- elif o.keyState[16] == 4:
|
1005
|
|
- u.draw_header(o)
|
1006
|
|
- self.draw_footer(o)
|
1007
|
|
- self.draw_main(o)
|
1008
|
|
- o.update_display(0)
|
1009
|
|
-
|
1010
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
1011
|
|
- u.draw_header(o)
|
1012
|
|
- self.draw_footer(o)
|
1013
|
|
- self.draw_main(o)
|
1014
|
|
- o.update_display(0)
|
1015
|
|
- print('draw butt')
|
1016
|
|
-
|
1017
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1018
|
|
- pass
|
1019
|
|
- else:
|
1020
|
|
- if o.keyState[0] == 1:
|
1021
|
|
- if self.cur_el > 0:
|
1022
|
|
- self.cur_el -= 1
|
1023
|
|
- print('cur el down is ', self.cur_el)
|
1024
|
|
- if o.keyState[1] == 1:
|
1025
|
|
- if self.cur_el < (len(self.menu) - 1):
|
1026
|
|
- self.cur_el += 1
|
1027
|
|
- print('cur el up is ', self.cur_el)
|
1028
|
|
-
|
1029
|
|
- if o.keyState[3] == 1:
|
1030
|
|
- m.util_command(self, o, self.menu[self.cur_el])
|
1031
|
|
-
|
1032
|
|
- def ReceiveMessage(self, message):
|
1033
|
|
- _id = 0
|
1034
|
|
- o = self.FSM.owner
|
1035
|
|
- u.play_seq(o, message)
|
1036
|
|
- # if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1037
|
|
- # pass
|
1038
|
|
- # else:
|
1039
|
|
- # u.draw_header(o)
|
1040
|
|
- # o.update_display(0)
|
1041
|
|
-
|
1042
|
|
- def draw_main(self, o):
|
1043
|
|
- al = []
|
1044
|
|
- ypos = 30
|
1045
|
|
- if self.cur_el == 0:
|
1046
|
|
- _iter = 0
|
1047
|
|
- while len(al) < 4:
|
1048
|
|
- al.append(self.menu[_iter])
|
1049
|
|
- _iter += 1
|
1050
|
|
- elif self.cur_el == 1:
|
1051
|
|
- al.append(self.menu[self.cur_el - 1])
|
1052
|
|
- al.append(self.menu[self.cur_el])
|
1053
|
|
- al.append(self.menu[self.cur_el + 1])
|
1054
|
|
- al.append(self.menu[self.cur_el + 2])
|
1055
|
|
- elif self.cur_el == (len(self.menu) - 2):
|
1056
|
|
- al.append(self.menu[self.cur_el - 2])
|
1057
|
|
- al.append(self.menu[self.cur_el - 1])
|
1058
|
|
- al.append(self.menu[self.cur_el])
|
1059
|
|
- al.append(self.menu[self.cur_el + 1])
|
1060
|
|
- elif self.cur_el == (len(self.menu) - 1):
|
1061
|
|
- al.append(self.menu[self.cur_el - 3])
|
1062
|
|
- al.append(self.menu[self.cur_el - 2])
|
1063
|
|
- al.append(self.menu[self.cur_el - 1])
|
1064
|
|
- al.append(self.menu[self.cur_el])
|
1065
|
|
- else:
|
1066
|
|
- al.append(self.menu[self.cur_el - 1])
|
1067
|
|
- al.append(self.menu[self.cur_el])
|
1068
|
|
- al.append(self.menu[self.cur_el + 1])
|
1069
|
|
- al.append(self.menu[self.cur_el + 2])
|
1070
|
|
- _iter = 0
|
1071
|
|
- for i in al:
|
1072
|
|
- if i == self.menu[self.cur_el]:
|
1073
|
|
- #if _iter == self.cur_el:
|
1074
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
|
1075
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
|
1076
|
|
- else:
|
1077
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
|
1078
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
|
1079
|
|
- ypos += 20
|
1080
|
|
- _iter += 1
|
1081
|
|
-
|
1082
|
|
- def draw_footer(self, o):
|
1083
|
|
- _iter = 0
|
1084
|
|
- width = o.width / 4
|
1085
|
|
- xpos = 0
|
1086
|
|
- yposa = 135 - 25
|
1087
|
|
- yposb = 135
|
1088
|
|
- opts = ["Up", "Down", "Esc", "OK"]
|
1089
|
|
- while _iter < 4:
|
1090
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
|
1091
|
|
-
|
1092
|
|
- if o.keyState[_iter] == 1:
|
1093
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
|
1094
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
|
1095
|
|
- else:
|
1096
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
|
1097
|
|
-
|
1098
|
|
- xpos += width
|
1099
|
|
- _iter += 1
|
1100
|
|
-
|
1101
|
|
- def Exit(self):
|
1102
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
1103
|
|
-
|
1104
|
|
-
|
1105
|
|
-
|
1106
|
|
-class Ball(State):
|
1107
|
|
- def __init__(self,FSM):
|
1108
|
|
- super(Ball, self).__init__(FSM)
|
1109
|
|
-
|
1110
|
|
- def Enter(self):
|
1111
|
|
- self.ball_size = 10
|
1112
|
|
- self.ballx = self.ball_size
|
1113
|
|
- self.bally = self.ball_size
|
1114
|
|
-
|
1115
|
|
- self.ball_speed = 8
|
1116
|
|
- self.ball_x_dir = 1
|
1117
|
|
- self.ball_y_dir = 1
|
1118
|
|
-
|
1119
|
|
- self.ball2x = self.ball_size + 180
|
1120
|
|
- self.ball2y = self.ball_size + 70
|
1121
|
|
-
|
1122
|
|
- self.ball2_x_dir = -1
|
1123
|
|
- self.ball2_y_dir = -1
|
1124
|
|
-
|
1125
|
|
- self.xmult = 1.0
|
1126
|
|
-
|
1127
|
|
- o = self.FSM.owner
|
1128
|
|
- o.header_text = "Balls"
|
1129
|
|
- o.pub.register("beat", self)
|
1130
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1131
|
|
- pass
|
1132
|
|
- else:
|
1133
|
|
- u.draw_header(o)
|
1134
|
|
- o.update_display(0)
|
1135
|
|
- super(Ball, self).Enter()
|
1136
|
|
-
|
1137
|
|
- def Execute(self):
|
1138
|
|
- o = self.FSM.owner
|
1139
|
|
- m.menu1_actions(self, o)
|
1140
|
|
- if o.keyState[16] == 1:
|
1141
|
|
- m.draw_menu1(o)
|
1142
|
|
- o.update_display(0)
|
1143
|
|
-
|
1144
|
|
-
|
1145
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1146
|
|
- pass
|
1147
|
|
- else:
|
1148
|
|
- now = datetime.now()
|
1149
|
|
- current_time = time.strftime("%-I:%M %p")
|
1150
|
|
-
|
1151
|
|
-
|
1152
|
|
- if self.ballx < (0 + self.ball_size):
|
1153
|
|
- self.ball_x_dir = 1
|
1154
|
|
- if self.ballx > (o.width - self.ball_size):
|
1155
|
|
- self.ball_x_dir = -1
|
1156
|
|
-
|
1157
|
|
- if self.bally < (0 + self.ball_size):
|
1158
|
|
- self.ball_y_dir = 1
|
1159
|
|
- if self.bally > (o.height - self.ball_size):
|
1160
|
|
- self.ball_y_dir = -1
|
1161
|
|
-
|
1162
|
|
- # if self.ballx > (o.width - self.ball_size) or self.ballx < (0 + self.ball_size):
|
1163
|
|
- # self.ball_x_dir *= -1
|
1164
|
|
- # if self.bally > (o.height - self.ball_size) or self.bally < (0 + self.ball_size):
|
1165
|
|
- # self.ball_y_dir *= -1
|
1166
|
|
-
|
1167
|
|
- self.ballx += self.ball_speed * self.ball_x_dir
|
1168
|
|
- self.bally += self.ball_speed * self.ball_y_dir
|
1169
|
|
-
|
1170
|
|
-
|
1171
|
|
- if self.ball2x < (0 + self.ball_size):
|
1172
|
|
- self.ball2_x_dir = 1
|
1173
|
|
- self.xmult = random.uniform(.6, 1.2)
|
1174
|
|
- if self.ball2x > (o.width - self.ball_size):
|
1175
|
|
- self.ball2_x_dir = -1
|
1176
|
|
- self.xmult = random.uniform(.6, 1.2)
|
1177
|
|
-
|
1178
|
|
- if self.ball2y < (0 + self.ball_size):
|
1179
|
|
- self.ball2_y_dir = 1
|
1180
|
|
- if self.ball2y > (o.height - self.ball_size):
|
1181
|
|
- self.ball2_y_dir = -1
|
1182
|
|
-
|
1183
|
|
-
|
1184
|
|
- # if self.ball2x > (o.width - self.ball_size) or self.ball2x < (0 + self.ball_size):
|
1185
|
|
- # self.ball2_x_dir *= -1
|
1186
|
|
- # self.xmult = random.uniform(.8, 1.2)
|
1187
|
|
- # if self.ball2y > (o.height - self.ball_size) or self.ball2y < (0 + self.ball_size):
|
1188
|
|
- # self.ball2_y_dir *= -1
|
1189
|
|
-
|
1190
|
|
- self.ball2x += (self.ball_speed * self.ball2_x_dir) * self.xmult
|
1191
|
|
- self.ball2y += (self.ball_speed * self.ball2_y_dir)
|
1192
|
|
-
|
1193
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
1194
|
|
-
|
1195
|
|
- o.draw.ellipse((self.ballx - self.ball_size, self.bally - self.ball_size, self.ballx + self.ball_size, self.bally + self.ball_size), fill = o.light_grey, outline =o.light_grey)
|
1196
|
|
- o.draw.ellipse((self.ball2x - self.ball_size, self.ball2y - self.ball_size, self.ball2x + self.ball_size, self.ball2y + self.ball_size), fill = o.light_grey, outline =o.light_grey)
|
1197
|
|
- #o.center_block(current_time, o.h3, [0,0,o.width,o.height], o.pink)
|
1198
|
|
- o.update_display(0)
|
1199
|
|
-
|
1200
|
|
- def ReceiveMessage(self, message):
|
1201
|
|
- o = self.FSM.owner
|
1202
|
|
- u.play_seq(o, message)
|
1203
|
|
-
|
1204
|
|
- def Exit(self):
|
1205
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
1206
|
|
-
|
1207
|
|
-#====================================
|
1208
|
|
-
|
1209
|
|
-
|
1210
|
|
-class Clock(State):
|
1211
|
|
- def __init__(self,FSM):
|
1212
|
|
- super(Clock, self).__init__(FSM)
|
1213
|
|
-
|
1214
|
|
- def Enter(self):
|
1215
|
|
- o = self.FSM.owner
|
1216
|
|
- current_time = time.strftime("%-I:%M:%S")
|
1217
|
|
- self.ball_sizex, self.ball_sizey = o.h3.getsize("18:88:88")
|
1218
|
|
- self.ball_sizex /= 2
|
1219
|
|
- self.ball_sizey /= 2
|
1220
|
|
- #self.ball_sizey += 10
|
1221
|
|
- self.ballx = o.width / 2
|
1222
|
|
- self.bally = o.height / 2
|
1223
|
|
- self.ball_speed = .5
|
1224
|
|
- self.ball_x_dir = 1
|
1225
|
|
- self.ball_y_dir = 1
|
1226
|
|
-
|
1227
|
|
- o.header_text = "Clock"
|
1228
|
|
- o.pub.register("beat", self)
|
1229
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1230
|
|
- pass
|
1231
|
|
- else:
|
1232
|
|
- pass
|
1233
|
|
- super(Clock, self).Enter()
|
1234
|
|
-
|
1235
|
|
- def Execute(self):
|
1236
|
|
- o = self.FSM.owner
|
1237
|
|
- m.menu1_actions(self, o)
|
1238
|
|
-
|
1239
|
|
- if o.keyState[16] == 1:
|
1240
|
|
- m.draw_menu1(o)
|
1241
|
|
- o.update_display(0)
|
1242
|
|
-
|
1243
|
|
-
|
1244
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1245
|
|
- pass
|
1246
|
|
- else:
|
1247
|
|
- current_time = time.strftime("%-I:%M:%S")
|
1248
|
|
- s = int(time.strftime("%S"))
|
1249
|
|
- if s % 2 == 0:
|
1250
|
|
- current_time = time.strftime("%-I:%M.%S")
|
1251
|
|
-
|
1252
|
|
- if self.ballx > (o.width - self.ball_sizex) or self.ballx < (0 + self.ball_sizex):
|
1253
|
|
- self.ball_x_dir *= -1
|
1254
|
|
- if (self.bally > o.height - self.ball_sizey - 20) or (self.bally < 0 + self.ball_sizey):
|
1255
|
|
- self.ball_y_dir *= -1
|
1256
|
|
-
|
1257
|
|
- x1 = self.ballx - self.ball_sizex
|
1258
|
|
- x2 = self.ballx + self.ball_sizex
|
1259
|
|
- y1 = self.bally - self.ball_sizey
|
1260
|
|
- y2 = self.bally + self.ball_sizey
|
1261
|
|
- self.ballx += self.ball_speed * self.ball_x_dir
|
1262
|
|
- self.bally += self.ball_speed * self.ball_y_dir
|
1263
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
1264
|
|
- #o.draw.rectangle((x1, y1, x2, y2), outline=0, fill=o.dark_grey)
|
1265
|
|
-
|
1266
|
|
- #o.draw.text((self.ballx - self.ball_sizex, self.bally - self.ball_sizey), current_time, align='center', font=o.h3, fill=o.light_grey)
|
1267
|
|
- o.center_block(current_time, o.h3, [x1, y1, x2, y2], o.light_grey)
|
1268
|
|
- today = date.today()
|
1269
|
|
- current_date = today.strftime('%A')
|
1270
|
|
- current_date += ', ' + today.strftime("%b %d, %Y")
|
1271
|
|
- #o.draw.text((self.ballx - self.ball_sizex, (self.bally + 45) - self.ball_sizey), current_date, align='center', font=o.h2, fill=o.light_grey)
|
1272
|
|
- o.center_block(current_date, o.h2, [x1, y1 + 35, x2, y2 + 35], o.light_grey)
|
1273
|
|
- o.update_display(0)
|
1274
|
|
-
|
1275
|
|
- def ReceiveMessage(self, message):
|
1276
|
|
- o = self.FSM.owner
|
1277
|
|
- u.play_seq(o, message)
|
1278
|
|
-
|
1279
|
|
- def Exit(self):
|
1280
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
1281
|
|
-
|
1282
|
|
-#====================================
|
1283
|
|
-
|
1284
|
|
-class Exit(State):
|
1285
|
|
- def __init__(self,FSM):
|
1286
|
|
- super(Exit, self).__init__(FSM)
|
1287
|
|
-
|
1288
|
|
- def Enter(self):
|
1289
|
|
- o = self.FSM.owner
|
1290
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
1291
|
|
- o.center_block("goodbye", o.h2, [0, 0, o.width,o.height], o.light_grey)
|
1292
|
|
- o.update_display(0)
|
1293
|
|
- pygame.quit()
|
1294
|
|
- sys.exit()
|
1295
|
|
- super(Exit, self).Enter()
|
1296
|
|
-
|
1297
|
|
- def Execute(self):
|
1298
|
|
- self.FSM.stateLife += 1
|
1299
|
|
-
|
1300
|
|
- def Exit(self):
|
1301
|
|
- pass
|
1302
|
|
-
|
1303
|
|
-#====================================
|
1304
|
|
-
|
1305
|
|
-#====================================
|
1306
|
|
-
|
1307
|
|
-class Reboot(State):
|
1308
|
|
- def __init__(self,FSM):
|
1309
|
|
- super(Reboot, self).__init__(FSM)
|
1310
|
|
-
|
1311
|
|
- def Enter(self):
|
1312
|
|
- o = self.FSM.owner
|
1313
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
1314
|
|
- o.center_block("rebooting", o.h2, [0, 0, o.width,o.height], o.light_grey)
|
1315
|
|
- o.update_display(0)
|
1316
|
|
- command = 'bash -c "sleep 5; sudo shutdown -r now"&'
|
1317
|
|
- os.system(command)
|
1318
|
|
- pygame.quit()
|
1319
|
|
- sys.exit()
|
1320
|
|
- super(Reboot, self).Enter()
|
1321
|
|
-
|
1322
|
|
- def Execute(self):
|
1323
|
|
- pass
|
1324
|
|
- #self.FSM.stateLife += 1
|
1325
|
|
- #os.system('sudo shutdown -r now')
|
1326
|
|
-
|
1327
|
|
- def Exit(self):
|
1328
|
|
- pass
|
1329
|
|
-
|
1330
|
|
-#====================================
|
1331
|
|
-
|
1332
|
|
-
|
1333
|
|
-#====================================
|
1334
|
|
-
|
1335
|
|
-class Shutdown(State):
|
1336
|
|
- def __init__(self,FSM):
|
1337
|
|
- super(Shutdown, self).__init__(FSM)
|
1338
|
|
-
|
1339
|
|
- def Enter(self):
|
1340
|
|
- o = self.FSM.owner
|
1341
|
|
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
1342
|
|
- o.center_block("shutting down", o.h2, [0, 0, o.width,o.height - 20], o.light_grey)
|
1343
|
|
- o.center_block("(unplug in 20s)", o.h2, [0, 10, o.width,o.height+10], o.light_grey)
|
1344
|
|
- o.center_block("thank you for playing", o.h2, [0, 30, o.width,o.height+30], o.light_grey)
|
1345
|
|
- o.update_display(0)
|
1346
|
|
- command = 'bash -c "sleep 5; sudo shutdown -h now"&'
|
1347
|
|
- os.system(command)
|
1348
|
|
- pygame.quit()
|
1349
|
|
- sys.exit()
|
1350
|
|
- super(Shutdown, self).Enter()
|
1351
|
|
-
|
1352
|
|
- def Execute(self):
|
1353
|
|
- pass
|
1354
|
|
- #self.FSM.stateLife += 1
|
1355
|
|
- #os.system('sudo shutdown -r now')
|
1356
|
|
-
|
1357
|
|
- def Exit(self):
|
1358
|
|
- pass
|
1359
|
|
-
|
1360
|
|
-#====================================
|
1361
|
|
-class SelTheme(State):
|
1362
|
|
- def __init__(self,FSM):
|
1363
|
|
- super(SelTheme, self).__init__(FSM)
|
1364
|
|
-
|
1365
|
|
- def Enter(self):
|
1366
|
|
- o = self.FSM.owner
|
1367
|
|
- o.header_text = "Select Theme"
|
1368
|
|
- o.pub.register("beat", self)
|
1369
|
|
- self.cur_el = 0
|
1370
|
|
- self.globbed = glob.glob('/home/pi/zpc_ct/user/themes/*.thm')
|
1371
|
|
- self.globbed.sort()
|
1372
|
|
- self.names = [os.path.basename(x) for x in self.globbed]
|
1373
|
|
- self.names = [os.path.splitext(x)[0] for x in self.names]
|
1374
|
|
- if o.mconf['theme'] in self.names:
|
1375
|
|
- _id = self.names.index(o.mconf['theme'])
|
1376
|
|
- self.cur_el = _id
|
1377
|
|
- #print('found theme ', _id)
|
1378
|
|
- else:
|
1379
|
|
- print('nope ', o.mconf['theme'], ' - ', self.globbed)
|
1380
|
|
- #self.theme = ConfigObj("/home/pi/zpc_ct/themes/" + self.mconf['theme'])
|
1381
|
|
- #print(os.path.splitext(x)[0])
|
1382
|
|
- self.menu = self.names
|
1383
|
|
-
|
1384
|
|
- #self.cur_el = 0
|
1385
|
|
- print('theme menu is ', self.menu)
|
1386
|
|
-
|
1387
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1388
|
|
- pass
|
1389
|
|
- else:
|
1390
|
|
- u.draw_header(o)
|
1391
|
|
- self.draw_main(o)
|
1392
|
|
-
|
1393
|
|
- o.update_display(0)
|
1394
|
|
- super(SelTheme, self).Enter()
|
1395
|
|
-
|
1396
|
|
- def Execute(self):
|
1397
|
|
- o = self.FSM.owner
|
1398
|
|
- m.menu1_actions(self, o)
|
1399
|
|
- if o.keyState[16] == 1:
|
1400
|
|
- m.draw_menu1(o)
|
1401
|
|
- o.update_display(0)
|
1402
|
|
- elif o.keyState[16] == 4:
|
1403
|
|
- u.draw_header(o)
|
1404
|
|
- self.draw_footer(o)
|
1405
|
|
- self.draw_main(o)
|
1406
|
|
- o.update_display(0)
|
1407
|
|
-
|
1408
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
1409
|
|
- u.draw_header(o)
|
1410
|
|
- self.draw_footer(o)
|
1411
|
|
- self.draw_main(o)
|
1412
|
|
- o.update_display(0)
|
1413
|
|
- print('draw butt')
|
1414
|
|
-
|
1415
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1416
|
|
- pass
|
1417
|
|
- else:
|
1418
|
|
- if o.keyState[0] == 1:
|
1419
|
|
- if self.cur_el > 0:
|
1420
|
|
- self.cur_el -= 1
|
1421
|
|
- o.mconf['theme'] = self.menu[self.cur_el]
|
1422
|
|
- o.save_config()
|
1423
|
|
- o.load_config()
|
1424
|
|
- o.apply_theme()
|
1425
|
|
- print('cur el down is ', self.cur_el)
|
1426
|
|
-
|
1427
|
|
- #o.applyTheme
|
1428
|
|
- if o.keyState[1] == 1:
|
1429
|
|
- if self.cur_el < (len(self.menu) - 1):
|
1430
|
|
- self.cur_el += 1
|
1431
|
|
- o.mconf['theme'] = self.menu[self.cur_el]
|
1432
|
|
- o.save_config()
|
1433
|
|
- o.load_config()
|
1434
|
|
- o.apply_theme()
|
1435
|
|
- print('cur el up is ', self.cur_el)
|
1436
|
|
- print('loading theme ', self.menu[self.cur_el], '-- ', o.mconf['theme'])
|
1437
|
|
- if o.keyState[3] == 1:
|
1438
|
|
- m.util_command(self, o, self.menu[self.cur_el])
|
1439
|
|
-
|
1440
|
|
- def draw_main(self, o):
|
1441
|
|
- al = []
|
1442
|
|
- ypos = 30
|
1443
|
|
- if self.cur_el == 0:
|
1444
|
|
- _iter = 0
|
1445
|
|
- while len(al) < 4:
|
1446
|
|
- al.append(self.menu[_iter])
|
1447
|
|
- _iter += 1
|
1448
|
|
- elif self.cur_el == 1:
|
1449
|
|
- al.append(self.menu[self.cur_el - 1])
|
1450
|
|
- al.append(self.menu[self.cur_el])
|
1451
|
|
- al.append(self.menu[self.cur_el + 1])
|
1452
|
|
- al.append(self.menu[self.cur_el + 2])
|
1453
|
|
- elif self.cur_el == (len(self.menu) - 2):
|
1454
|
|
- al.append(self.menu[self.cur_el - 2])
|
1455
|
|
- al.append(self.menu[self.cur_el - 1])
|
1456
|
|
- al.append(self.menu[self.cur_el])
|
1457
|
|
- al.append(self.menu[self.cur_el + 1])
|
1458
|
|
- elif self.cur_el == (len(self.menu) - 1):
|
1459
|
|
- al.append(self.menu[self.cur_el - 3])
|
1460
|
|
- al.append(self.menu[self.cur_el - 2])
|
1461
|
|
- al.append(self.menu[self.cur_el - 1])
|
1462
|
|
- al.append(self.menu[self.cur_el])
|
1463
|
|
- else:
|
1464
|
|
- al.append(self.menu[self.cur_el - 1])
|
1465
|
|
- al.append(self.menu[self.cur_el])
|
1466
|
|
- al.append(self.menu[self.cur_el + 1])
|
1467
|
|
- al.append(self.menu[self.cur_el + 2])
|
1468
|
|
- _iter = 0
|
1469
|
|
- for i in al:
|
1470
|
|
- if i == self.menu[self.cur_el]:
|
1471
|
|
- #if _iter == self.cur_el:
|
1472
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
|
1473
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
|
1474
|
|
- else:
|
1475
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
|
1476
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
|
1477
|
|
- ypos += 20
|
1478
|
|
- _iter += 1
|
1479
|
|
-
|
1480
|
|
- def draw_footer(self, o):
|
1481
|
|
- _iter = 0
|
1482
|
|
- width = o.width / 4
|
1483
|
|
- xpos = 0
|
1484
|
|
- yposa = 135 - 25
|
1485
|
|
- yposb = 135
|
1486
|
|
- opts = ["Up", "Down", "", ""]
|
1487
|
|
- while _iter < 4:
|
1488
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
|
1489
|
|
-
|
1490
|
|
- if o.keyState[_iter] == 1:
|
1491
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
|
1492
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
|
1493
|
|
- else:
|
1494
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
|
1495
|
|
-
|
1496
|
|
- xpos += width
|
1497
|
|
- _iter += 1
|
1498
|
|
-
|
1499
|
|
-
|
1500
|
|
- def ReceiveMessage(self, message):
|
1501
|
|
- o = self.FSM.owner
|
1502
|
|
- u.play_seq(o, message)
|
1503
|
|
-
|
1504
|
|
- def Exit(self):
|
1505
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
1506
|
|
-
|
1507
|
|
-#====================================
|
1508
|
|
-
|
1509
|
|
-class OpenSong(State):
|
1510
|
|
- def __init__(self,FSM):
|
1511
|
|
- super(OpenSong, self).__init__(FSM)
|
1512
|
|
-
|
1513
|
|
- def Enter(self):
|
1514
|
|
- o = self.FSM.owner
|
1515
|
|
- o.header_text = "Open Song"
|
1516
|
|
- o.pub.register("beat", self)
|
1517
|
|
- self.cur_el = 0
|
1518
|
|
- self.globbed = glob.glob('/home/pi/zpc_ct/user/songs/*.sng')
|
1519
|
|
- self.globbed.sort()
|
1520
|
|
- if '/home/pi/zpc_ct/user/songs/_blank.sng' in self.globbed:
|
1521
|
|
- self.globbed.remove('/home/pi/zpc_ct/user/songs/_blank.sng')
|
1522
|
|
- #del self.globbed[0]
|
1523
|
|
- self.names = [os.path.basename(x) for x in self.globbed]
|
1524
|
|
- self.names = [os.path.splitext(x)[0] for x in self.names]
|
1525
|
|
- print('we got these songs ', self.names)
|
1526
|
|
- print('in these paths ', self.globbed)
|
1527
|
|
- if o.mconf['default_song'] in self.names:
|
1528
|
|
- _id = self.names.index(o.mconf['default_song'])
|
1529
|
|
- self.cur_el = _id
|
1530
|
|
- else:
|
1531
|
|
- print('nope ', o.mconf['default_song'], ' - ', self.globbed)
|
1532
|
|
- self.menu = self.names
|
1533
|
|
-
|
1534
|
|
- #self.cur_el = 0
|
1535
|
|
- #print('theme menu is ', self.menu)
|
1536
|
|
-
|
1537
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1538
|
|
- pass
|
1539
|
|
- else:
|
1540
|
|
- u.draw_header(o)
|
1541
|
|
- self.draw_main(o)
|
1542
|
|
-
|
1543
|
|
- o.update_display(0)
|
1544
|
|
- super(OpenSong, self).Enter()
|
1545
|
|
-
|
1546
|
|
- def Execute(self):
|
1547
|
|
- o = self.FSM.owner
|
1548
|
|
- m.menu1_actions(self, o)
|
1549
|
|
- if o.keyState[16] == 1:
|
1550
|
|
- m.draw_menu1(o)
|
1551
|
|
- o.update_display(0)
|
1552
|
|
- elif o.keyState[16] == 4:
|
1553
|
|
- u.draw_header(o)
|
1554
|
|
- self.draw_footer(o)
|
1555
|
|
- self.draw_main(o)
|
1556
|
|
- o.update_display(0)
|
1557
|
|
-
|
1558
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
1559
|
|
- u.draw_header(o)
|
1560
|
|
- self.draw_footer(o)
|
1561
|
|
- self.draw_main(o)
|
1562
|
|
- o.update_display(0)
|
1563
|
|
-
|
1564
|
|
-
|
1565
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1566
|
|
- pass
|
1567
|
|
- else:
|
1568
|
|
- if o.keyState[0] == 1:
|
1569
|
|
- if self.cur_el > 0:
|
1570
|
|
- self.cur_el -= 1
|
1571
|
|
- # o.mconf['theme'] = self.menu[self.cur_el]
|
1572
|
|
- # o.save_config()
|
1573
|
|
- # o.load_config()
|
1574
|
|
- # o.apply_theme()
|
1575
|
|
- print('cur el down is ', self.cur_el)
|
1576
|
|
-
|
1577
|
|
- #o.applyTheme
|
1578
|
|
- if o.keyState[1] == 1:
|
1579
|
|
- if self.cur_el < (len(self.menu) - 1):
|
1580
|
|
- self.cur_el += 1
|
1581
|
|
- # o.mconf['theme'] = self.menu[self.cur_el]
|
1582
|
|
- # o.save_config()
|
1583
|
|
- # o.load_config()
|
1584
|
|
- # o.apply_theme()
|
1585
|
|
- print('cur el up is ', self.cur_el)
|
1586
|
|
- #print('loading theme ', self.menu[self.cur_el], '-- ', o.mconf['theme'])
|
1587
|
|
- if o.keyState[3] == 1:
|
1588
|
|
- #open_command(self, o, self.menu[self.cur_el])
|
1589
|
|
- o.mconf['default_song'] = self.menu[self.cur_el]
|
1590
|
|
- o.save_config()
|
1591
|
|
- o.load_song()
|
1592
|
|
- #pass
|
1593
|
|
-
|
1594
|
|
- def draw_main(self, o):
|
1595
|
|
- al = []
|
1596
|
|
- ypos = 30
|
1597
|
|
- if self.cur_el == 0:
|
1598
|
|
- _iter = 0
|
1599
|
|
- while len(al) < 4:
|
1600
|
|
- al.append(self.menu[_iter])
|
1601
|
|
- _iter += 1
|
1602
|
|
- elif self.cur_el == 1:
|
1603
|
|
- al.append(self.menu[self.cur_el - 1])
|
1604
|
|
- al.append(self.menu[self.cur_el])
|
1605
|
|
- al.append(self.menu[self.cur_el + 1])
|
1606
|
|
- al.append(self.menu[self.cur_el + 2])
|
1607
|
|
- elif self.cur_el == (len(self.menu) - 2):
|
1608
|
|
- al.append(self.menu[self.cur_el - 2])
|
1609
|
|
- al.append(self.menu[self.cur_el - 1])
|
1610
|
|
- al.append(self.menu[self.cur_el])
|
1611
|
|
- al.append(self.menu[self.cur_el + 1])
|
1612
|
|
- elif self.cur_el == (len(self.menu) - 1):
|
1613
|
|
- al.append(self.menu[self.cur_el - 3])
|
1614
|
|
- al.append(self.menu[self.cur_el - 2])
|
1615
|
|
- al.append(self.menu[self.cur_el - 1])
|
1616
|
|
- al.append(self.menu[self.cur_el])
|
1617
|
|
- else:
|
1618
|
|
- al.append(self.menu[self.cur_el - 1])
|
1619
|
|
- al.append(self.menu[self.cur_el])
|
1620
|
|
- al.append(self.menu[self.cur_el + 1])
|
1621
|
|
- al.append(self.menu[self.cur_el + 2])
|
1622
|
|
- _iter = 0
|
1623
|
|
- for i in al:
|
1624
|
|
- if i == self.menu[self.cur_el]:
|
1625
|
|
- #if _iter == self.cur_el:
|
1626
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
|
1627
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
|
1628
|
|
- else:
|
1629
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
|
1630
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
|
1631
|
|
- ypos += 20
|
1632
|
|
- _iter += 1
|
1633
|
|
-
|
1634
|
|
- def draw_footer(self, o):
|
1635
|
|
- _iter = 0
|
1636
|
|
- width = o.width / 4
|
1637
|
|
- xpos = 0
|
1638
|
|
- yposa = 135 - 25
|
1639
|
|
- yposb = 135
|
1640
|
|
- opts = ["Up", "Down", "Esc", "Open"]
|
1641
|
|
- while _iter < 4:
|
1642
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
|
1643
|
|
-
|
1644
|
|
- if o.keyState[_iter] == 1:
|
1645
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
|
1646
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
|
1647
|
|
- else:
|
1648
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
|
1649
|
|
-
|
1650
|
|
- xpos += width
|
1651
|
|
- _iter += 1
|
1652
|
|
-
|
1653
|
|
-
|
1654
|
|
- def ReceiveMessage(self, message):
|
1655
|
|
- o = self.FSM.owner
|
1656
|
|
- u.play_seq(o, message)
|
1657
|
|
-
|
1658
|
|
- def Exit(self):
|
1659
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
1660
|
|
-
|
1661
|
|
-
|
1662
|
|
-class EnterText(State):
|
1663
|
|
- def __init__(self,FSM):
|
1664
|
|
- super(EnterText, self).__init__(FSM)
|
1665
|
|
-
|
1666
|
|
- def Enter(self):
|
1667
|
|
- o = self.FSM.owner
|
1668
|
|
-
|
1669
|
|
- m.menu1_actions(self, o)
|
1670
|
|
- if o.keyState[16] == 1:
|
1671
|
|
- m.draw_menu1(o)
|
1672
|
|
- o.update_display(0)
|
1673
|
|
- elif o.keyState[16] == 4:
|
1674
|
|
- u.draw_header(o)
|
1675
|
|
- self.draw_footer(o)
|
1676
|
|
- self.draw_main(o)
|
1677
|
|
- o.update_display(0)
|
1678
|
|
- self.input_string = ""
|
1679
|
|
- if o.sconf['title'] == 'blank':
|
1680
|
|
-
|
1681
|
|
- self.input_string += str(datetime.today().strftime('%Y%m%d'))
|
1682
|
|
- else:
|
1683
|
|
-
|
1684
|
|
- self.input_string += o.sconf['title']
|
1685
|
|
- #if
|
1686
|
|
- o.header_text = "EnterText"
|
1687
|
|
- o.pub.register("beat", self)
|
1688
|
|
- self.last_action = pygame.time.get_ticks()
|
1689
|
|
- self.caps = False
|
1690
|
|
- self.cur_but = 18
|
1691
|
|
- self.cur_letter = ""
|
1692
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1693
|
|
- pass
|
1694
|
|
- else:
|
1695
|
|
- pass
|
1696
|
|
-
|
1697
|
|
- self.skips = [7, 3, 11, 12, 13, 14, 15]
|
1698
|
|
-
|
1699
|
|
- self.lc_labels = [["p", "q", "r", "s"], ["t", "u", "v"], ["w", "x", "y", "z"], ["C", "A", "P", "S"],
|
1700
|
|
- ["g", "h", "i"], ["j", "k", "l"], ["m", "n", "o"], ["D", "E", "L"],
|
1701
|
|
- ["_", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-"], ["a", "b", "c"], ["d", "e", "f"], ["O", "K"],
|
1702
|
|
- [], [], [], []]
|
1703
|
|
-
|
1704
|
|
- self.uc_labels = [["P", "Q", "R", "S"], ["T", "U", "V"], ["W", "X", "Y", "Z"], ["C", "A", "P", "S"],
|
1705
|
|
- ["G", "H", "I"], ["J", "K", "L"], ["M", "N", "O"], ["D", "E", "L"],
|
1706
|
|
- ["_", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-"], ["A", "B", "C"], ["D", "E", "F"], ["O", "K"],
|
1707
|
|
- [], [], [], []]
|
1708
|
|
-
|
1709
|
|
- self.labels = self.lc_labels
|
1710
|
|
-
|
1711
|
|
- #self.songCycle = cycle(self.song)
|
1712
|
|
- #self.curPattern = next(self.songCycle)
|
1713
|
|
-
|
1714
|
|
- self.cycles = []
|
1715
|
|
- for l in self.labels:
|
1716
|
|
- self.cycles.append(cycle(l))
|
1717
|
|
-
|
1718
|
|
-
|
1719
|
|
-
|
1720
|
|
- self.draw(o)
|
1721
|
|
- o.update_display(0)
|
1722
|
|
- super(EnterText, self).Enter()
|
1723
|
|
-
|
1724
|
|
- def Execute(self):
|
1725
|
|
- o = self.FSM.owner
|
1726
|
|
-
|
1727
|
|
- y_size = o.height / 4
|
1728
|
|
- if o.keyState[11] == 1:
|
1729
|
|
- if self.input_string != 'blank':
|
1730
|
|
- o.title = self.input_string
|
1731
|
|
- #o.bpm = o.sconf['bpm']
|
1732
|
|
- o.sconf['title'] = self.input_string
|
1733
|
|
-
|
1734
|
|
- print('fsm saving')
|
1735
|
|
- o.save_song()
|
1736
|
|
- self.FSM.ToTransition('toFile')
|
1737
|
|
-
|
1738
|
|
- m.menu1_actions(self, o)
|
1739
|
|
- if o.keyState[16] == 1:
|
1740
|
|
- m.draw_menu1(o)
|
1741
|
|
- o.update_display(0)
|
1742
|
|
- elif o.keyState[16] == 4:
|
1743
|
|
- u.draw_header(o)
|
1744
|
|
- self.draw(o)
|
1745
|
|
- #self.draw_main(o)
|
1746
|
|
- o.update_display(0)
|
1747
|
|
-
|
1748
|
|
- if o.keyState[17] == 1:
|
1749
|
|
- m.draw_menu_saveas(o)
|
1750
|
|
- o.update_display(0)
|
1751
|
|
- elif o.keyState[17] == 4:
|
1752
|
|
- u.draw_header(o)
|
1753
|
|
- self.draw(o)
|
1754
|
|
- #self.draw_main(o)
|
1755
|
|
- o.update_display(0)
|
1756
|
|
-
|
1757
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
1758
|
|
- u.draw_header(o)
|
1759
|
|
- self.draw(o)
|
1760
|
|
- #self.draw_main(o)
|
1761
|
|
- o.update_display(0)
|
1762
|
|
-
|
1763
|
|
-
|
1764
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1765
|
|
- pass
|
1766
|
|
-
|
1767
|
|
- else:
|
1768
|
|
- _iter = 0
|
1769
|
|
- for k in o.keyState:
|
1770
|
|
- if k == 1:
|
1771
|
|
- cur_time = pygame.time.get_ticks()
|
1772
|
|
- print(cur_time - self.last_action)
|
1773
|
|
-
|
1774
|
|
- #print('cur letter ', next(self.cycles[_iter]))
|
1775
|
|
- if _iter not in self.skips:
|
1776
|
|
- self.last_action = cur_time
|
1777
|
|
- if _iter < len(self.cycles):
|
1778
|
|
- self.cur_letter = next(self.cycles[_iter])
|
1779
|
|
- self.cur_but = _iter
|
1780
|
|
- self.draw(o)
|
1781
|
|
- o.center_block(self.input_string + self.cur_letter, o.h2, [0, 0, o.width, y_size], o.light_grey)
|
1782
|
|
-
|
1783
|
|
- if _iter == 7:
|
1784
|
|
-
|
1785
|
|
- self.input_string = self.input_string[:-1]
|
1786
|
|
- #self.input_string = self.input_string.rstrip(self.input_string[-1])
|
1787
|
|
- print('deleting')
|
1788
|
|
- self.last_action = 100000000
|
1789
|
|
- self.draw(o)
|
1790
|
|
- o.center_block(self.input_string, o.h2, [0, 0, o.width, y_size], o.light_grey)
|
1791
|
|
-
|
1792
|
|
- elif _iter == 3:
|
1793
|
|
- print('caps')
|
1794
|
|
- if self.caps:
|
1795
|
|
- self.caps = False
|
1796
|
|
- self.labels = self.lc_labels
|
1797
|
|
-
|
1798
|
|
- else:
|
1799
|
|
- self.caps = True
|
1800
|
|
- self.labels = self.uc_labels
|
1801
|
|
- self.draw(o)
|
1802
|
|
- o.center_block(self.input_string, o.h2, [0, 0, o.width, y_size], o.light_grey)
|
1803
|
|
- self.cycles = []
|
1804
|
|
- for l in self.labels:
|
1805
|
|
- self.cycles.append(cycle(l))
|
1806
|
|
-
|
1807
|
|
- o.update_display(0)
|
1808
|
|
- _iter += 1
|
1809
|
|
-
|
1810
|
|
- cur_time = pygame.time.get_ticks()
|
1811
|
|
- delay = cur_time - self.last_action
|
1812
|
|
- if delay > 1000 and delay < 100000:
|
1813
|
|
- self.input_string += self.cur_letter
|
1814
|
|
- self.last_action = 100000000
|
1815
|
|
- self.reset_cycles()
|
1816
|
|
- self.draw(o)
|
1817
|
|
-
|
1818
|
|
- o.center_block(self.input_string, o.h2, [0, 0, o.width, y_size], o.light_grey)
|
1819
|
|
- o.update_display(0)
|
1820
|
|
-
|
1821
|
|
- def ReceiveMessage(self, message):
|
1822
|
|
- o = self.FSM.owner
|
1823
|
|
- u.play_seq(o, message)
|
1824
|
|
-
|
1825
|
|
- def draw(self, o):
|
1826
|
|
- x_size = o.width / 4
|
1827
|
|
- y_size = o.height / 4
|
1828
|
|
- og_x = 0
|
1829
|
|
- o_x = og_x
|
1830
|
|
- o_y = o.height
|
1831
|
|
- text_padding = 6
|
1832
|
|
-
|
1833
|
|
- _id = 0
|
1834
|
|
- while _id < 16:
|
1835
|
|
- lab = ""
|
1836
|
|
- for i in self.labels[_id]:
|
1837
|
|
- lab += i
|
1838
|
|
-
|
1839
|
|
- if _id == 8:
|
1840
|
|
- lab = "_12"
|
1841
|
|
-
|
1842
|
|
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.blue)
|
1843
|
|
- o.center_block(lab, o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
|
1844
|
|
-
|
1845
|
|
- o_x = o_x + x_size
|
1846
|
|
- _id += 1
|
1847
|
|
- if _id % 4 == 0:
|
1848
|
|
- o_y -= y_size
|
1849
|
|
- o_x = og_x
|
1850
|
|
- o.draw.rectangle((0, 0, o.width, y_size), outline=0, fill=o.blue)
|
1851
|
|
-
|
1852
|
|
- def reset_cycles(self):
|
1853
|
|
- self.cycles = []
|
1854
|
|
- for l in self.labels:
|
1855
|
|
- self.cycles.append(cycle(l))
|
1856
|
|
-
|
1857
|
|
- def Exit(self):
|
1858
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
1859
|
|
-
|
1860
|
|
-#====================================
|
1861
|
|
-
|
1862
|
|
-class LoadSound(State):
|
1863
|
|
- def __init__(self,FSM):
|
1864
|
|
- super(LoadSound, self).__init__(FSM)
|
1865
|
|
-
|
1866
|
|
- def Enter(self):
|
1867
|
|
- o = self.FSM.owner
|
1868
|
|
- o.header_text = "Load Sound"
|
1869
|
|
- o.pub.register("beat", self)
|
1870
|
|
- self.cur_el = 0
|
1871
|
|
-
|
1872
|
|
- self.press_ticks_up = None
|
1873
|
|
- self.press_ticks_down = None
|
1874
|
|
-
|
1875
|
|
- self.menu = []
|
1876
|
|
-
|
1877
|
|
- self.menu.append("..")
|
1878
|
|
- self.menu += self.get_file_list(o)
|
1879
|
|
- if o.last_load_sound_id != None and o.last_load_sound_id <= len(self.menu):
|
1880
|
|
- self.cur_el = o.last_load_sound_id
|
1881
|
|
- print('setting cur_el ', self.cur_el)
|
1882
|
|
- self.last_preview = None
|
1883
|
|
-
|
1884
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1885
|
|
- pass
|
1886
|
|
- else:
|
1887
|
|
- u.draw_header(o)
|
1888
|
|
- self.draw_main(o)
|
1889
|
|
-
|
1890
|
|
- o.update_display(0)
|
1891
|
|
- super(LoadSound, self).Enter()
|
1892
|
|
-
|
1893
|
|
- def Execute(self):
|
1894
|
|
- o = self.FSM.owner
|
1895
|
|
- m.menu1_actions(self, o)
|
1896
|
|
- if o.keyState[16] == 1:
|
1897
|
|
- m.draw_menu1(o)
|
1898
|
|
- o.update_display(0)
|
1899
|
|
- elif o.keyState[16] == 4:
|
1900
|
|
- u.draw_header(o)
|
1901
|
|
- self.draw_footer(o)
|
1902
|
|
- self.draw_main(o)
|
1903
|
|
- o.update_display(0)
|
1904
|
|
-
|
1905
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
1906
|
|
- u.draw_header(o)
|
1907
|
|
- self.draw_footer(o)
|
1908
|
|
- self.draw_main(o)
|
1909
|
|
- o.update_display(0)
|
1910
|
|
- #print('draw butt')
|
1911
|
|
-
|
1912
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
1913
|
|
- pass
|
1914
|
|
- else:
|
1915
|
|
-
|
1916
|
|
- since_up = 0
|
1917
|
|
- if o.keyState[0] == 2:
|
1918
|
|
- if self.press_ticks_up == None:
|
1919
|
|
- self.press_ticks_up = pygame.time.get_ticks()
|
1920
|
|
- since_up = pygame.time.get_ticks() - self.press_ticks_up
|
1921
|
|
- else:
|
1922
|
|
- self.press_ticks_up = None
|
1923
|
|
-
|
1924
|
|
- self.press_ticks_up = pygame.time.get_ticks()
|
1925
|
|
-
|
1926
|
|
-
|
1927
|
|
- if o.keyState[0] == 1 or since_up > 250:
|
1928
|
|
- if self.cur_el > 0:
|
1929
|
|
- self.cur_el -= 1
|
1930
|
|
- self.draw_main(o)
|
1931
|
|
- o.update_display(0)
|
1932
|
|
- self.press_ticks_up = pygame.time.get_ticks()
|
1933
|
|
-
|
1934
|
|
-
|
1935
|
|
-
|
1936
|
|
- since_down = 0
|
1937
|
|
- if o.keyState[1] == 2:
|
1938
|
|
- if self.press_ticks_down == None:
|
1939
|
|
- self.press_ticks_down = pygame.time.get_ticks()
|
1940
|
|
- since_down = pygame.time.get_ticks() - self.press_ticks_down
|
1941
|
|
- else:
|
1942
|
|
- self.press_ticks_down = None
|
1943
|
|
-
|
1944
|
|
- self.press_ticks_down = pygame.time.get_ticks()
|
1945
|
|
-
|
1946
|
|
-
|
1947
|
|
- if o.keyState[1] == 1 or since_down > 250:
|
1948
|
|
- if self.cur_el < (len(self.menu) - 1):
|
1949
|
|
- self.cur_el += 1
|
1950
|
|
- self.draw_main(o)
|
1951
|
|
- o.update_display(0)
|
1952
|
|
- self.press_ticks_down = pygame.time.get_ticks()
|
1953
|
|
-
|
1954
|
|
-
|
1955
|
|
-
|
1956
|
|
-
|
1957
|
|
- if o.keyState[2] == 1:
|
1958
|
|
- if self.is_wav():
|
1959
|
|
- if self.last_preview == self.menu[self.cur_el]:
|
1960
|
|
- pass
|
1961
|
|
- else:
|
1962
|
|
- snd = pygame.mixer.Sound(o.load_song_dir + self.menu[self.cur_el])
|
1963
|
|
- pygame.mixer.Sound.play(snd)
|
1964
|
|
- #o.last_load_sound_id = self.cur_el
|
1965
|
|
-
|
1966
|
|
-
|
1967
|
|
- if o.keyState[3] == 1:
|
1968
|
|
- if self.menu[self.cur_el] == '..':
|
1969
|
|
- print('directory up')
|
1970
|
|
- o.last_load_sound_id = None
|
1971
|
|
- if o.load_song_dir == '/home/pi/zpc_ct/user/sounds/':
|
1972
|
|
- print('root dir - cant go up')
|
1973
|
|
- else:
|
1974
|
|
- o.load_song_dir = os.path.dirname(os.path.dirname(o.load_song_dir))
|
1975
|
|
- o.load_song_dir += '/'
|
1976
|
|
- print('new up dir is ', o.load_song_dir)
|
1977
|
|
- self.menu = []
|
1978
|
|
- self.menu.append("..")
|
1979
|
|
- self.menu += self.get_file_list(o)
|
1980
|
|
-
|
1981
|
|
- self.cur_el = 0
|
1982
|
|
-
|
1983
|
|
- elif os.path.isdir(o.load_song_dir + self.menu[self.cur_el]):
|
1984
|
|
- print('this is a directory ', o.load_song_dir + self.menu[self.cur_el])
|
1985
|
|
- o.load_song_dir = o.load_song_dir + self.menu[self.cur_el] + '/'
|
1986
|
|
- self.menu = []
|
1987
|
|
- self.menu.append("..")
|
1988
|
|
- self.menu += self.get_file_list(o)
|
1989
|
|
- self.cur_el = 0
|
1990
|
|
-
|
1991
|
|
- else:
|
1992
|
|
- print('this is not a directory ', o.load_song_dir + self.menu[self.cur_el])
|
1993
|
|
- o.soundSlots[o.eSound].file = o.load_song_dir + self.menu[self.cur_el]
|
1994
|
|
- o.soundSlots[o.eSound].volume = 16
|
1995
|
|
- o.soundSlots[o.eSound].pitch = 0
|
1996
|
|
- o.soundSlots[o.eSound].create_sound()
|
1997
|
|
- o.soundSlots[o.eSound].set_pitch()
|
1998
|
|
- o.last_load_sound_id = self.cur_el
|
1999
|
|
- self.FSM.ToTransition('toMain')
|
2000
|
|
-
|
2001
|
|
- def get_file_list(self, o):
|
2002
|
|
- #os.path.isdir(o.load_song_dir + self.menu[self.cur_el])
|
2003
|
|
- dirs = os.listdir(o.load_song_dir)
|
2004
|
|
- dirs.sort()
|
2005
|
|
- for i in dirs:
|
2006
|
|
- if os.path.isdir(o.load_song_dir + i):
|
2007
|
|
- i += "/asdfasdfasf"
|
2008
|
|
- print(i, ' is a directory')
|
2009
|
|
- else:
|
2010
|
|
- print(i, ' is not a directory')
|
2011
|
|
- print(dirs)
|
2012
|
|
- return dirs
|
2013
|
|
-
|
2014
|
|
- def draw_main(self, o):
|
2015
|
|
- al = []
|
2016
|
|
- ypos = 30
|
2017
|
|
- #print(self.menu)
|
2018
|
|
- if self.cur_el == 0:
|
2019
|
|
- _iter = 0
|
2020
|
|
- while len(al) < 4:
|
2021
|
|
- if _iter < len(self.menu):
|
2022
|
|
- #print('appending to al', _iter, ' ', len(self.menu))
|
2023
|
|
- al.append(self.menu[_iter])
|
2024
|
|
- else:
|
2025
|
|
- break
|
2026
|
|
- _iter += 1
|
2027
|
|
- elif self.cur_el == 1:
|
2028
|
|
- al.append(self.menu[self.cur_el - 1])
|
2029
|
|
- al.append(self.menu[self.cur_el])
|
2030
|
|
- if (self.cur_el + 1) < len(self.menu):
|
2031
|
|
- al.append(self.menu[self.cur_el + 1])
|
2032
|
|
- if (self.cur_el + 2) < len(self.menu):
|
2033
|
|
- al.append(self.menu[self.cur_el + 2])
|
2034
|
|
- elif self.cur_el == (len(self.menu) - 2):
|
2035
|
|
- al.append(self.menu[self.cur_el - 2])
|
2036
|
|
- al.append(self.menu[self.cur_el - 1])
|
2037
|
|
- al.append(self.menu[self.cur_el])
|
2038
|
|
- al.append(self.menu[self.cur_el + 1])
|
2039
|
|
- elif self.cur_el == (len(self.menu) - 1):
|
2040
|
|
- al.append(self.menu[self.cur_el - 3])
|
2041
|
|
- al.append(self.menu[self.cur_el - 2])
|
2042
|
|
- al.append(self.menu[self.cur_el - 1])
|
2043
|
|
- al.append(self.menu[self.cur_el])
|
2044
|
|
- else:
|
2045
|
|
- al.append(self.menu[self.cur_el - 1])
|
2046
|
|
- al.append(self.menu[self.cur_el])
|
2047
|
|
- al.append(self.menu[self.cur_el + 1])
|
2048
|
|
- al.append(self.menu[self.cur_el + 2])
|
2049
|
|
- _iter = 0
|
2050
|
|
- #print(al)
|
2051
|
|
- for i in al:
|
2052
|
|
- # if os.path.isdir(o.load_song_dir + i):
|
2053
|
|
- # i += "/"
|
2054
|
|
- # print(i, ' is a directory')
|
2055
|
|
- # else:
|
2056
|
|
- # print(i, ' is not a directory')
|
2057
|
|
-
|
2058
|
|
- if i == self.menu[self.cur_el]:
|
2059
|
|
- #if _iter == self.cur_el:
|
2060
|
|
- if os.path.isdir(o.load_song_dir + i):
|
2061
|
|
- i += "/"
|
2062
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
|
2063
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
|
2064
|
|
- else:
|
2065
|
|
- if os.path.isdir(o.load_song_dir + i):
|
2066
|
|
- i += "/"
|
2067
|
|
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
|
2068
|
|
- #i += '/2342'
|
2069
|
|
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
|
2070
|
|
- ypos += 20
|
2071
|
|
- _iter += 1
|
2072
|
|
-
|
2073
|
|
- def draw_footer(self, o):
|
2074
|
|
- _iter = 0
|
2075
|
|
- width = o.width / 4
|
2076
|
|
- xpos = 0
|
2077
|
|
- yposa = 135 - 25
|
2078
|
|
- yposb = 135
|
2079
|
|
- opts = ["Up", "Down", "Play", "Open"]
|
2080
|
|
- while _iter < 4:
|
2081
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
|
2082
|
|
-
|
2083
|
|
- if o.keyState[_iter] == 1:
|
2084
|
|
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
|
2085
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
|
2086
|
|
- else:
|
2087
|
|
- if _iter == 2:
|
2088
|
|
- if self.is_wav():
|
2089
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
|
2090
|
|
- else:
|
2091
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.dark_grey)
|
2092
|
|
- else:
|
2093
|
|
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
|
2094
|
|
-
|
2095
|
|
- xpos += width
|
2096
|
|
- _iter += 1
|
2097
|
|
-
|
2098
|
|
- def is_wav(self):
|
2099
|
|
- if len(self.menu[self.cur_el]) > 3 and (self.menu[self.cur_el][-1] == 'V' or self.menu[self.cur_el][-1] == 'v') and (self.menu[self.cur_el][-2] == 'A' or self.menu[self.cur_el][-2] == 'a') and (self.menu[self.cur_el][-3] == 'W' or self.menu[self.cur_el][-3] == 'w'):
|
2100
|
|
- return True
|
2101
|
|
- else:
|
2102
|
|
- return False
|
2103
|
|
-
|
2104
|
|
- def ReceiveMessage(self, message):
|
2105
|
|
- o = self.FSM.owner
|
2106
|
|
- u.play_seq(o, message)
|
2107
|
|
-
|
2108
|
|
- def Exit(self):
|
2109
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
2110
|
|
-
|
2111
|
|
-#====================================
|
2112
|
|
-
|
2113
|
|
-class Ping(State):
|
2114
|
|
- def __init__(self,FSM):
|
2115
|
|
- super(Ping, self).__init__(FSM)
|
2116
|
|
-
|
2117
|
|
- def Enter(self):
|
2118
|
|
- o = self.FSM.owner
|
2119
|
|
-
|
2120
|
|
- o.header_text = "Ping"
|
2121
|
|
- o.pub.register("beat", self)
|
2122
|
|
-
|
2123
|
|
- #o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
|
2124
|
|
- #o.center_block("ping", o.h2, [0, 0, o.width,o.height], o.light_grey)
|
2125
|
|
- #o.update_display(0)
|
2126
|
|
-
|
2127
|
|
-
|
2128
|
|
-
|
2129
|
|
-
|
2130
|
|
- self.pinging = self.check_ping()
|
2131
|
|
-
|
2132
|
|
- self.draw_main(o)
|
2133
|
|
-
|
2134
|
|
- u.draw_header(o)
|
2135
|
|
- o.update_display(0)
|
2136
|
|
- super(Ping, self).Enter()
|
2137
|
|
-
|
2138
|
|
- def Execute(self):
|
2139
|
|
- o = self.FSM.owner
|
2140
|
|
- m.menu1_actions(self, o)
|
2141
|
|
- if o.keyState[16] == 1:
|
2142
|
|
- m.draw_menu1(o)
|
2143
|
|
- o.update_display(0)
|
2144
|
|
- elif o.keyState[16] == 4:
|
2145
|
|
- u.draw_header(o)
|
2146
|
|
- #self.draw_footer(o)
|
2147
|
|
- self.draw_main(o)
|
2148
|
|
- o.update_display(0)
|
2149
|
|
-
|
2150
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
2151
|
|
- u.draw_header(o)
|
2152
|
|
- #self.draw_footer(o)
|
2153
|
|
- self.draw_main(o)
|
2154
|
|
- o.update_display(0)
|
2155
|
|
-
|
2156
|
|
-
|
2157
|
|
- def draw_main(self, o):
|
2158
|
|
- o.center_block(self.pinging, o.h2, [0, 0, o.width, o.height], o.light_grey)
|
2159
|
|
-
|
2160
|
|
- def check_ping(self):
|
2161
|
|
- hostname = "8.8.8.8"
|
2162
|
|
- response = os.system("ping -c 1 " + hostname)
|
2163
|
|
- # and then check the response...
|
2164
|
|
- if response == 0:
|
2165
|
|
- pingstatus = "Network Active "
|
2166
|
|
- else:
|
2167
|
|
- pingstatus = "Network Error "
|
2168
|
|
-
|
2169
|
|
- return pingstatus
|
2170
|
|
-
|
2171
|
|
- def ReceiveMessage(self, message):
|
2172
|
|
- o = self.FSM.owner
|
2173
|
|
- u.play_seq(o, message)
|
2174
|
|
-
|
2175
|
|
- def Exit(self):
|
2176
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
2177
|
|
-
|
2178
|
|
-#====================================
|
2179
|
|
-
|
2180
|
|
-
|
2181
|
|
-class Wifi(State):
|
2182
|
|
- def __init__(self,FSM):
|
2183
|
|
- super(Wifi, self).__init__(FSM)
|
2184
|
|
-
|
2185
|
|
- def Enter(self):
|
2186
|
|
- o = self.FSM.owner
|
2187
|
|
-
|
2188
|
|
- o.header_text = "Wifi"
|
2189
|
|
- o.pub.register("beat", self)
|
2190
|
|
-
|
2191
|
|
- self.ipad = self.extract_ip()
|
2192
|
|
- self.ssid = os.popen("sudo iwgetid -r").read()
|
2193
|
|
- o.center_block(self.ipad, o.h2, [0, 0, o.width,o.height], o.light_grey)
|
2194
|
|
-
|
2195
|
|
- u.draw_header(o)
|
2196
|
|
- self.draw_main(o)
|
2197
|
|
- o.update_display(0)
|
2198
|
|
- super(Wifi, self).Enter()
|
2199
|
|
-
|
2200
|
|
- def Execute(self):
|
2201
|
|
- o = self.FSM.owner
|
2202
|
|
- m.menu1_actions(self, o)
|
2203
|
|
- if o.keyState[16] == 1:
|
2204
|
|
- m.draw_menu1(o)
|
2205
|
|
- o.update_display(0)
|
2206
|
|
- elif o.keyState[16] == 4:
|
2207
|
|
- u.draw_header(o)
|
2208
|
|
- #self.draw_footer(o)
|
2209
|
|
- self.draw_main(o)
|
2210
|
|
- o.update_display(0)
|
2211
|
|
-
|
2212
|
|
- if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
2213
|
|
- u.draw_header(o)
|
2214
|
|
- #self.draw_footer(o)
|
2215
|
|
- self.draw_main(o)
|
2216
|
|
- o.update_display(0)
|
2217
|
|
-
|
2218
|
|
-
|
2219
|
|
- def draw_main(self, o):
|
2220
|
|
- o.center_block(self.ipad, o.h2, [0, 0, o.width, o.height], o.light_grey)
|
2221
|
|
- o.center_block(self.ssid, o.h2, [0, 40, o.width, o.height+40], o.light_grey)
|
2222
|
|
-
|
2223
|
|
-
|
2224
|
|
- def extract_ip(self):
|
2225
|
|
- st = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
2226
|
|
- try:
|
2227
|
|
- #st.connect(('10.255.255.255', 1))
|
2228
|
|
- st.connect(("8.8.8.8", 80))
|
2229
|
|
- IP = st.getsockname()[0]
|
2230
|
|
- except Exception:
|
2231
|
|
- IP = '127.0.0.1'
|
2232
|
|
- finally:
|
2233
|
|
- st.close()
|
2234
|
|
- return IP
|
2235
|
|
- #print(extract_ip())
|
2236
|
|
-
|
2237
|
|
- def ReceiveMessage(self, message):
|
2238
|
|
- o = self.FSM.owner
|
2239
|
|
- u.play_seq(o, message)
|
2240
|
|
-
|
2241
|
|
- def Exit(self):
|
2242
|
|
- self.FSM.owner.pub.unregister("beat", self)
|
2243
|
|
-
|
2244
|
|
-#====================================
|
2245
|
|
-
|
2246
|
|
-
|
2247
|
|
-
|
2248
|
|
-class Defender(State):
|
2249
|
|
- def __init__(self,FSM):
|
2250
|
|
- super(Defender, self).__init__(FSM)
|
2251
|
|
-
|
2252
|
|
- def Enter(self):
|
2253
|
|
- o = self.FSM.owner
|
2254
|
|
-
|
2255
|
|
- self.gameFSM = FSM.DefenderFSM(o)
|
2256
|
|
-
|
2257
|
|
- super(Defender, self).Enter()
|
2258
|
|
-
|
2259
|
|
- def Execute(self):
|
2260
|
|
- o = self.FSM.owner
|
2261
|
|
- m.menu1_actions(self, o)
|
2262
|
|
- if o.keyState[16] == 1:
|
2263
|
|
- m.draw_menu1(o)
|
2264
|
|
- o.update_display(0)
|
2265
|
|
- elif o.keyState[16] == 4:
|
2266
|
|
- #u.draw_header(o)
|
2267
|
|
- #self.draw_footer(o)
|
2268
|
|
- #self.draw_main(o)
|
2269
|
|
- #o.update_display(0)
|
2270
|
|
- pass
|
2271
|
|
-
|
2272
|
|
- if o.keyState[16] > 0 or o.keyState[17] > 0:
|
2273
|
|
-
|
2274
|
|
- #if o.keyState[16] > 0:
|
2275
|
|
- pass
|
2276
|
|
- else:
|
2277
|
|
- self.gameFSM.Execute()
|
2278
|
|
-
|
2279
|
|
- def Exit(self):
|
2280
|
|
- pass
|
2281
|
|
-
|
2282
|
|
-#====================================
|
2283
|
|
-#====================================
|
2284
|
|
-
|
2285
|
|
-
|
2286
|
|
-
|
2287
|
|
-# class Update(State):
|
2288
|
|
-# def __init__(self,FSM):
|
2289
|
|
-# super(Update, self).__init__(FSM)
|
2290
|
|
-
|
2291
|
|
-# def Enter(self):
|
2292
|
|
-
|
2293
|
|
-# o = self.FSM.owner
|
2294
|
|
-# o.header_text = "Update"
|
2295
|
|
-# o.pub.register("beat", self)
|
2296
|
|
-# g = git.cmd.Git("/home/pi/zpc_ct/")
|
2297
|
|
-# self.msg = g.pull()
|
2298
|
|
-# if o.keyState[16] > 0 or o.keyState[17] > 0:
|
2299
|
|
-# pass
|
2300
|
|
-# else:
|
2301
|
|
-# u.draw_header(o)
|
2302
|
|
-# o.update_display(0)
|
2303
|
|
-# super(Update, self).Enter()
|
2304
|
|
-
|
2305
|
|
-# def Execute(self):
|
2306
|
|
-# o = self.FSM.owner
|
2307
|
|
-# m.menu1_actions(self, o)
|
2308
|
|
-# if o.keyState[16] == 1:
|
2309
|
|
-# m.draw_menu1(o)
|
2310
|
|
-# o.update_display(0)
|
2311
|
|
-# elif o.keyState[16] == 4:
|
2312
|
|
-# u.draw_header(o)
|
2313
|
|
-# #self.draw_footer(o)
|
2314
|
|
-# self.draw_main(o)
|
2315
|
|
-# o.update_display(0)
|
2316
|
|
-
|
2317
|
|
-# if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
2318
|
|
-# u.draw_header(o)
|
2319
|
|
-# #self.draw_footer(o)
|
2320
|
|
-# self.draw_main(o)
|
2321
|
|
-# o.update_display(0)
|
2322
|
|
-
|
2323
|
|
-# if o.keyState[16] > 0 or o.keyState[17] > 0:
|
2324
|
|
-# pass
|
2325
|
|
-# else:
|
2326
|
|
-# pass
|
2327
|
|
-# #o.update_display(0)
|
2328
|
|
-
|
2329
|
|
-# def draw_main(self, o):
|
2330
|
|
-# #o.center_text(self.msg, o.h1, o.width, 25, o.light_grey)
|
2331
|
|
-# o.center_block(self.msg, o.h2, [0, 0, o.width, o.height], o.light_grey)
|
2332
|
|
-
|
2333
|
|
-# def ReceiveMessage(self, message):
|
2334
|
|
-# o = self.FSM.owner
|
2335
|
|
-# u.play_seq(o, message)
|
2336
|
|
-
|
2337
|
|
-# def Exit(self):
|
2338
|
|
-# self.FSM.owner.pub.unregister("beat", self)
|
2339
|
|
-
|
2340
|
|
-#====================================
|
2341
|
|
-
|
2342
|
|
-
|
2343
|
|
-
|
2344
|
|
-# class Calculator(State):
|
2345
|
|
-# def __init__(self,FSM):
|
2346
|
|
-# super(Calculator, self).__init__(FSM)
|
2347
|
|
-
|
2348
|
|
-# def Enter(self):
|
2349
|
|
-# o = self.FSM.owner
|
2350
|
|
-
|
2351
|
|
-# o.pub.register("beat", self)
|
2352
|
|
-
|
2353
|
|
-# self.num1 = ''
|
2354
|
|
-# self.num2 = ''
|
2355
|
|
-# self.op = ''
|
2356
|
|
-# self.result = ''
|
2357
|
|
-
|
2358
|
|
-# self.labels = ['.', '0', '=', '/',
|
2359
|
|
-# '1', '2', '3', '*',
|
2360
|
|
-# '4', '5', '6', '-',
|
2361
|
|
-# '7', '8', '9', '+',
|
2362
|
|
-# '7', '8', '9', '+']
|
2363
|
|
-
|
2364
|
|
-# self.draw_main(o)
|
2365
|
|
-# o.update_display(0)
|
2366
|
|
-
|
2367
|
|
-# super(Calculator, self).Enter()
|
2368
|
|
-
|
2369
|
|
-# def Execute(self):
|
2370
|
|
-# o = self.FSM.owner
|
2371
|
|
-# m.menu1_actions(self, o)
|
2372
|
|
-# if o.keyState[16] == 1:
|
2373
|
|
-# m.draw_menu1(o)
|
2374
|
|
-# o.update_display(0)
|
2375
|
|
-# elif o.keyState[16] == 4:
|
2376
|
|
-# self.draw_main(o)
|
2377
|
|
-# o.update_display(0)
|
2378
|
|
-
|
2379
|
|
-# if o.keyState[16] > 0:
|
2380
|
|
-# pass
|
2381
|
|
-# else:
|
2382
|
|
-# if o.keyState[17] == 1:
|
2383
|
|
-# self.num1 = ''
|
2384
|
|
-# self.num2 = ''
|
2385
|
|
-# self.op = ''
|
2386
|
|
-# self.result = ''
|
2387
|
|
-
|
2388
|
|
-# self.check_keys(o)
|
2389
|
|
-
|
2390
|
|
-# def append_num(self, num):
|
2391
|
|
-# ops = ['+', '-', '*', '/']
|
2392
|
|
-# print('appending num ', num)
|
2393
|
|
-# if num in ops:
|
2394
|
|
-# if self.num1 != '':
|
2395
|
|
-# self.op = num
|
2396
|
|
-# self.num2 = ''
|
2397
|
|
-# self.result = ''
|
2398
|
|
-# elif num == '=':
|
2399
|
|
-# print('this is that')
|
2400
|
|
-# if self.num2 != '':
|
2401
|
|
-# if self.result == '':
|
2402
|
|
-# if self.op == '+':
|
2403
|
|
-# self.result = float(self.num1) + float(self.num2)
|
2404
|
|
-# print(self.result)
|
2405
|
|
-# if self.op == '-':
|
2406
|
|
-# self.result = float(self.num1) - float(self.num2)
|
2407
|
|
-# print(self.result)
|
2408
|
|
-# if self.op == '*':
|
2409
|
|
-# self.result = float(self.num1) * float(self.num2)
|
2410
|
|
-# print(self.result)
|
2411
|
|
-# if self.op == '/':
|
2412
|
|
-# self.result = float(self.num1) / float(self.num2)
|
2413
|
|
-# print(self.result)
|
2414
|
|
-# else:
|
2415
|
|
-# if self.op != '':
|
2416
|
|
-# if self.op == '+':
|
2417
|
|
-# self.result = self.result + float(self.num2)
|
2418
|
|
-# print(self.result)
|
2419
|
|
-# if self.op == '-':
|
2420
|
|
-# self.result = self.result - float(self.num2)
|
2421
|
|
-# print(self.result)
|
2422
|
|
-# if self.op == '*':
|
2423
|
|
-# self.result = self.result * float(self.num2)
|
2424
|
|
-# print(self.result)
|
2425
|
|
-# if self.op == '/':
|
2426
|
|
-# self.result = self.result / float(self.num2)
|
2427
|
|
-# print(self.result)
|
2428
|
|
-
|
2429
|
|
-# else:
|
2430
|
|
-# if self.result != '':
|
2431
|
|
-# self.num1 = ''
|
2432
|
|
-# self.num2 = ''
|
2433
|
|
-# self.op = ''
|
2434
|
|
-# self.result = ''
|
2435
|
|
-# if self.op == '':
|
2436
|
|
-# self.num1 += num
|
2437
|
|
-# print('---append ', num)
|
2438
|
|
-# else:
|
2439
|
|
-# self.num2 += num
|
2440
|
|
-# print('---append ', num)
|
2441
|
|
-
|
2442
|
|
-# def check_keys(self, o):
|
2443
|
|
-# _iter = 0
|
2444
|
|
-# for k in o.keyState:
|
2445
|
|
-# if k == 1:
|
2446
|
|
-# if _iter == 0:
|
2447
|
|
-# if ('.' not in self.num1 and self.num2 == '') or (self.num2 != '' and '.' not in self.num2):
|
2448
|
|
-# self.append_num('.')
|
2449
|
|
-# if _iter == 1:
|
2450
|
|
-# self.append_num('0')
|
2451
|
|
-# if _iter == 2:
|
2452
|
|
-# self.append_num('=')
|
2453
|
|
-# if _iter == 3:
|
2454
|
|
-# self.append_num('/')
|
2455
|
|
-# if _iter == 4:
|
2456
|
|
-# self.append_num('1')
|
2457
|
|
-# if _iter == 5:
|
2458
|
|
-# self.append_num('2')
|
2459
|
|
-# if _iter == 6:
|
2460
|
|
-# self.append_num('3')
|
2461
|
|
-# if _iter == 7:
|
2462
|
|
-# self.append_num('*')
|
2463
|
|
-# if _iter == 8:
|
2464
|
|
-# self.append_num('4')
|
2465
|
|
-# if _iter == 9:
|
2466
|
|
-# self.append_num('5')
|
2467
|
|
-# if _iter == 10:
|
2468
|
|
-# self.append_num('6')
|
2469
|
|
-# if _iter == 11:
|
2470
|
|
-# self.append_num('-')
|
2471
|
|
-# if _iter == 12:
|
2472
|
|
-# self.append_num('7')
|
2473
|
|
-# if _iter == 13:
|
2474
|
|
-# self.append_num('8')
|
2475
|
|
-# if _iter == 14:
|
2476
|
|
-# self.append_num('9')
|
2477
|
|
-# if _iter == 15:
|
2478
|
|
-# self.append_num('+')
|
2479
|
|
-
|
2480
|
|
-# self.draw_main(o)
|
2481
|
|
-
|
2482
|
|
-# _iter += 1
|
2483
|
|
-
|
2484
|
|
-# def draw_main(self, o):
|
2485
|
|
-# print('drawing ', self.num1)
|
2486
|
|
-# x_size = o.width / 4
|
2487
|
|
-# y_size = o.height / 5
|
2488
|
|
-# og_x = 0
|
2489
|
|
-# o_x = og_x
|
2490
|
|
-# o_y = o.height
|
2491
|
|
-# text_padding = 6
|
2492
|
|
-
|
2493
|
|
-# _id = 0
|
2494
|
|
-# while _id < 20:
|
2495
|
|
-# # lab = ""
|
2496
|
|
-# # for i in self.labels[_id]:
|
2497
|
|
-# # lab += i
|
2498
|
|
-
|
2499
|
|
-# lab = self.labels[_id]
|
2500
|
|
-
|
2501
|
|
-# o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.blue)
|
2502
|
|
-# o.center_block(lab, o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
|
2503
|
|
-
|
2504
|
|
-# o_x = o_x + x_size
|
2505
|
|
-# _id += 1
|
2506
|
|
-# if _id % 4 == 0:
|
2507
|
|
-# o_y -= y_size
|
2508
|
|
-# o_x = og_x
|
2509
|
|
-# o.draw.rectangle((0, 0, o.width, y_size), outline=0, fill=o.blue)
|
2510
|
|
-# #o.center_block('where is my fucking text', o.h2, [0, 0, o.width, y_size], o.light_grey)
|
2511
|
|
-# if self.num1 != '':
|
2512
|
|
-# if self.result != '':
|
2513
|
|
-# o.center_block(str(self.result), o.h2, [0, 0, o.width, y_size], o.light_grey)
|
2514
|
|
-# elif self.num2 != '':
|
2515
|
|
-# o.center_block(str(self.num2), o.h2, [0, 0, o.width, y_size], o.light_grey)
|
2516
|
|
-# elif self.op != '':
|
2517
|
|
-# o.center_block(str(self.op), o.h2, [0, 0, o.width, y_size], o.light_grey)
|
2518
|
|
-# else:
|
2519
|
|
-# o.center_block(str(self.num1), o.h2, [0, 0, o.width, y_size], o.light_grey)
|
2520
|
|
-# print('fucking do something')
|
2521
|
|
-# else:
|
2522
|
|
-# print('num1 is empty')
|
2523
|
|
-# o.update_display(0)
|
2524
|
|
-
|
2525
|
|
-# def ReceiveMessage(self, message):
|
2526
|
|
-# o = self.FSM.owner
|
2527
|
|
-# u.play_seq(o, message)
|
2528
|
|
-
|
2529
|
|
-# def Exit(self):
|
2530
|
|
-# self.FSM.owner.pub.unregister("beat", self)
|
2531
|
|
-
|
2532
|
|
-#====================================
|
2533
|
|
-
|
2534
|
|
-# class About(State):
|
2535
|
|
-# def __init__(self,FSM):
|
2536
|
|
-# super(About, self).__init__(FSM)
|
2537
|
|
-
|
2538
|
|
-# def Enter(self):
|
2539
|
|
-
|
2540
|
|
-# o = self.FSM.owner
|
2541
|
|
-# o.header_text = "About"
|
2542
|
|
-# o.pub.register("beat", self)
|
2543
|
|
-
|
2544
|
|
-# if o.keyState[16] > 0 or o.keyState[17] > 0:
|
2545
|
|
-# pass
|
2546
|
|
-# else:
|
2547
|
|
-# u.draw_header(o)
|
2548
|
|
-# o.update_display(0)
|
2549
|
|
-# self.draw_main(o)
|
2550
|
|
-# super(About, self).Enter()
|
2551
|
|
-
|
2552
|
|
-# def Execute(self):
|
2553
|
|
-# o = self.FSM.owner
|
2554
|
|
-# m.menu1_actions(self, o)
|
2555
|
|
-# if o.keyState[16] == 1:
|
2556
|
|
-# m.draw_menu1(o)
|
2557
|
|
-# o.update_display(0)
|
2558
|
|
-# elif o.keyState[16] == 4:
|
2559
|
|
-# u.draw_header(o)
|
2560
|
|
-# self.draw_main(o)
|
2561
|
|
-# o.update_display(0)
|
2562
|
|
-
|
2563
|
|
-# if o.keyState[0] == 1 or o.keyState[0] == 3 or o.keyState[1] == 1 or o.keyState[1] == 3 or o.keyState[2] == 1 or o.keyState[2] == 3 or o.keyState[3] == 1 or o.keyState[3] == 3:
|
2564
|
|
-# u.draw_header(o)
|
2565
|
|
-# self.draw_main(o)
|
2566
|
|
-# o.update_display(0)
|
2567
|
|
-
|
2568
|
|
-# def draw_main(self, o):
|
2569
|
|
-# o.center_block("rob@robzilla-beats.com", o.h2, [0, 0, o.width, o.height], o.light_grey)
|
2570
|
|
-
|
2571
|
|
-# def ReceiveMessage(self, message):
|
2572
|
|
-# o = self.FSM.owner
|
2573
|
|
-# u.play_seq(o, message)
|
2574
|
|
-
|
2575
|
|
-# def Exit(self):
|
2576
|
|
-# self.FSM.owner.pub.unregister("beat", self)
|