1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002 |
-
- import random
- import time
- import pygame
- import sys
- import pyaudio
- import wave
- import glob
- import os
- from itertools import cycle
- from datetime import datetime
- import ast
- import random
- #====================================
-
- State = type("State", (object,), {})
- #====================================
- class State(object):
- def __init__(self, FSM):
- self.FSM = FSM
- self.timer = 0
- self.startTime = 0
- def Enter(self):
- self.timer = 0
- self.startTime = 0
- def Execute(self):
- print('Executing')
- def Exit(self):
- print('Exiting')
-
- #====================================
-
- def play_seq(o, message):
- _id = 0
- o.clear_notes_on()
- for s in o.soundSlots:
- if s.notes[message[0]][message[1]][0] == 1:
- o.notes_on[_id] = 1
- o.soundSlots[_id].play(s.notes[message[0]][message[1]][1])
- _id += 1
- #print(o.notes_on)
- def draw_header(o):
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_text(o.header_text, o.h1, o.width, 25, o.light_grey)
- o.center_text("----------------------", o.h2, o.width, 55, o.light_grey)
-
- def text_box1(o, a, b):
- w1 = 0
- w2 = (o.width / 2) - 50
- h1 = 45
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box2(o, a, b):
- w1 = 0
- w2 = (o.width / 2) - 50
- h1 = 90
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box3(o, a, b):
- w1 = (o.width / 2) + 40
- w2 = o.width
- h1 = 45
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_box4(o, a, b):
- w1 = (o.width / 2) + 40
- w2 = o.width
- h1 = 90
- h2 = h1 + 10
- o.center_block(a, o.h2, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h2, [w1,h1+10,w2,h2+25], o.light_grey)
-
- def text_center(o, a, b):
- w1 = 0
- w2 = o.width
- h1 = 45
- h2 = h1 + 10
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_block(a, o.h1, [w1,h1,w2,h2], o.light_grey)
- o.center_block(b, o.h1, [w1,h1+20,w2,h2+45], o.light_grey)
-
-
- def draw_menu1(o):
- bpm_inc = 4
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
- _id = 0
- while _id < 16:
-
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.blue)
-
- if _id == 0:
- o.center_block("Main", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 1:
- o.center_block("Note", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 2:
- o.center_block("Patt", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 3:
- o.center_block("Song", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 4:
- o.center_block("File", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 5:
- o.center_block("Util", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 6:
- o.center_block("Bank-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 7:
- o.center_block("Bank+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 8:
- o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 9:
- o.center_block("Vol+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 11:
- o.center_block("", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 12:
- o.center_block("Play", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 13:
- o.center_block("Stop", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 14:
- o.center_block("BPM-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 15:
- o.center_block("BPM+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
-
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
-
-
- def draw_menu2_sample(o):
- bpm_inc = 4
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
- _id = 0
- while _id < 16:
-
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
-
-
- if _id == 0:
- o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 1:
- o.center_block("Paste", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 2:
- o.center_block("Del-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 3:
- o.center_block("Load", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- if _id == 4:
- o.center_block("Vol-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 5:
- o.center_block("Vol+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 6:
- o.center_block("Pitch-", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 7:
- o.center_block("Pitch+", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
-
- def draw_menu2_pattern(o):
- bpm_inc = 4
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
- _id = 0
- while _id < 16:
-
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
-
- if _id == 0:
- o.center_block("Copy", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 1:
- o.center_block("Paste", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 2:
- o.center_block("Clear", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 6:
- o.center_block("Bank -", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 7:
- o.center_block("Bank +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
-
- def draw_menu2_note(o):
- bpm_inc = 4
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
- _id = 0
- while _id < 16:
-
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.dark_grey)
-
- if _id == 0:
- o.center_block("Vol -", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
- if _id == 1:
- o.center_block("Vol +", o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
-
- def menu1_actions(self, o):
- if o.keyState[16] == 2:
- if o.keyState[0] == 1:
- self.FSM.ToTransition('toMain')
- elif o.keyState[1] == 1:
- self.FSM.ToTransition('toEditSoundSequence')
- elif o.keyState[2] == 1:
- self.FSM.ToTransition('toSelectPattern')
- elif o.keyState[3] == 1:
- self.FSM.ToTransition('toEditSong')
- elif o.keyState[4] == 1:
- self.FSM.ToTransition('toFile')
- elif o.keyState[5] == 1:
- self.FSM.ToTransition('toUtil')
- if o.keyState[12] == 1:
- o.start_playback()
- if o.keyState[13] == 1:
- o.stop_playback()
- if o.keyState[6] == 1:
- if o.note_bank > 0:
- o.note_bank -= 1
- if o.keyState[7] == 1:
- if o.note_bank < 4:
- o.note_bank += 1
- if o.keyState[8] == 1:
- if o.volume > 0:
- o.volume -= 1
- text_center(o, "Master Volume", str(o.volume))
- o.update_display(0)
- if o.keyState[9] == 1:
- if o.volume < 16:
- o.volume += 1
- text_center(o, "Master Volume", str(o.volume))
- o.update_display(0)
- if o.keyState[11] == 1:
- #o.save_song()
- pass
- if o.keyState[14] == 1:
- if o.sconf.as_int('bpm') > 60:
- o.sconf['bpm'] = o.sconf.as_int('bpm') - o.bpm_inc
- o.update_bpm()
- text_center(o, "Master BPM", str(o.sconf['bpm']))
- o.update_display(0)
- if o.keyState[15] == 1:
- if o.sconf.as_int('bpm') < 240:
- o.sconf['bpm'] = o.sconf.as_int('bpm') + o.bpm_inc
- o.update_bpm()
- text_center(o, "Master BPM", str(o.sconf['bpm']))
- o.update_display(0)
-
-
- def menu2_actions_sample(self, o):
- if o.keyState[17] == 2:
- if o.keyState[0] == 1:
- if o.soundSlots[o.eSound].volume > 0:
- print('copy')
- o.soundClipboard = [o.soundSlots[o.eSound].file, o.soundSlots[o.eSound].volume, o.soundSlots[o.eSound].pitch]
- print(o.soundClipboard)
- #text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
- #o.update_display(0)
- elif o.keyState[1] == 1:
- if o.soundSlots[o.eSound].volume < 16:
- print('pasting ', o.soundClipboard)
- #o.soundSlots[o.eSound].volume += 1
- #text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
- #o.update_display(0)
- elif o.keyState[2] == 1:
- if o.soundSlots[o.eSound].pitch > -10:
- o.soundSlots[o.eSound].pitch -= 1
- text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
- o.soundSlots[o.eSound].set_pitch()
- o.update_display(0)
- elif o.keyState[3] == 1:
- if o.soundSlots[o.eSound].pitch < 10:
- o.soundSlots[o.eSound].pitch += 1
- text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
- o.soundSlots[o.eSound].set_pitch()
- o.update_display(0)
-
- elif o.keyState[4] == 1:
- if o.soundSlots[o.eSound].volume > 0:
- o.soundSlots[o.eSound].volume -= 1
- text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
- o.update_display(0)
- elif o.keyState[5] == 1:
- if o.soundSlots[o.eSound].volume < 16:
- o.soundSlots[o.eSound].volume += 1
- text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
- o.update_display(0)
- elif o.keyState[6] == 1:
- if o.soundSlots[o.eSound].pitch > -10:
- o.soundSlots[o.eSound].pitch -= 1
- text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
- o.soundSlots[o.eSound].set_pitch()
- o.update_display(0)
- elif o.keyState[7] == 1:
- if o.soundSlots[o.eSound].pitch < 10:
- o.soundSlots[o.eSound].pitch += 1
- text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
- o.soundSlots[o.eSound].set_pitch()
- o.update_display(0)
-
- def menu2_actions_pattern(self, o):
- if o.keyState[17] == 2:
- if o.keyState[0] == 1:
- print('copy')
- o.patternClipboard = []
- for s in o.soundSlots:
- notes = []
- for i in s.notes[o.ePattern]:
- notes.append([i[0], i[1]])
- #i[0] = 0
- #i[1] = 0
- o.patternClipboard.append(notes)
- print('adding to clip ', notes)
- # if o.soundSlots[o.eSound].volume > 0:
- # o.soundSlots[o.eSound].volume -= 1
- # text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
- # o.update_display(0)
- elif o.keyState[1] == 1:
- print('paste')
- if o.patternClipboard != []:
- p = 0
- for s in o.soundSlots:
- n = 0
- for i in s.notes[o.ePattern]:
- i[0] = o.patternClipboard[p][n][0]
- i[1] = o.patternClipboard[p][n][1]
- n += 1
- print('added ', o.patternClipboard[p])
- p += 1
-
-
- else:
- print('nothing to paste')
- # if o.soundSlots[o.eSound].volume < 16:
- # o.soundSlots[o.eSound].volume += 1
- # text_center(o, "Sample Volume", str(o.soundSlots[o.eSound].volume))
- # o.update_display(0)
- elif o.keyState[2] == 1:
- print('clear')
- print(o.soundSlots[o.eSound].notes[o.ePattern])
- for s in o.soundSlots:
- for i in s.notes[o.ePattern]:
- i[0] = 0
- i[1] = 0
- #print(o.soundSlots[o.eSound].notes[o.ePattern])
- # if o.soundSlots[o.eSound].pitch > -10:
- # o.soundSlots[o.eSound].pitch -= 1
- # text_center(o, "Sample Pitch", str(o.soundSlots[o.eSound].pitch))
- # o.soundSlots[o.eSound].set_pitch()
- # o.update_display(0)
- elif o.keyState[6] == 1:
- if o.pat_bank > 0:
- o.pat_bank -= 1
- text_center(o, "Pattern Bank", str(o.pat_bank))
- o.update_display(0)
-
- elif o.keyState[7] == 1:
- if o.pat_bank < 4:
- o.pat_bank += 1
- text_center(o, "Pattern Bank", str(o.pat_bank))
- o.update_display(0)
-
-
-
- def menu2_actions_note(self, o):
- if o.keyState[17] == 2:
- if o.keyState[0] == 1:
- if o.note_vol > 0:
- o.note_vol -= 1
- text_center(o, "Note Volume", str(o.note_vol))
- o.update_display(0)
-
-
- elif o.keyState[1] == 1:
- if o.note_vol < 16:
- o.note_vol += 1
- text_center(o, "Note Volume", str(o.note_vol))
- o.update_display(0)
-
-
-
-
- def util_command(self, o, command):
- if command == "Clock":
- self.FSM.ToTransition('toClock')
- elif command == "Ball":
- self.FSM.ToTransition('toBall')
- elif command == "Exit":
- self.FSM.ToTransition('toExit')
- elif command == "Theme":
- self.FSM.ToTransition('toSelTheme')
- elif command == "Reboot":
- #self.FSM.ToTransition('toSelTheme')
- os.system("sudo reboot")
-
-
- def file_command(self, o, command):
- if command == "Save":
- o.save_song()
-
- elif command == "Open":
- self.FSM.ToTransition('toOpenSong')
- elif command == "Save As":
- self.FSM.ToTransition('toEnterText')
- #====================================
-
- class Example(State):
- def __init__(self,FSM):
- super(Example, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- super(Example, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
-
- def Exit(self):
- pass
-
- #====================================
-
- class Startup(State):
- def __init__(self,FSM):
- super(Startup, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- self.birth = time.perf_counter()
- super(Startup, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- print('startup state')
-
- if hasattr(self, 'birth'):
- pass
- else:
- self.birth = time.perf_counter()
-
- self.FSM.ToTransition('toIntro')
-
- def Exit(self):
- pass
-
- #====================================
-
- class Intro(State):
- def __init__(self,FSM):
- super(Intro, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Starting up..."
- o.draw.rectangle((0, 0, self.FSM.owner.width, self.FSM.owner.height), outline=0, fill=o.blue)
- #draw_header(o)
- #o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_block("Starting up...", o.h2, [0, 0, o.width, o.height], o.light_grey)
- #o.display_thread.start()
- o.update_display(0)
- #o.update_display(0)
- super(Intro, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- o = self.FSM.owner
- self.FSM.ToTransition('toLoadDefault')
-
- def Exit(self):
- pass
-
- #====================================
-
- class LoadDefault(State):
- def __init__(self,FSM):
- super(LoadDefault, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
-
-
- o = self.FSM.owner
- o.init_slots()
- o.load_song()
-
-
-
- self.bank = 0
- self.sounds = []
- self.globbed = glob.glob('/home/pi/skull/*.wav') + glob.glob('/home/pi/skull/*.mp3')
- self.globbed.sort()
- obj_id = 0
-
- # for s in o.sconf['sounds']:
- # p1 = self.FSM.owner.SoundSlot(s, obj_id, o)
- # self.FSM.owner.soundSlots.append(p1)
- # obj_id += 1
-
- _iter = 0
-
- lst = ast.literal_eval(o.sconf['notes'][0])
- print('length ', len(lst))
-
- for n in o.soundSlots:
- m = []
- if _iter < (len(o.sconf.as_list('notes')) - 1):
- lst = ast.literal_eval(o.sconf.as_list('notes')[_iter])
- n.notes = lst
- _iter += 1
-
- super(LoadDefault, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- self.FSM.ToTransition('toMain')
-
- def Exit(self):
- pass
-
- #====================================
-
- #====================================
-
- class Main(State):
- def __init__(self,FSM):
- super(Main, self).__init__(FSM)
-
- def Enter(self):
- print('hello main')
- self.FSM.owner.pub.register("beat", self)
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Main"
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
-
- text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
- o.update_display(0)
-
- #o.soundSlots[2].volume = 2
- super(Main, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- menu2_actions_sample(self, o)
-
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- #print('esound ', o.eSound)
- #print('oss ', o.soundSlots[o.eSound].volume)
- text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
- o.update_display(0)
-
-
- if o.keyState[17] == 1:
- draw_menu2_sample(o)
- o.update_display(0)
- elif o.keyState[17] == 4:
- draw_header(o)
- self.draw_square()
- text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
- o.update_display(0)
-
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- if k == 1:
- note = _id + o.note_bank * 16
- #if len(o.soundSlots) > note:
- if 12 == 12:
-
- #o.soundSlots[note].play(o.note_vol)
- o.slots[note].play(o.note_vol)
- o.eSound = note
- #print('now editing sound ', o.eSound)
- draw_header(o)
- #text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
- text_box1(o, "SVol", str(o.slots[o.eSound].volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- #text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
- text_box3(o, "Pitch", str(o.slots[o.eSound].pitch))
- self.draw_square()
- o.update_display(0)
- _id += 1
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
- text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box4(o, "Bank", str(o.note_bank))
- text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
- o.update_display(0)
-
- def draw_square(self):
- o = self.FSM.owner
- size = 22
- og_x = (o.width / 2) - (size * 2)
- o_x = og_x
- o_y = 127
- _id = o.note_bank * 16
-
- while _id < ((o.note_bank * 16) + 16):
- if _id == o.eSound:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
- elif o.notes_on[_id] == 1:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.grey, width=1)
- elif _id > (len(o.soundSlots) - 1):
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.dark_blue, width=1)
-
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y -= size
- o_x = og_x
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
- #====================================
-
- class PadPlayer(State):
- def __init__(self,FSM):
- super(PadPlayer, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- print('entering pad player')
- super(PadPlayer, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
-
-
- _id = 0
- for k in self.FSM.owner.keyState:
- if _id < 16 and k == 1:
- self.FSM.owner.soundSlots[_id].play()
- _id += 1
- if self.FSM.owner.keys:
-
- print("Pressed: ", self.FSM.owner.keys)
- #self.FSM.ToTransition('toLand')
-
- def Exit(self):
- pass
-
- #====================================
-
- class SeqPlayer(State):
- def __init__(self,FSM):
- super(SeqPlayer, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- self.beat = 0
- self.FSM.owner.pub.register("beat", self)
- print('entering seq player')
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((20, 0), 'SeqPlayer', font=o.h1, fill="#FFFFFF")
- o.update_display(0)
- super(SeqPlayer, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
- o = self.FSM.owner
-
- if o.keyState[12] == 1:
- o.start_playback()
- if o.keyState[13] == 1:
- o.stop_playback()
- #self.beat = o.playhead
- #print('key0 ', o.keyState[16])
- if o.keyState[16] == 2:
- #print('key0 ', o.keyState[16])
- if o.keyState[0] == 1:
- print('to main')
- self.FSM.ToTransition('toMain')
-
- def ReceiveMessage(self, message):
- #print(self.name, 'got message', message)
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((20, 0), str(message[0]) + ' - ' + str(message[1]), font=o.h1, fill="#FFFFFF")
- o.update_display(0)
- play_seq(o, message)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
- #====================================
-
- class SelectSound(State):
- def __init__(self,FSM):
- super(SelectSound, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "SelSou"
- o.pub.register("beat", self)
- draw_header(o)
- self.draw_square()
- o.update_display(0)
- super(SelectSound, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- o.update_display(0)
-
- if o.keyState[16] == 2:
- if o.keyState[0] == 1:
- self.FSM.ToTransition('toMain')
- else:
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if k == 1:
- o.eSound = _id
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.draw.text((0, 0), "SelSou", font=o.h1, fill=o.color_a)
- o.draw.text((20, 60), str(o.eSound), font=o.h2, fill=o.color_b)
- self.draw_square()
- o.update_display(0)
- self.FSM.owner.soundSlots[_id].play()
- #print('now editing sound ', _id)
- _id += 1
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=(0, 0, 0))
- o.draw.text((0, 0), "SelSou", font=o.h1, fill="#FFFFFF")
- o.draw.text((0, 20), str(o.eSound), font=o.h2, fill="#FFFFFF")
- o.update_display(0)
- play_seq(o, message)
-
- def draw_square(self):
- o = self.FSM.owner
- size = 32
- og_x = 110
- o_x = og_x
- o_y = 0
- _id = 0
-
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- if _id == o.eSound:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.color_b)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y + size), outline=0, fill=o.dark_grey)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y += size
- o_x = og_x
-
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class SelectPattern(State):
- def __init__(self,FSM):
- super(SelectPattern, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Select Pattern"
- o.pub.register("beat", self)
- self.cur_playing = 0
- self.active_patterns = []
- self.get_active_patterns(o)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Pat", str(o.ePattern))
- text_box4(o, "Bank", str(o.pat_bank))
- o.update_display(0)
-
- super(SelectPattern, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- menu2_actions_pattern(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Pat", str(o.ePattern))
- text_box4(o, "Bank", str(o.pat_bank))
- o.update_display(0)
-
- if o.keyState[17] == 1:
- draw_menu2_pattern(o)
- o.update_display(0)
- elif o.keyState[17] == 4:
- draw_header(o)
- self.draw_square()
- #text_box1(o, "SVol", str(o.soundSlots[o.eSound].volume))
- #text_box2(o, "BPM", str(o.sconf['bpm']))
- text_box1(o, "Pat", str(o.ePattern))
- text_box4(o, "Bank", str(o.pat_bank))
- #text_box3(o, "Pitch", str(o.soundSlots[o.eSound].pitch))
- self.get_active_patterns(o)
- o.update_display(0)
-
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- _id = 0
- for k in o.keyState:
- if _id > 15:
- pass
- else:
- if k == 1:
- o.ePattern = (o.pat_bank * 16) +_id
-
- draw_header(o)
- self.draw_square()
-
- text_box1(o, "Pat", str(o.ePattern))
- text_box4(o, "Bank", str(o.pat_bank))
- o.update_display(0)
-
-
- _id += 1
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- if message[0] != self.cur_playing:
- #print('playing ', message)
- self.cur_playing = message[0]
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Pat", str(o.ePattern))
- text_box4(o, "PBank", str(o.pat_bank))
- o.update_display(0)
-
- def draw_square(self):
- o = self.FSM.owner
- size = 22
- og_x = (o.width / 2) - (size * 2)
- o_x = og_x
- o_y = 127
- _id = 0
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- if (_id + (o.pat_bank * 16)) == o.ePattern:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.olive, width=1)
- elif (_id + (o.pat_bank * 16)) == self.cur_playing:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.light_grey, width=1)
- elif self.active_patterns[_id] == 1:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.dark_blue, width=1)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y -= size
- o_x = og_x
-
- def get_active_patterns(self, o):
- #for n in o.soundSlots[o.eSound]
- self.active_patterns = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
- pat_iter = o.pat_bank * 16
- _iter = 0
- print('is this note on? ', o.soundSlots[0].notes[0][0][0])
-
-
- while pat_iter < ((o.pat_bank * 16) + 16):
-
- for s in o.soundSlots:
- print('checking soundSlot ', s.id)
- pat_used = 0
- for p in s.notes[pat_iter]:
- if self.active_patterns[_iter] == 1:
- break
- if p[0] == 1:
- #pat_used = 1
- self.active_patterns[_iter] = 1
- print('found ', pat_iter, ' -- ', p[0])
- break
- #self.active_patterns.append(pat_used)
- pat_iter += 1
- _iter += 1
-
- print('active patterns ', self.active_patterns)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class EditSoundSequence(State):
- def __init__(self,FSM):
- super(EditSoundSequence, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "Note Edit"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Note Vol", str(o.note_vol))
- o.update_display(0)
- super(EditSoundSequence, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- menu2_actions_note(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Note Vol", str(o.note_vol))
- o.update_display(0)
-
- if o.keyState[17] == 1:
- draw_menu2_note(o)
- o.update_display(0)
- elif o.keyState[17] == 4:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Note Vol", str(o.note_vol))
-
- o.update_display(0)
-
- if o.keyState[16] == 2:
- pass
-
- else:
- _id = 0
- for k in self.FSM.owner.keyState:
- if _id < 16 and k == 1:
- if o.soundSlots[o.eSound].notes[o.ePattern][_id][0] == 1:
- print('turn note off')
- o.soundSlots[o.eSound].notes[o.ePattern][_id][0] = 0
- o.soundSlots[o.eSound].notes[o.ePattern][_id][1] = 0
- else:
- print('turn note on')
- o.soundSlots[o.eSound].notes[o.ePattern][_id][0] = 1
- o.soundSlots[o.eSound].notes[o.ePattern][_id][1] = o.note_vol
- _id += 1
-
-
- def draw_square(self):
- o = self.FSM.owner
- size = 22
- og_x = (o.width / 2) - (size * 2)
- o_x = og_x
- o_y = 127
- _id = 0
- for n in o.soundSlots[o.eSound].notes[o.ePattern]:
- if _id == o.playhead:
- if o.curPattern == o.ePattern:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.olive, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.olive, fill=o.pink, width=1)
- elif n[0] == 1:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.light_grey, width=1)
- else:
- o.draw.rectangle((o_x, o_y, o_x + size, o_y - size), outline=o.light_grey, fill=o.blue, width=1)
- o_x = o_x + size
- _id += 1
- if _id % 4 == 0:
- o_y -= size
- o_x = og_x
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_square()
- text_box1(o, "Note Vol", str(o.note_vol))
- o.update_display(0)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class EditSong(State):
- def __init__(self,FSM):
- super(EditSong, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Edit Song"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
- o.draw.text((20, 50), str(o.song), font=o.h2, fill=o.light_grey)
- o.update_display(0)
- self.new_song = []
- super(EditSong, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
-
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- if self.new_song == []:
- o.draw.text((20, 30), "Current Song", font=o.h2, fill=o.light_grey)
- o.draw.text((20, 50), str(o.song), font=o.h2, fill=o.light_grey)
- else:
- o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
- o.draw.text((20, 50), str(self.new_song), font=o.h2, fill=o.pink)
- o.update_display(0)
-
- if o.keyState[16] > 0:
- pass
- else:
- _id = 0
- for k in self.FSM.owner.keyState:
- if k == 1 and _id < 16:
- self.new_song.append((_id + (o.pat_bank * 16)))
- draw_header(o)
- o.draw.text((20, 30), "New Song", font=o.h2, fill=o.pink)
- o.draw.text((20, 50), str(self.new_song), font=o.h2, fill=o.pink)
- o.update_display(0)
- _id += 1
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- o = self.FSM.owner
- self.FSM.owner.pub.unregister("beat", self)
- if self.new_song != []:
- o.song = self.new_song
- o.songCycle = cycle(self.new_song)
- self.curPattern = next(o.songCycle)
- o.songStart = o.curPattern
-
- #====================================
-
- class File(State):
- def __init__(self,FSM):
- super(File, self).__init__(FSM)
-
- def Enter(self):
- self.FSM.stateLife = 1
- o = self.FSM.owner
- o.header_text = "File"
- o.pub.register("beat", self)
- self.cur_el = 0
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
- self.menu = ["Save", "Save As", "Open", "New"]
-
- super(File, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- #self.draw_footer(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
-
- 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:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
- print('draw butt')
-
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- if o.keyState[0] == 1:
- if self.cur_el > 0:
- self.cur_el -= 1
- print('cur el down is ', self.cur_el)
- if o.keyState[1] == 1:
- if self.cur_el < (len(self.menu) - 1):
- self.cur_el += 1
- print('cur el up is ', self.cur_el)
-
- if o.keyState[3] == 1:
- file_command(self, o, self.menu[self.cur_el])
- pass
-
- def draw_footer(self, o):
- _iter = 0
- width = o.width / 4
- xpos = 0
- yposa = 135 - 25
- yposb = 135
- opts = ["Up", "Down", "Esc", "OK"]
- while _iter < 4:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
-
- if o.keyState[_iter] == 1:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
- else:
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
-
- xpos += width
- _iter += 1
-
-
- def draw_main(self, o):
- al = []
- ypos = 30
- if self.cur_el == 0:
- _iter = 0
- while len(al) < 4:
- al.append(self.menu[_iter])
- _iter += 1
- elif self.cur_el == 1:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- elif self.cur_el == (len(self.menu) - 2):
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- elif self.cur_el == (len(self.menu) - 1):
- al.append(self.menu[self.cur_el - 3])
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- else:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- _iter = 0
- for i in al:
- if i == self.menu[self.cur_el]:
- #if _iter == self.cur_el:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
- else:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
- ypos += 20
- _iter += 1
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- class Util(State):
- def __init__(self,FSM):
- super(Util, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Utilities"
- o.pub.register("beat", self)
- self.menu = ["Clock", "Ball", "Exit", "Shutdown", "Reboot", "Theme", "Update"]
- self.cur_el = 0
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
-
-
- super(Util, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
-
- 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:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
- print('draw butt')
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- if o.keyState[0] == 1:
- if self.cur_el > 0:
- self.cur_el -= 1
- print('cur el down is ', self.cur_el)
- if o.keyState[1] == 1:
- if self.cur_el < (len(self.menu) - 1):
- self.cur_el += 1
- print('cur el up is ', self.cur_el)
-
- if o.keyState[3] == 1:
- util_command(self, o, self.menu[self.cur_el])
-
- def ReceiveMessage(self, message):
- _id = 0
- o = self.FSM.owner
- play_seq(o, message)
- # if o.keyState[16] > 0 or o.keyState[17] > 0:
- # pass
- # else:
- # draw_header(o)
- # o.update_display(0)
-
- def draw_main(self, o):
- al = []
- ypos = 30
- if self.cur_el == 0:
- _iter = 0
- while len(al) < 4:
- al.append(self.menu[_iter])
- _iter += 1
- elif self.cur_el == 1:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- elif self.cur_el == (len(self.menu) - 2):
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- elif self.cur_el == (len(self.menu) - 1):
- al.append(self.menu[self.cur_el - 3])
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- else:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- _iter = 0
- for i in al:
- if i == self.menu[self.cur_el]:
- #if _iter == self.cur_el:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
- else:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
- ypos += 20
- _iter += 1
-
- def draw_footer(self, o):
- _iter = 0
- width = o.width / 4
- xpos = 0
- yposa = 135 - 25
- yposb = 135
- opts = ["Up", "Down", "Esc", "OK"]
- while _iter < 4:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
-
- if o.keyState[_iter] == 1:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
- else:
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
-
- xpos += width
- _iter += 1
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
-
-
- class Ball(State):
- def __init__(self,FSM):
- super(Ball, self).__init__(FSM)
-
- def Enter(self):
- self.ball_size = 10
- self.ballx = self.ball_size
- self.bally = self.ball_size
-
- self.ball_speed = 15
- self.ball_x_dir = 1
- self.ball_y_dir = 1
-
- self.ball2x = self.ball_size + 180
- self.ball2y = self.ball_size + 70
-
- self.ball2_x_dir = -1
- self.ball2_y_dir = -1
-
- self.xmult = 1.0
-
- o = self.FSM.owner
- o.header_text = "Ball"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- o.update_display(0)
- super(Ball, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
-
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- now = datetime.now()
- current_time = time.strftime("%-I:%M %p")
-
-
- if self.ballx < (0 + self.ball_size):
- self.ball_x_dir = 1
- if self.ballx > (o.width - self.ball_size):
- self.ball_x_dir = -1
-
- if self.bally < (0 + self.ball_size):
- self.ball_y_dir = 1
- if self.bally > (o.height - self.ball_size):
- self.ball_y_dir = -1
-
- # if self.ballx > (o.width - self.ball_size) or self.ballx < (0 + self.ball_size):
- # self.ball_x_dir *= -1
- # if self.bally > (o.height - self.ball_size) or self.bally < (0 + self.ball_size):
- # self.ball_y_dir *= -1
-
- self.ballx += self.ball_speed * self.ball_x_dir
- self.bally += self.ball_speed * self.ball_y_dir
-
-
- if self.ball2x < (0 + self.ball_size):
- self.ball2_x_dir = 1
- self.xmult = random.uniform(.6, 1.2)
- if self.ball2x > (o.width - self.ball_size):
- self.ball2_x_dir = -1
- self.xmult = random.uniform(.6, 1.2)
-
- if self.ball2y < (0 + self.ball_size):
- self.ball2_y_dir = 1
- if self.ball2y > (o.height - self.ball_size):
- self.ball2_y_dir = -1
-
-
- # if self.ball2x > (o.width - self.ball_size) or self.ball2x < (0 + self.ball_size):
- # self.ball2_x_dir *= -1
- # self.xmult = random.uniform(.8, 1.2)
- # if self.ball2y > (o.height - self.ball_size) or self.ball2y < (0 + self.ball_size):
- # self.ball2_y_dir *= -1
-
- self.ball2x += (self.ball_speed * self.ball2_x_dir) * self.xmult
- self.ball2y += (self.ball_speed * self.ball2_y_dir)
-
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
-
- 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)
- 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)
- #o.center_block(current_time, o.h3, [0,0,o.width,o.height], o.pink)
- o.update_display(0)
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
-
- class Clock(State):
- def __init__(self,FSM):
- super(Clock, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- current_time = time.strftime("%-I:%M:%S")
- self.ball_sizex, self.ball_sizey = o.h3.getsize("18:88:88")
- self.ball_sizex /= 2
- self.ball_sizey /= 2
- self.ballx = o.width / 2
- self.bally = o.height / 2
- self.ball_speed = 1
- self.ball_x_dir = 1
- self.ball_y_dir = 1
-
- o.header_text = "Clock"
- o.pub.register("beat", self)
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- pass
- super(Clock, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
-
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
-
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- current_time = time.strftime("%-I:%M:%S")
-
- if self.ballx > (o.width - self.ball_sizex) or self.ballx < (0 + self.ball_sizex):
- self.ball_x_dir *= -1
- if (self.bally > o.height - self.ball_sizey) or (self.bally < 0 + self.ball_sizey):
- self.ball_y_dir *= -1
-
- self.ballx += self.ball_speed * self.ball_x_dir
- self.bally += self.ball_speed * self.ball_y_dir
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.black)
- o.draw.text((self.ballx - self.ball_sizex, self.bally - self.ball_sizey), current_time, align='center', font=o.h3, fill=o.olive)
- o.update_display(0)
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class Exit(State):
- def __init__(self,FSM):
- super(Exit, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
- o.center_block("goodbye", o.h2, [0, 0, o.width,o.height], o.light_grey)
- o.update_display(0)
- pygame.quit()
- sys.exit()
- super(Exit, self).Enter()
-
- def Execute(self):
- self.FSM.stateLife += 1
-
- def Exit(self):
- pass
-
- #====================================
-
- class SelTheme(State):
- def __init__(self,FSM):
- super(SelTheme, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Select Theme"
- o.pub.register("beat", self)
- self.cur_el = 0
- self.globbed = glob.glob('/home/pi/zpc_ct/themes/*.thm')
- self.globbed.sort()
- self.names = [os.path.basename(x) for x in self.globbed]
- self.names = [os.path.splitext(x)[0] for x in self.names]
- if o.mconf['theme'] in self.names:
- _id = self.names.index(o.mconf['theme'])
- self.cur_el = _id
- #print('found theme ', _id)
- else:
- print('nope ', o.mconf['theme'], ' - ', self.globbed)
- #self.theme = ConfigObj("/home/pi/zpc_ct/themes/" + self.mconf['theme'])
- #print(os.path.splitext(x)[0])
- self.menu = self.names
-
- #self.cur_el = 0
- print('theme menu is ', self.menu)
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_main(o)
-
- o.update_display(0)
- super(SelTheme, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
-
- 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:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
- print('draw butt')
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- if o.keyState[0] == 1:
- if self.cur_el > 0:
- self.cur_el -= 1
- o.mconf['theme'] = self.menu[self.cur_el]
- o.save_config()
- o.load_config()
- o.apply_theme()
- print('cur el down is ', self.cur_el)
-
- #o.applyTheme
- if o.keyState[1] == 1:
- if self.cur_el < (len(self.menu) - 1):
- self.cur_el += 1
- o.mconf['theme'] = self.menu[self.cur_el]
- o.save_config()
- o.load_config()
- o.apply_theme()
- print('cur el up is ', self.cur_el)
- print('loading theme ', self.menu[self.cur_el], '-- ', o.mconf['theme'])
- if o.keyState[3] == 1:
- util_command(self, o, self.menu[self.cur_el])
-
- def draw_main(self, o):
- al = []
- ypos = 30
- if self.cur_el == 0:
- _iter = 0
- while len(al) < 4:
- al.append(self.menu[_iter])
- _iter += 1
- elif self.cur_el == 1:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- elif self.cur_el == (len(self.menu) - 2):
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- elif self.cur_el == (len(self.menu) - 1):
- al.append(self.menu[self.cur_el - 3])
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- else:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- _iter = 0
- for i in al:
- if i == self.menu[self.cur_el]:
- #if _iter == self.cur_el:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
- else:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
- ypos += 20
- _iter += 1
-
- def draw_footer(self, o):
- _iter = 0
- width = o.width / 4
- xpos = 0
- yposa = 135 - 25
- yposb = 135
- opts = ["Up", "Down", "", ""]
- while _iter < 4:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
-
- if o.keyState[_iter] == 1:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
- else:
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
-
- xpos += width
- _iter += 1
-
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
-
- class OpenSong(State):
- def __init__(self,FSM):
- super(OpenSong, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
- o.header_text = "Open Song"
- o.pub.register("beat", self)
- self.cur_el = 0
- self.globbed = glob.glob('/home/pi/zpc_ct/user/songs/*.sng')
- self.globbed.sort()
- if '/home/pi/zpc_ct/user/songs/_blank.sng' in self.globbed:
- self.globbed.remove('/home/pi/zpc_ct/user/songs/_blank.sng')
- #del self.globbed[0]
- self.names = [os.path.basename(x) for x in self.globbed]
- self.names = [os.path.splitext(x)[0] for x in self.names]
- print('we got these songs ', self.names)
- print('in these paths ', self.globbed)
- if o.mconf['default_song'] in self.names:
- _id = self.names.index(o.mconf['default_song'])
- self.cur_el = _id
- else:
- print('nope ', o.mconf['default_song'], ' - ', self.globbed)
- self.menu = self.names
-
- #self.cur_el = 0
- #print('theme menu is ', self.menu)
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- draw_header(o)
- self.draw_main(o)
-
- o.update_display(0)
- super(OpenSong, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- menu1_actions(self, o)
- if o.keyState[16] == 1:
- draw_menu1(o)
- o.update_display(0)
- elif o.keyState[16] == 4:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
-
- 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:
- draw_header(o)
- self.draw_footer(o)
- self.draw_main(o)
- o.update_display(0)
- print('draw butt')
-
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- if o.keyState[0] == 1:
- if self.cur_el > 0:
- self.cur_el -= 1
- # o.mconf['theme'] = self.menu[self.cur_el]
- # o.save_config()
- # o.load_config()
- # o.apply_theme()
- print('cur el down is ', self.cur_el)
-
- #o.applyTheme
- if o.keyState[1] == 1:
- if self.cur_el < (len(self.menu) - 1):
- self.cur_el += 1
- # o.mconf['theme'] = self.menu[self.cur_el]
- # o.save_config()
- # o.load_config()
- # o.apply_theme()
- print('cur el up is ', self.cur_el)
- #print('loading theme ', self.menu[self.cur_el], '-- ', o.mconf['theme'])
- if o.keyState[3] == 1:
- #open_command(self, o, self.menu[self.cur_el])
- o.mconf['default_song'] = self.menu[self.cur_el]
- o.load_song()
- #pass
-
- def draw_main(self, o):
- al = []
- ypos = 30
- if self.cur_el == 0:
- _iter = 0
- while len(al) < 4:
- al.append(self.menu[_iter])
- _iter += 1
- elif self.cur_el == 1:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- elif self.cur_el == (len(self.menu) - 2):
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- elif self.cur_el == (len(self.menu) - 1):
- al.append(self.menu[self.cur_el - 3])
- al.append(self.menu[self.cur_el - 2])
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- else:
- al.append(self.menu[self.cur_el - 1])
- al.append(self.menu[self.cur_el])
- al.append(self.menu[self.cur_el + 1])
- al.append(self.menu[self.cur_el + 2])
- _iter = 0
- for i in al:
- if i == self.menu[self.cur_el]:
- #if _iter == self.cur_el:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.light_grey)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.blue)
- else:
- o.draw.rectangle((0, ypos, o.width, ypos + 20), outline=0, fill=o.blue)
- o.center_block(i, o.h2, [0, ypos, o.width,ypos + 20], o.light_grey)
- ypos += 20
- _iter += 1
-
- def draw_footer(self, o):
- _iter = 0
- width = o.width / 4
- xpos = 0
- yposa = 135 - 25
- yposb = 135
- opts = ["Up", "Down", "Esc", "Open"]
- while _iter < 4:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.blue)
-
- if o.keyState[_iter] == 1:
- o.draw.rectangle((xpos, yposa, xpos + width, yposb), outline=0, fill=o.light_grey)
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.blue)
- else:
- o.center_block(opts[_iter], o.h2, [xpos,yposa,xpos + width,yposb], o.light_grey)
-
- xpos += width
- _iter += 1
-
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
-
- class EnterText(State):
- def __init__(self,FSM):
- super(EnterText, self).__init__(FSM)
-
- def Enter(self):
- o = self.FSM.owner
-
- self.input_string = ""
- o.header_text = "EnterText"
- o.pub.register("beat", self)
- self.last_action = pygame.time.get_ticks()
-
- self.cur_but = 18
- self.cur_letter = ""
- if o.keyState[16] > 0 or o.keyState[17] > 0:
- pass
- else:
- pass
-
- self.skips = [7, 11, 12, 13, 14, 15]
-
- self.labels = [["p", "q", "r", "s"], ["t", "u", "v"], ["w", "x", "y", "z"], ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
- ["g", "h", "i"], ["j", "k", "l"], ["m", "n", "o"], ["D", "E", "L"],
- ["_", "-"], ["a", "b", "c"], ["d", "e", "f"], ["O", "K"],
- [], [], [], []]
-
- #self.songCycle = cycle(self.song)
- #self.curPattern = next(self.songCycle)
-
- self.cycles = []
- for l in self.labels:
- self.cycles.append(cycle(l))
-
- self.draw(o)
- o.update_display(0)
- super(EnterText, self).Enter()
-
- def Execute(self):
- o = self.FSM.owner
- y_size = o.height / 4
- if o.keyState[11] == 1:
- self.FSM.ToTransition('toFile')
- if o.keyState[16] > 0 and o.keyState[17] > 0:
- pass
- else:
- _iter = 0
- for k in o.keyState:
- if k == 1:
- cur_time = pygame.time.get_ticks()
- print(cur_time - self.last_action)
-
- #print('cur letter ', next(self.cycles[_iter]))
- if _iter not in self.skips:
- self.last_action = cur_time
- self.cur_letter = next(self.cycles[_iter])
- self.cur_but = _iter
- self.draw(o)
- o.center_block(self.input_string + self.cur_letter, o.h2, [0, 0, o.width, y_size], o.light_grey)
-
- if _iter == 7:
-
- self.input_string = self.input_string[:-1]
- #self.input_string = self.input_string.rstrip(self.input_string[-1])
- print('deleting')
- self.last_action = 100000000
- self.draw(o)
- o.center_block(self.input_string, o.h2, [0, 0, o.width, y_size], o.light_grey)
-
- o.update_display(0)
- _iter += 1
-
- cur_time = pygame.time.get_ticks()
- delay = cur_time - self.last_action
- if delay > 1000 and delay < 100000:
- self.input_string += self.cur_letter
- self.last_action = 100000000
- self.reset_cycles()
- self.draw(o)
-
- o.center_block(self.input_string, o.h2, [0, 0, o.width, y_size], o.light_grey)
- o.update_display(0)
-
- def ReceiveMessage(self, message):
- o = self.FSM.owner
- play_seq(o, message)
-
- def draw(self, o):
- x_size = o.width / 4
- y_size = o.height / 4
- og_x = 0
- o_x = og_x
- o_y = o.height
- text_padding = 6
-
-
- _id = 0
- while _id < 16:
- lab = ""
- for i in self.labels[_id]:
- lab += i
- o.draw.rectangle((o_x, o_y, o_x + x_size, o_y - y_size), outline=0, fill=o.blue)
- if _id == 3:
- lab = "123"
- o.center_block(lab, o.h2, [o_x, o_y, o_x + x_size, o_y - y_size], o.light_grey)
-
- o_x = o_x + x_size
- _id += 1
- if _id % 4 == 0:
- o_y -= y_size
- o_x = og_x
- o.draw.rectangle((0, 0, o.width, y_size), outline=0, fill=o.blue)
-
- def reset_cycles(self):
- self.cycles = []
- for l in self.labels:
- self.cycles.append(cycle(l))
-
- def Exit(self):
- self.FSM.owner.pub.unregister("beat", self)
-
- #====================================
|