From cd1b0934aa536b6d48b5492d775dff9ace06a639 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 28 May 2025 01:41:12 +0200 Subject: [PATCH] introduced lookup table for led ring cw --- soundcube-firmware/soundcube-firmware.ino | 29 ++++++++++++++++------- tools/index_luts.py | 17 +++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 tools/index_luts.py diff --git a/soundcube-firmware/soundcube-firmware.ino b/soundcube-firmware/soundcube-firmware.ino index 36dd8ce..c65e694 100644 --- a/soundcube-firmware/soundcube-firmware.ino +++ b/soundcube-firmware/soundcube-firmware.ino @@ -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 -} \ No newline at end of file +} + diff --git a/tools/index_luts.py b/tools/index_luts.py new file mode 100644 index 0000000..6589305 --- /dev/null +++ b/tools/index_luts.py @@ -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()