Jump to content

BLM16x16 optimized LED pattern transfer


Phatline
 Share

Recommended Posts

I am not clear what the optimized LED-Pattern Transfair is, the Readme says:

host updates all LEDs by sending CC events (Bn ..)

CC messages? can you give me a example? Do i need sysex handshakes 4 that, or can i simple send a CC,

i have a Array of Variables, call it Matrix{16[[16], ok now i want to transfair the whole data from one Core32 to the BLM Core32 (via Midi.)

-ok, up to now I send single Note Events for every cell, like this:

u8 CCoutPort = 32;
u8 counter = 0;
u8 Matrix[16][16] = {{}}
for(Counter=0; Counter<16; Counter  ) {
               MIOS32_MIDI_SendNoteOn(CCoutPort,0,  Counter, Matrix[0][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,1,  Counter, Matrix[1][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,2,  Counter, Matrix[2][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,3,  Counter, Matrix[3][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,4,  Counter, Matrix[4][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,5,  Counter, Matrix[5][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,6,  Counter, Matrix[6][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,7,  Counter, Matrix[7][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,8,  Counter, Matrix[8][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,9,  Counter, Matrix[9][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,10, Counter, Matrix[10][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,11, Counter, Matrix[11][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,12, Counter, Matrix[12][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,13, Counter, Matrix[13][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,14, Counter, Matrix[14][Counter]);
               MIOS32_MIDI_SendNoteOn(CCoutPort,15, Counter, Matrix[15][Counter]);  } 

and with this i can see coming the LEDs from Left to right...

 

The Stripped Down Readme:

Quote

MIDI Protocol
~~~~~~~~~~~~~

  All numbers in hexadecimal format!
  <row>: 0..F (coded into MIDI channel)
  <column>: 00..0F (Note Number)
  <button-state>: 00: depressed, 7F: pressed
  <colour>: 00: off, 20: green colour only, 40: red colour only, 7F: all colours (Decimal 32, 64,127)
  <fader>: 00..0F (coded into MIDI channel)


Received LED events (single access):
+---------------------------------------+-----------------------------+
| BLM16x16 LEDs                         | 9<row> <column> <colour>    |
| Extra column LEDs                     | 9<row> <40+column> <colour> |
| Extra row LEDs                        | 90 <60+column> <colour>     |
| Additional extra LEDs (e.g. Shift)    | 9F <60+function> <colour>   |
+---------------------------------------+-----------------------------+

BLM16x16 optimized LED pattern transfer (prefered usage):
+-----------------------------------------------+---------------------+
| column LEDs 0..6, green colour, 8th LED off   | B<row> 10 <pattern> |
| column LEDs 0..6, green colour, 8th LED on    | B<row> 11 <pattern> |
| column LEDs 8..14, green colour, 16th LED off | B<row> 12 <pattern> |
| column LEDs 8..14, green colour, 16th LED on  | B<row> 13 <pattern> |
+-----------------------------------------------+---------------------+
| column LEDs 0..6, red colour, 8th LED off     | B<row> 20 <pattern> |
| column LEDs 0..6, red colour, 8th LED on      | B<row> 21 <pattern> |
| column LEDs 8..14, red colour, 16th LED off   | B<row> 22 <pattern> |
| column LEDs 8..14, red colour, 16th LED on    | B<row> 23 <pattern> |
+-----------------------------------------------+---------------------+

Communication
~~~~~~~~~~~~~
   - host requests layout informations with F0 00 00 7E 4E 00 00 F7
   - this application replies with F0 00 00 7E 4E 00 01 ... F7 to send back the
     available number of buttons and LEDs
   - host updates all LEDs by sending CC events (Bn ..)

As long as no MIDI data has been received after startup, the BLM is in test mode.
The buttons cycle the colour of the corresponding LED:
   - first button press: green colour
   - second button press: red colour
   - third button press: both colours
   - fourth button press: all LEDs off
   - period

===============================================================================

 

 

From [16][16] Array to CC - whats the way?

thnx for tips, and explaination - phat.

Link to comment
Share on other sites

Let me separate the BLM communication handler from MBSEQ and provide it as a driver, this will simplify the handling dramatically at your side (and hopefully won't raise up too many unnecessary questions which are actually already answered in the MBSEQ source code ;-)

I will try this later today, hopefully without unexpected issues.

Best Regards, Thorsten.

Link to comment
Share on other sites

Alright, the BLM_SCALAR_MASTER driver is available now, an integration example can be found under apps/examples/blm_scalar_communication: http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fexamples%2Fblm_scalar_communication%2F

I've integrated the same driver into MBSEQ V4, and it's working - the code looks much more readable now (which was my motivation... :)

Back to the example:
I would propose that you build blm_scalar_communication and test it at your side first to ensure that the basis is working.
You've to adapt the BLM_SCALAR_MASTER_MIDI_PortSet() assigment if you are not using OUT3/IN3 (resp. UART2) as communication port.

The next step is to understand the example code in APP_BLM_ButtonCallback() which shows, how to handle received button events, and how to control the LEDs.

The actual MIDI communication to the BLM works "automagically" in background, driven by TASK_Period1mS(), which calls BLM_SCALAR_MASTER_Periodic_mS().
This function (located in modules/blm_scalar_master/blm_scalar_master.c) looks complicated, but this is due to some performance improvement measures to ensure high-speed transfers to the BLM. Actually you don't need to look into the BLM_SCALAR_MASTER driver, it just works...

You've to decide by yourself, if it's better to integrate your existing code into this example, or if you want to try to transfer the example code into your application. I won't be able to help you on this - I can only show you, how it works at my side.

Best Regards, Thorsten.

Link to comment
Share on other sites

GREAT!

DANKEx1000 :love:

 

when i want to transfair a Matrix, ís there a better way then this:  ? (@ least it work on my machine)

  if( element_id == BLM_SCALAR_MASTER_ELEMENT_SHIFT ) {
    u8 counter = 0;
    for(counter=0; counter<16; counter++){
        BLM_SCALAR_MASTER_LED_Set(0, 0, 0, counter,  MtxPart[0][0][counter]); //(blm, element_id, button_x, button_y, new_colour);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 1, counter,  MtxPart[0][1][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 2, counter,  MtxPart[0][2][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 3, counter,  MtxPart[0][3][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 4, counter,  MtxPart[0][4][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 5, counter,  MtxPart[0][5][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 6, counter,  MtxPart[0][6][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 7, counter,  MtxPart[0][7][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 8, counter,  MtxPart[0][8][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 9, counter,  MtxPart[0][9][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 10, counter, MtxPart[0][10][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 11, counter, MtxPart[0][11][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 12, counter, MtxPart[0][12][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 13, counter, MtxPart[0][13][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 14, counter, MtxPart[0][14][counter]);
        BLM_SCALAR_MASTER_LED_Set(0, 0, 15, counter, MtxPart[0][15][counter]);}
        }

 

Link to comment
Share on other sites

If it works don't change it too much, focus your ideas instead!
The STM32F4 microcontroller has more than enough horse power to handle unoptimized code; and optimization could mean that it will be more difficult for you to integrate changes (without writing more questions in the forum than writing code into the .c file... ;-)

Only minor complaints: you could add a for-loop for the row, and I would call the variables "x" and "y" so that it's clear (by reading the code) what should be done:

  if( element_id == BLM_SCALAR_MASTER_ELEMENT_SHIFT ) {
    int y;
    for(y=0; y<16; y++){
        int x;
        for(x=0; x<16; x++) {
          BLM_SCALAR_MASTER_LED_Set(0, 0, x, y,  MtxPart[0][x][y]); //(blm, element_id, led_x, led_y, colour);
        }
    }
  }

Best Regards, Thorsten.

Link to comment
Share on other sites

nice

compact code.

i only ask, because, i thougt there is a optimized transfair-methode for the Matrix, by transfairing row-wise in some kind of pattern... and because i have to rewrite the code so or so. (what is good idea anyway)

by analyze?g existing code e.g. a monster like SEQ - - for that i am to much newbee, i feel/think i got everything i need to do my job from here with your tutorial/explaination/documentation that you have made - very cool. :cheers:

 

Link to comment
Share on other sites

The optimization takes place in BLM_SCALAR_MASTER, so that you can now work at a higher level where execution speed doesn't matter anymore.

MBSEQ is a different story - the SEQ_BLM code is a critical element since it is running in parallel to many other UI processes, therefore I had to spent more effort into the optimization (e.g. I had to access variables directly - which is dangerous for programmer newbies because of potential hard faults!)

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