Jump to content

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


ranger930
 Share

Recommended Posts

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
Link to comment
Share on other sites

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

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.

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