led programming.... pc interface

How should i program the leds so that for each different midi note coming from the pc a different led lights? I have 128 leds connected to core.

I tested ain64_din128_dout128 and works fine, so I would like to do the same from the pc now

Basically i want to build a software ( hope that I find one free :slight_smile: ), to trigger an led according to outputs selected, from 0-127

Thanks a lot

Have you looked at the function reference and C skeleton?

MPROC_NotifyReceivedEvent

MIOS_DOUT_PinSet

That’s all ya need

thanks, working nearly as i want it but…

I wrote the following;

/////////////////////////////////////////////////////////////////////////////

// This function is called by MIOS after startup to initialize the

// application

/////////////////////////////////////////////////////////////////////////////

void Init(void) __wparam

{

  // set shift register update frequency

  MIOS_SRIO_UpdateFrqSet(1); // ms

  // only one DOUTX4 module is connected

  // the maximum value is 16 (-> 128 digital outputs)

  MIOS_SRIO_NumberSet(16);

}

/////////////////////////////////////////////////////////////////////////////

//  This function is called by MIOS when a complete MIDI event has been received

/////////////////////////////////////////////////////////////////////////////

void MPROC_NotifyReceivedEvnt(

  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2, unsigned char pin, unsigned char value) __wparam

{

  // a note event provides 128 different note values (0..127)

  // in this simple example, each note sets an individual pin

  // for DOUT pin numbers, see also this documentation:

  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!

    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)

    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off

      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On

      MIOS_DOUT_PinSet(pin, 1);

    }

  }

}

and every note I send I get the same first led to light only. Can I modify the code so that each led corresponds to a different note?

Thanks

I’ve hardly started on the programming side but the bit where you turn on the LED..

->  MIOS_DOUT_PinSet(pin, 1);

You don’t seem to have set the ā€˜pin’ variable from the note number?

most probably i need to write code for each led to correspond to each note. Still got no idea haw to do it, but will try.

Thanks

void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2, unsigned char pin, unsigned char value) __wparam

Hah where did ya get that from? should look like this:

void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam

then do:

MIOS_DOUT_PinSet(evnt1, 1)

not working… now no led’s light

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!

    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)

    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off

      MIOS_DOUT_PinSet(evnt1, 0);

    } else {

      // Note On

      MIOS_DOUT_PinSet(evnt1, 1);

No idea how or what’s happening :frowning:

how many leds do you have attached?

i.e. if you have all 128 outputs attached via the DOUTX4s try moving the cable to the various outputs

and isn’t that code exactly what’s in ain64_din128_dout128_v2_0.zip anyway?

Well, posting in year-old threads may not help, especially when they already put the answer there :wink:

Cross-posting like that is generally considered bad netiquette, it just creates confusion…

Maybe you should try some troubleshooting… Try hardcoding a value in there…

MIOS_DOUT_PinSet(32, 1);

sorry about posting.. i deleted it.

Yes I already tried hardcoding before like this

// Note Off
      MIOS_DOUT_PinSet(2, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(2, 1);

It works when I send a midi note, turns on led 3 and off straightaway.

I am sending midi notes from the keyboard on MIOS studio, that’s ok to test?

You don’t seem to have set the ā€˜pin’ variable from the note number?

Speaking of which- I was looking at some of Thorsten’s ā€œProgramming Examplesā€ from the bottom of the MIOS C interface page the other night, and there’s an example which seems to do the same thing (I couldn’t find the link between the incoming note # and the ā€œpinā€ variable used for the DOUT call). IIRC, I had seen the missing part in one of his other apps or examples, so maybe the example snippet was pulled from one of them.

Take Care

When I program this line

MIOS_DOUT_PinSet(pin, 0);

exactly as in the programming example it gives an error when compiling. Is the programming example incomplete? or am I missing something?

I will try to modify ain64_din128_dout128 as someone posted in this thread [tt]http://www.midibox.org/forum/index.php?topic=5034.15[/tt]

Will let you know

Thanks

or am I missing something?

Yeh, you forgot to put the error in your post :wink:

When trying to code this ’ Controlling 128 LEDs VIA midi ’ example

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS after startup to initialize the 
// application
/////////////////////////////////////////////////////////////////////////////
void Init(void) __wparam
{
  // set shift register update frequency
  MIOS_SRIO_UpdateFrqSet(1); // ms

  // only one DOUTX4 module is connected
  // the maximum value is 16 (-> 128 digital outputs)
  MIOS_SRIO_NumberSet(16);
}


/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{
  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(pin, 1);

    }
  }
}

I get

main.c:83: error 20: Undefined identifier ā€˜pin’

main.c:83: error 20: Undefined identifier ā€˜pin’

main.c:88: error 20: Undefined identifier ā€˜pin’

main.c:88: error 20: Undefined identifier ā€˜pin’

Thanks

Wel that’ll be because it’s not defined.

This is the same answer that you have been given before in this thread and that you saw in the other thread.

Use evnt1 like instructed before, or try this:

/////////////////////////////////////////////////////////////////////////////
//  This function is called by MIOS when a complete MIDI event has been received
/////////////////////////////////////////////////////////////////////////////
void MPROC_NotifyReceivedEvnt(
  unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
{

unsigned char pin;

pin = evnt1;

  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet(pin, 0);

    } else {

      // Note On
      MIOS_DOUT_PinSet(pin, 1);

    }
  }
}

I would also recommend that you read The C Book, you can find it with a search of the forums here.

Stryd,

is the new SDCC release allowing you declare vars properly now, rather than just at the top?

THANKS stryd_one… I got something working at last!!!

Now the led’s are following the velocity setting. Now I need to set them to turn off and not stay ON.

I will do as you’re suggesting and read more in detail.

Somehow my final project is to connect 12 cores with 128leds each at a distance between them so that I could fire a show.

You think that’s possible? 

THANKS, thanks

Wicked :slight_smile: If it works for velocity, then it will be using evnt2, so just replace that with for evnt1, and it will be using the note number :slight_smile:

Dave: Nope :frowning: I’m still wanting to find time to try --extended :wink: … and find a version of the doc old enough to tell me what --fstack was before they removed it hehehe

Can you post your working Code here ?

Im very interested in it :slight_smile:

Regards

My DOUT is wired to core J8, correct?

tried evnt0, evnt1, evnt2 but all i can get is velocity to trigger led’s

This code turns ON led 0 and OFF

  // a note event provides 128 different note values (0..127)
  // in this simple example, each note sets an individual pin
  // for DOUT pin numbers, see also this documentation:
  // http://www.ucapps.de/mios/mios_pin_list.txt

  if( evnt0 == 0x80 || evnt0 == 0x90 ) {

    // 90 xx 00 is the same like a note off event!
    // (-> http://www.borg.com/~jglatt/tech/midispec.htm)
    if( evnt0 == 0x80 || evnt2 == 0x00 ) {

      // Note Off
      MIOS_DOUT_PinSet0(evnt0);

    } else {

      // Note On
      MIOS_DOUT_PinSet1(evnt0);

    }
  }
}

and this turns ON but never OFF the corresponding led with velocity…

      // Note Off
      MIOS_DOUT_PinSet0(evnt2);

    } else {

      // Note On
      MIOS_DOUT_PinSet1(evnt2);