introduced lookup table for led ring cw

This commit is contained in:
Sebastian
2025-05-28 01:41:12 +02:00
parent 686f76b0fd
commit cd1b0934aa
2 changed files with 37 additions and 9 deletions

View File

@ -22,6 +22,8 @@ PWMAudio ui_snd(8);
enum BUTTON {CVINL, CVINR, INL, INR, OUTR, OUTL, CVOUTR, CVOUTL, RIGHT, LEFT, SELECT, DEBUG1, DEBUG2, DEBUG3};
int lut_ring_cw[48] = {39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,50,49,48,47,46,45,44,43,42,41,40};
CRGB ui_leds[74];
CRGB edge_leds[11];
@ -199,6 +201,11 @@ void loop() {
ui_leds[i + 3] = CRGB(0, 0, 0);
}
// Rotary button LEDs
ui_leds[0] = CRGB(0, 0, 0);
ui_leds[1] = CRGB(0, 0, 0);
ui_leds[2] = CRGB(0, 0, 0);
// flag = true when a button is pushed
if (flag) {
int val = TCA.read16();
@ -221,9 +228,14 @@ void loop() {
}
// Flash led ring
for (int i = 0; i < 48; i++) {
ui_leds[i + 3] = CRGB(0, 15, 0);
}
// for (int i = 0; i < 48; i++) {
// ui_leds[i + 3] = CRGB(0, 15, 0);
// }
// Flash encoder leds
ui_leds[0] = CRGB(0, 100, 50);
ui_leds[1] = CRGB(0, 100, 50);
ui_leds[2] = CRGB(0, 100, 50);
// Switch through LED matrix
if(buttons[RIGHT]) active++;
@ -234,10 +246,6 @@ void loop() {
flag = false;
}
// Rotary button LEDs
ui_leds[0] = CRGB(0, 0, 15);
ui_leds[1] = CRGB(0, 0, 15);
ui_leds[2] = CRGB(0, 0, 15);
// empty LED matrix
for (int i = 0; i < 13; i++) {
@ -251,9 +259,12 @@ void loop() {
active_led_ring = (position / 32) % 48;
// set active LED ring LED
ui_leds[active_led_ring + 3] = CRGB(255, 255, 255);
for(int i = 0; i < active_led_ring; i++){
ui_leds[lut_ring_cw[i]] = CRGB(50, 0, 25);
}
FastLED.show();
delay(1); // wait 1ms
}
}

17
tools/index_luts.py Normal file
View File

@ -0,0 +1,17 @@
leds = []
for i in range(3,51):
leds.append(i)
leds_first = leds[0:37]
leds_first.reverse()
leds_last = leds[37:48]
leds_last.reverse()
leds_yeah = leds_first + leds_last
print("int lut_ring_cw[48] = {", end="")
for i in range(0,48):
if i < 47:
print(leds_yeah[i], end=",")
else:
print(leds_yeah[i], end="")
print("};", end="")
print()