-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid_view.py
30 lines (24 loc) · 977 Bytes
/
grid_view.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class GridView:
def __init__(self, model, midi_output):
self.model = model
self.midi_output = midi_output
def __getitem__(self, key):
return self.model.grid[key]
def display_console(self):
rows, columns = self.model.rows, self.model.columns
console_grid = "\n"
for col in range(columns):
for row in range(rows):
console_grid += "[X] " if self.model[row, col]._state == True else "[ ] "
console_grid += "\n"
return console_grid
def release_leds(self):
for col in range(self.model.columns - 1):
for row in range(self.model.rows - 1):
self.midi_output.send_messages(row + col*16, 0)
def set_mode(self, mode):
if self.model.mode != mode:
print (f"Mode changing from {self.model.mode} to {mode}")
self.model.mode = mode
else:
print(f"Remaining in mode {self.model.mode}")