marioguzzi Posted October 31, 2009 Report Share Posted October 31, 2009 Hi, 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 Quote Link to comment Share on other sites More sharing options...
TK. Posted October 31, 2009 Report Share Posted October 31, 2009 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. Quote Link to comment Share on other sites More sharing options...
marioguzzi Posted October 31, 2009 Author Report Share Posted October 31, 2009 thank you Thorsten, both for the reply and for MIDIBOX :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.