I’m planning to develop an application that reacts to note-on midi messages to trigger dout pins for a fixed time, using the Timer or Tick function seems the way to go but being not really a coder I’m a bit confused on the approach to use.
Any idea?
I tried searching the forum but it seems the search engine is not working
Define an array which contains counter variables for each individual DOUT pin:
// in this example for up to 16 pins
#define NUM_DOUT_DELAY_CTR 16
unsigned char dout_delay_ctr[NUM_DOUT_DELAY_CTR];
[/code]
initialize these counters in Init():
[code]
void Init(void) \_\_wparam
{
unsigned char i;
for(i=0; i\<NUM\_DOUT\_DELAY\_CTR; ++i)
dout\_delay\_ctr[i] = 0;
// ...remaining init stuff...
Add following code to SR_Service_Finish():
void SR_Service_Finish(void) __wparam
{
unsigned char i;
for(i=0; i<NUM_DOUT_DELAY_CTR; ++i)
if( dout_delay_ctr[i] && --dout_delay_ctr[i] == 0 ) {
MIOS_DOUT_PinSet(i, 0);
}
}
[/code]
done!
Whenever you set a pin, set "dout\_delay\_ctr[pin]" to a value between 1..255
This value defines the delay in mS after which the DOUT pin will be cleared again.
Best Regards, Thorsten.