Jump to content

led time counter help


piku
 Share

Recommended Posts

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!!

Link to comment
Share on other sites

mmmh .. ok

i used some suggestions i found here:

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??

Link to comment
Share on other sites

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 :tongue:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...