understanding the .ngc code

I am getting to grips with the code however, can someone enlighten me on the last section of this example string>

EVENT_BUTTON id=1 type=NoteOn key=36 lcd_pos=1:1:1 label=“Button #%3i: %3d”    what is this section referencing/meaning?   #%3i: %3d

so when i look at this i see

(EVENT_BUTTON id=1)   the button id is 1 this is the first button on D0

(type=NoteOn key=36)     the midi event it is producing is a note on key value 36

(lcd_pos=1:1:1)   it is shown on lcd 1, line 1, (what is the 3rd 1 for?)

(label=“Button #%3i: %3d” )   and you got me here… no clue!!

 

Thanks

Here is the reference:

http://ucapps.de/midibox_ng_manual_ngl.html

Quote

  • %d: will output the value (minus specified offset) in decimal format
  • %u: same like %d, but value always in unsigned format
  • %x: will output the value (minus specified offset) in hexadecimal format
  • %X: same like %x, but with capital letters
  • %c: will output the value as character
  • %s: will output an empty string. In conjunction with padding values it could save some memory, e.g. “%20s” will output 20 spaces
  • %i: the ID of the EVENT
  • %p: for EVENT_BUTTON_MATRIX only: the pin number of the matrix
  • %e: the MIDI event of the EVENT (up to 3 hexadecimal values, always 6 characters)
  • %m: the minimum value of the EVENT which has been specified with range
  • %M: the maximum value of the EVENT which has been specified with range
  • %b: a binary digit: * if value >= (range/2), o if value < (range/2)
  • %B: a vertical bar which works like a meter.
    In conjunction with various fonts (selected with &<font>) alternative icons will be output instead.
  • %q: current selected bank (q is a rotated b - do you see it? :wink:
  • %C: clear all LCDs
  • %%: outputs the % character

It’s possible to format the output by adding following specifiers after the percent (%) character. In following example the %d (decimal value) is used, but this works with any format type:

  • %3d: the value will be padded with spaces to 3 characters, and it will be output right-aligned, e.g. " 1", " 10", “100”
  • %-3d: the value will be padded with spaces to 3 characters, and it will be output left-aligned, e.g. "1 ", "10 ", “100”
  • %03d: the value will be padded with zeroes to 3 characters, and it will be output right-aligned, e.g. “001”, “010”, “100”

 

ok so this is:

%3i** ** The “i” is the id of the event as stated above ( %i: the ID of the EVENT ) and the %3i means the event will be padded with spaces to 3 characters

%3d This is also padded with spaces to 3 characters

I do not have a completed MB_NG here to try this so I am guessing in the dark on this so bear with me.

Please define “padding” as i find no reference to its meaning. 

 

Padding would define the number of spaces; the width of each is defined by the font in use or simply a blank character if such an OLED or LCD was used. I also haven’t messed around with .NGL files.

its a section not properly explained in the info, this is the first time i have taken a look at the NG.  so does %3 mean there are 3 spaces before the display shows a character? I have ordered a brick to hit myself over the head at some point to try and understand this! lol

most of the code is ok to understand its actually simpler than the old assembly on the older cores. its just some of this syntax use to define variables to the end of the statement.

 

ok after talking with latigid on it seems the penny dropped

so, EVENT_BUTTON id=1 type=NoteOn key=36 lcd_pos=1:1:1 label="Button #%3i: %3d

1: EVENT_BUTTON id=1  this references the button on sr=1 (shift register 1 pin D0)

2: type=NoteOn key=36    this references the midi event generated (midi noteon key=36, this has a range of 0-127)

3:  lcd_pos=1:1:1     This references the lcd say a 2x20   (the first 1 references the first lcd connected, the second “1” references the first line of the lcd the “upper line”, the third “1” is the starting character of the lcd and the generated text of the event name mapped tothe button)

4: #%3i: %3d     this references the spacing"padding" of the characters in the display (%3i is a padding of “3” before the event id “i”  and the %3d is also referencing padding)

 

Once my core arrives i can play around with this to get a better understanding however if i were to change the string to this #%2i %2d the padding woud be of two characters spacing

%i is the event-id   %d is the value so if the value is 54 it will show “54” as the value, then the lcd displays (noteon    54) on the lcd.

A couple of days in and its sinking in, thanks again for the help

 

 

 

 

 

 

 

I am also wondering about condition lables 

COND

CONDitional labels are the most powerful purpose of global label definitions - they allow to output different strings based on the EVENT value!

Following example demonstrates the purpose pretty nicely:

<tt>COND_LABEL fil_type
COND =0 "Bypass "
COND =1 "LP 24dB "
COND =2 "LP 12dB "
COND =3 "BP 24dB "
COND =4 "BP 12dB "
COND =5 "HP 24dB "
COND =6 "HP 12dB "
COND =7 "Notch24dB"
COND =8 "Notch12dB"
COND =9 "Comb+ "
COND =10 "Comb- "
COND =11 "PPG LP "
COND_ELSE "Type %3d "
</tt>

An EVENT_* command can use it this way:

<tt># this command is part of a .NGC file:
EVENT_ENC id=1 type=CC cc=16 lcd_pos=1:1:1 label="Filter Type: ^fil_type"
</tt>

How does this line call say COND =8 “Notch12dB”?

Really enjoying this code, its easier to understand than assembly was for me, i showed my work colleage today who still uses delphi for some of our test software and he said it had some similarities to delphi.

I dare say i will have a couple more questions as i go, but as i learn i will put up diagrams to show what I have learned and its use and effects to help new members who also want to learn the code for the NG.

I printed out all of the user manual files for first steps, ngc, ngl, ngr etc as it makes it easier to sit and read instead of staring at the computer screen besides, i like to be able to highlight or mark something thats relevent and i need to try.

On a plus point my boards arrived from Modular addict today, Gotta order a couple more though but now i can start on the new motorfader module.

I understand the padding now, but its how it is used for the %3i if it is displaying a button label of Noteon what is the 3 for? in the %3i at the beginning of #%3i %3d (edit: there are 3 spaces after the noteon text) i understand the #%3i %3d function now

really enjoying this code

EVENT_BUTTON id=1 type=NoteOn key=36 lcd_pos=1:1:1 label=“Button #%3i: %3d”  the simplicity of defining a buttons name and the value etc. push the button and “Button” is displayed on the lcd along with its value of 36.

im now looking at the addition of a sysex command mapped to the button.

Also with regards to the small SSD1306 displays, the software i use uses sysex to talk to them,

here is the sysex from the midi implementation section of the manual

Value Bar Received:

B0, 3i, vv i Value bar number (0 thru 7) vv value (0 to 7F)

B0, 3i, mm i Value bar number offset by 8 (8 thru 15) mm Value bar mode (0: normal, 1: bipolar, 2: fill, 3: spread, 4: off)

B0, 4i, vv i Value bar number (0 thru 7) for strip 9-16 vv value (0 to 7F)

B0, 4i, mm i Value bar number (8 thru 15) for strip 9-16 mm Value bare mode (0: normal, 1: bipolar, 2: fill, 3: spread, 4: off)

Scribble Strips

Addressing: Scribble Strip ID and Scribble Strip Line via SysEx:

Received:

Set Mode:

<SysExHdr> 13, xx, mn F7

xx = scribble strip id 0-7

m = bits 6 to 4 

• bit 4 = 0 - do not clear the strings/ redraw old strings in new mode

[<SysExHdr> 0x13, 0x01, 0x05 F7] - Changes display mode to Mode 5 and redraw old strings in new mode

• bit 4 = 1 - clear strings / new strings will be send and drawn in new mode [<SysExHdr> 0x13, 0x01,0x12 F7] - Changes display mode to Mode 2 and clears the old strings for Scribble Strip #1)

• bit 5 = unused • bit 6 = unused n = mode number (bits 3 to 0) 

 

Send String:

Send the text messages to the scribble strips. Received: <SysExHdr> 12, xx, yy, zz, tx,tx,tx,… F7

xx = scribble strip id 0-7

yy = line number 0-3

zz = alignment flag and normal/inverted

• flag bits xxxxiaa ( 0000000 = centered normal)

aa = alignment (center: 0, left: 1, right: 2)

i = inverted

x = not used

tx = text in ASCII format

Metering

Channel Pressure message (After Touch) for the peak and reduction meters.

Received:

Dn, vv

n meter address

• 0-7 peak meters 1-8

• 9-15 reduction meters 1-8

vv meter value (0…7F)

Peak meters decay automatically.

Reduction meters are set by the host only (no automatic decay).

Program Change message for the peak and reduction meters 9-16.

Cn, vv

n meter address

• 0-7 peak meters strip 9-16

• 9-15 reduction meters strip 9-16 vv meter value (0…7F)

Peak meters decay automatically. 100% decay in 1.8 seconds.

Reduction meters are set by the host only (no automatic decay).

Running Status The following message is should be sent every second: A0,00,0

 

SysEx

SysEx header <SysExHdr> F0 00 01 06 02
Manufacturer ID 00 01 06
16 fader Device ID 16
8 fader Device ID 02

Faders
Use MIDI pitch bend message to transmit fader moves and receive fader positions. FaderPort 8. Channels 0-7 are used to address faders 1-8 respectively. FaderPort 16. Channels 0-15 are used to address faders 1-16 respectively.

Received Ex, ll, hh
Trans m itted Ex, ll, hh
Fader index x
Low 7 bits ll
High 7 bits hh

Encoders

Use CC messages to transmit increment and decrement values. Transmitted endless rotary encoder delta values:
Pan / Param Encoder: B0, 10, xx
Session Navigator Encoder: B0, 3C, xx
xx delta value bit (Bit 6 = direction, Bits 0-5 = number of steps)

 

 

EDIT: Is it possible to have the glcd respond to the sysex coming in? i cant find where i assign a sysex recieve to a specific glcd. I understand the sysex i need it to recieve but how i assign say glcd 1 to recive the sysex: 

ignore the brackets etc they are just reference for the numbers

F0 00 01 06 02 ( xx 01) ( yy 01) (zz ??) (aa 00) does the ngc allow for asci text? is this in the documentation? the track name is “strings” in ascii its 115 116 114 105 110 103 115. How do i have the glcd recieve this for displaying the track name?

xx = scribble strip id 0-7

yy = line number 0-3

zz = alignment flag and normal/inverted

• flag bits xxxxiaa ( 0000000 = centered normal)

aa = alignment (center: 0, left: 1, right: 2)

i = inverted

x = not used

tx = text in ASCII format

 

I have printed everything out and i am going through it well, just a couple of things i cant find or know about. Its a jump from the old core8’s to this, mind you i havent been so excited by code in a long time.

 

 

How would you use fwd_to_lcd=<1|0> to forward the incoming sysex to a glcd?  If using the above sysex sent out from the software. As the label of the track is defined in the software daw, would you no longer use a “label” for this.?

Here is a string, I am not sure on the alignment flags ( zz ) can anyone explain the alignment flags to me? I am looking it up online also.

F0 00 01 06 02

xx = scribble strip id 0-7

yy = line number 0-3

zz = alignment flag and normal/inverted

• flag bits xxxxiaa ( 0000000 = centered normal)

aa = alignment (center: 0, left: 1, right: 2)

i = inverted

x = not used

tx = text in ASCII format

This is to the first glcd

 

F0 00 01 06 02 01 01 (zz) 01 115 116 114 105 110 103 115 F7

This is the first GLCD line 1 (i am learning about the flag bits) not inverted and the asci text “strings” closed with F7

 

 

Oh…( zz) . Convert binary to hex.. Lol sorry head fudge.

So, 0000/0110, the first 1 being

Invert 0=normal, 1=inverted

0000=center not inverted hex 00

0001=left not inverted hex 01

0010=right not inverted hex 02

Ok if I want a single glcd to show this how do I map this sysex string to the glcd when the software outputs it?

How do i set the software up so that this sysex string is sent to the glcd:

so the software sends this string  F0 00 01 06 02 01 01 02 01 115 116 114 105 110 103 115 F7  which is to the first glcd scribble display and the ascii text is “strings” and is centred

sysex header= F0 00 01 06 02

scribble number 1= 01

line number 1= 01

alignment flag centred = 00

ascii text 115 116 114 105 110 103 115 = strings

sysex close = F7

 

would i use fwd_to_lcd=<1|0> 

 

I am making a test interface with one motor fader, one glcd and a couple of buttons encoders and led’s so that i can get to grips with the code and using mios studio i want to test this by sending the string to the test box.

can anyone help me on this please?

My ssd displays turned up today. Looks like I got messed with.  These are not the ssd1306 glcds I needed. These have only 4 pins on, I’m guessing they are not compatible with the stm32f4. Anyone know if these will work or if I need to try and get the 16 pin parallel ssd displays?

Looks like an I2C interface. You want 4-wire SPI.

Hey latigid, i did order the alientek ones but this is what arrived, not a happy bunny.

Now i have to re-find the correct ones again.

 

I have spare ones in white and can sell them for 4€ each. PM if you’re interested.