Jump to content

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


Recommended Posts

Posted (edited)

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

Edited by ranger930
  • ranger930 changed the title to Mios8 with C, initial read all inputs once after the start of mios automaticly ?
Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...