Lunchtime so I can look into this and I think I see the issue now…checking.
Bingo! Got i!
midirx_enabled(1)
rgb = {
{255, 0, 0},
{125, 50, 0},
{100, 100, 100},
{200, 200, 200},
{0, 0, 0},
{0, 255, 0},
{255, 255, 255},
{50, 50, 250}
}
function set_color(cl)
for i = 0, 8, 1 do
led_color(i, 2, rgb[cl][1], rgb[cl][2], rgb[cl][3])
led_value(i, 2, 50)
end
end
The functions led_color()
and led_value()
do not need to be called with element[i]
as they already take parameters to indicate which element to address. Also, I needed to call led_value() so that the new color settings apply.
Tested on mine as working.
Full proper code:
-- 'Init tab'
midirx_enabled(1)
rgb = {
{255, 0, 0},
{125, 50, 0},
{100, 100, 100},
{200, 200, 200},
{0, 0, 0},
{0, 255, 0},
{255, 255, 255},
{50, 50, 250}
}
function set_color(cl)
for i = 0, 7, 1 do
led_color(i, 2, rgb[cl][1], rgb[cl][2], rgb[cl][3])
led_value(i, 2, 50)
end
end
-- 'MIDI rx' tab
local ch, cmd, param1, param2 = midi.ch, midi.cmd, midi.p1, midi.p2
if cmd == 176 and ch == 0 and param1 == 4 then
set_color(param2)
else
end
To add to this, delete all blocks in both ‘Init’ and ‘MIDI rx’ on the ‘System’ element. Create a new ‘Code’ block in each and copy the appropriate snippets of code.