piku
March 3, 2011, 2:37am
1
i’m building a little light installation with leds controlled via midi
i programmed the firmware following the C examples given by thorsten
the problem is that sometimes some leds remain on due to bad midi transmission, since i’m using a wireless midi device (cme widi)
i’d like to make the firmware able to set alwais the leds off after some seconds
let’s say .. a led doesn’t receive his midi note off message, so it remain lighten, what i want some counter algorithm that turn a led off after 2 seconds.
can someone give me saome examples i can follow?
i have no programming skills!!
piku
March 4, 2011, 3:49pm
2
mmmh .. ok
i used some suggestions i found here:
http://discourse.midibox.org/t/topic/13239
for now the leds of all my 8 shift registers are turned all off after 250 ms since the last note on received…
i used a global variable called “timerled”
ad every note on received it is turned to 0
and everytime it reaches 250 all led are set to 0
this is how the thing works
void SR_Service_Prepare(void) __wparam
{
if( ++timerled >= 250 ) {
timerled = 0;
MIOS_DOUT_SRSet(0,0x00);
MIOS_DOUT_SRSet(1,0x00);
MIOS_DOUT_SRSet(2,0x00);
MIOS_DOUT_SRSet(3,0x00);
MIOS_DOUT_SRSet(4,0x00);
MIOS_DOUT_SRSet(5,0x00);
MIOS_DOUT_SRSet(6,0x00);
MIOS_DOUT_SRSet(7,0x00);
}
}
now.. i repeat i have no programming skills
what i need now is a way to make the same work but for every single led
i thougt i have to use a multiple variabe like " unsigned char timerled[64] "
but do i have to repeat the “if” code 64 times???
is there an intelligent way to do this?
i mean .. how do i have to configure the code for a multiple variable in the SR_Service_Prepare section??
piku
March 4, 2011, 7:41pm
3
ahahah well..
it’s funny that it seems some kink of monologue but…
i finally found the final solution
i set two variables:
unsigned char timerled[64];
unsigned char actualed;
each time a note on i received , the corresponding led is set to ON and his timer is set to 0…
then.. in the SR_Service_Prepare section:
if ( ++actualed >= 64 ) {
actualed = 0;
}
if ( ++timerled[actualed] >= 16 ) {
MIOS_DOUT_PinSet(actualed, 0);
timerled[actualed] = 0;
}
so each led has a fixed duration…
thanks to the forum anyway!! ahaha
T.K
March 6, 2011, 9:22pm
4
Congrats - you mastered the first step of the MIDIbox code wizard diploma!
Best Regards, Thorsten.