7
7
from dataclasses import dataclass
8
8
from glm import ivec2 , vec2 , ivec3 , vec3
9
9
import time
10
+ import colorsys
10
11
11
12
from src .util import *
12
13
from src .constants import *
@@ -1419,19 +1420,29 @@ def __init__(self):
1419
1420
self .options .octave_separation = get_option (opts , "octave_separation" , DEFAULT_OPTIONS .octave_separation )
1420
1421
self .options .octave_split = get_option (opts , "octave_split" , DEFAULT_OPTIONS .octave_split )
1421
1422
1423
+ self .options .width = get_option (opts , "width" , 0 )
1424
+ self .options .height = get_option (opts , "height" , 0 )
1425
+
1426
+ self .split_point = None
1427
+
1422
1428
hardware_split = False
1423
- self .options .size = get_option (opts , "size" , DEFAULT_OPTIONS .size )
1424
- if self .options .size == 128 :
1425
- self .options .width = 16
1426
- self .split_point = None
1427
- elif self .options .size == 200 :
1428
- self .options .width = 25
1429
- self .split_point = 11
1430
- hardware_split = True
1431
- elif self .options .size < 0 : # test hardware split
1432
- self .options .width = 16
1433
- self .split_point = - self .options .size
1434
- hardware_split = True
1429
+ self .split_point = 11
1430
+ if self .options .width <= 0 or self .options .height <= 0 :
1431
+ self .options .size = get_option (opts , "size" , DEFAULT_OPTIONS .size )
1432
+ if self .options .size == 200 :
1433
+ self .options .width = 25
1434
+ self .options .height = 8
1435
+ self .split_point = 11
1436
+ hardware_split = False
1437
+ elif self .options .size < 0 : # test hardware split
1438
+ self .options .width = 16
1439
+ self .options .height = 8
1440
+ self .split_point = - self .options .size
1441
+ hardware_split = True
1442
+ else : # if self.options.size == 128:
1443
+ self .options .width = 16
1444
+ self .options .height = 8
1445
+ self .split_point = None
1435
1446
1436
1447
# Note: The default below is what is determined by size above.
1437
1448
# Overriding hardware_split is only useful for 128 user testing 200 behavior
@@ -1477,10 +1488,11 @@ def __init__(self):
1477
1488
self .scale = vec2 (64.0 )
1478
1489
1479
1490
self .board_w = self .options .width
1491
+ self .board_h = self .options .height
1480
1492
self .board_sz = ivec2 (self .board_w , self .board_h )
1481
1493
self .screen_w = self .board_w * self .scale .x
1482
1494
self .screen_h = self .board_h * self .scale .y + self .menu_sz + self .status_sz
1483
- self .button_sz = self . screen_w / self . board_w
1495
+ self .button_sz = 64
1484
1496
self .screen_sz = ivec2 (self .screen_w , self .screen_h )
1485
1497
1486
1498
self .lowest_note = None # x,y location of lowest note currently pressed
@@ -1823,6 +1835,14 @@ def __init__(self):
1823
1835
self .setup_rpn ()
1824
1836
# self.test()
1825
1837
1838
+ self .leds = None
1839
+ # try:
1840
+ # from src.leds import LEDGridInterface
1841
+ # self.leds = LEDGridInterface()
1842
+ # print("LEDs initialized")
1843
+ # except Exception as e:
1844
+ # print("LEDs not initialized: ", e)
1845
+
1826
1846
def midi_mode_rpn (self , on = True ):
1827
1847
if on :
1828
1848
self .rpn (0 , 1 if self .is_mpe () else 0 )
@@ -2357,6 +2377,10 @@ def render(self):
2357
2377
sz = self .screen_w / self .board_w
2358
2378
y = 0
2359
2379
rad = int (sz // 2 - 8 )
2380
+ T = pygame .time .get_ticks ()/ 1000
2381
+
2382
+ if self .leds :
2383
+ self .leds .clear (BLACK )
2360
2384
2361
2385
for row in self .board :
2362
2386
x = 0
@@ -2376,12 +2400,36 @@ def render(self):
2376
2400
# else:
2377
2401
# col = self.get_color(x, y)
2378
2402
lit_col = ivec3 (255 , 0 , 0 )
2379
- unlit_col = copy .copy (self .get_color (x , y ) or ivec3 (0 ))
2403
+ col = self .get_color (x , y ) or ivec3 (0 )
2404
+ unlit_col = copy .copy (col )
2380
2405
black = unlit_col == ivec3 (0 )
2381
2406
inner_col = copy .copy (unlit_col )
2382
2407
for i in range (len (unlit_col )):
2383
2408
unlit_col [i ] = min (255 , unlit_col [i ] * 1.5 )
2384
2409
2410
+ if self .leds :
2411
+ if cell :
2412
+ lit = glm .vec3 (1 ,1 ,1 )
2413
+ self .leds .put (lit , x , y )
2414
+ # self.leds.put(red, x*2+1, y*2)
2415
+ # self.leds.put(red, x*2+1, y*2+1)
2416
+ # self.leds.put(red, x*2, y*2+1)
2417
+ else :
2418
+ colf = glm .vec3 (col .x / 255 , col .y / 255 , col .z / 255 )
2419
+ # # change saturation
2420
+ # r, g, b = colf.x, colf.y, colf.z
2421
+ # h, s, v = colorsys.rgb_to_hsv(r, g, b)
2422
+ # # if v > 0.1:
2423
+ # # h = (h + T * 0.1) % 1.0
2424
+ # # h, s, v = color_grade_hsv((h, s, v))
2425
+ # r, g, b = colorsys.hsv_to_rgb(h, s, v)
2426
+ # colf = glm.vec3(r, g, b)
2427
+
2428
+ self .leds .put (colf , x , y )
2429
+ # self.leds.put(colf, x*2+1, y*2)
2430
+ # self.leds.put(colf / 2, x*2+1, y*2+1)
2431
+ # self.leds.put(colf / 2, x*2, y*2+1)
2432
+
2385
2433
ry = y + self .menu_sz # real y
2386
2434
# pygame.gfxdraw.box(self.screen.surface, [x*sz + b, self.menu_sz + y*sz + b, sz - b, sz - b], unlit_col)
2387
2435
rect = [x * sz + b , self .menu_sz + y * sz + b , sz - b , sz - b ]
@@ -2476,6 +2524,9 @@ def render(self):
2476
2524
x += 1
2477
2525
y += 1
2478
2526
2527
+ if self .leds :
2528
+ self .leds .draw ()
2529
+
2479
2530
# if self.gamepad:
2480
2531
# pos = self.gamepad.positions()
2481
2532
# # gp_pos.y = self.board_h - y - 1
0 commit comments