Mios8 with C, initial read all inputs once after the start of mios automaticly ?

Hello mios friends,

I have a midi controller based on a PIC18F452 and have programmed it in C.
Is there a routine after starting the operating system that can read all inputs once and send the determined values as midi out (without turning a potentiometer or pressing a button)?

br ranger930

Hi,

you could send values from the Tick() hook - by using a static variable you can ensure that the values will only be sent once after startup.

Something like this (untested code)

///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS in the mainloop when nothing else is to do ///////////////////////////////////////////////////////////////////////////// void Tick(void) \_\_wparam { static unsigned char ain\_sent = 0; if( ain\_sent == 0 ) { unsigned char pin; unsigned char num\_ain = MIOS\_AIN\_NumberGet(); ain\_sent = 1; // only sent once after startup for(pin=0; pin \< num\_ain; ++pin) { MIOS\_MIDI\_TxBufferPut(0xb0); // CC at channel 1 MIOS\_MIDI\_TxBufferPut(pin); // pin number corresponds to CC number MIOS\_MIDI\_TxBufferPut(MIOS\_AIN\_Pin7bitGet(pin)); } } }

Best Regards, Thorsten.