ssp

understanding the .ngc code

113 posts in this topic

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

Share this post


Link to post
Share on other sites

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? ;-)
  • %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"

 

Share this post


Link to post
Share on other sites

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. 

 

Edited by ssp

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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

 

 

 

 

 

 

 

Edited by ssp
it clicked ')

Share this post


Link to post
Share on other sites

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:

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 "

An EVENT_* command can use it this way:

# 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"

How does this line call say COND =8 "Notch12dB"? 

 
Edited by ssp

Share this post


Link to post
Share on other sites

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.

Edited by ssp

Share this post


Link to post
Share on other sites

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

clcd.jpg

Edited by ssp

Share this post


Link to post
Share on other sites

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

 

scribble.jpg

Edited by ssp

Share this post


Link to post
Share on other sites

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
Transmitted 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 (xx01) (yy01) (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.

 

 

Edited by ssp

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

 

 

Edited by ssp

Share this post


Link to post
Share on other sites

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?

Edited by ssp

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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?

IMG_20191204_180503.jpg

IMG_20191204_180445.jpg

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
5 hours ago, totoRaymond said:

Hi!

I made the same mistake recently.

If it helps, i found some on aliexpress which seems compatible with MidiBox_NG:

https://fr.aliexpress.com/item/32233300972.html?spm=a2g0w.12010612.8148356.5.58bf27a8d5IkVL

I ordered a pair as samples 2 days ago. I don't expect them soon but i'll keep you updated when they arrive.

 

Thomas

 

thanks thomas, i ordered the correct ones in the beginning, i got sent totally different things. I found some on ebay after got them coming tomorrow.

 

Share this post


Link to post
Share on other sites

I have managed to set up bome's midi translator tonight and try a few things out as I built my mb_mf but the 10mhz crystal wont be here until next week.

The correct sysex string for the oled coming from my daw software is this

F0 00 01 06 16 12 00 00 00 73 74 72 69 6E 67 73 F7

this hex is ascii for strings: 73 74 72 69 6E 67 73

the header is different to what the pdf told me, however I will try this out next week as a command from mios studio.

 

I did see there was another thread asking TK if it was possible to map these sysex commands to individual oled displays but there was no follow up on this and I did post on that particular thread the other day to see if it had been resolved.  As i know the strings involved in generating the "track name" on the display it will allow me to use this on each new track.  i am hoping that when TK pops in again this weekend he may take 5 mins just to answer on this.

I have most of the .ngc code down now and have been busy writing things ready to test next week. Most of the casework has been designed and i will cut it on the cnc machine and laser cutting system in work next week as well.

 

only a few holdups now!!

Thorsten you crazy german genuis dude. what do you say??? sysex strings of track names to the displays...?? thanks

Share this post


Link to post
Share on other sites

It's getting late now but... Can I apply two different sysex strings to a toggle switch?

For example

    Select track 1= F0 00 01 06 16 E0 18 10 F7

Deselect track 1= F0 00 01 06 16 E0 18 01 F7

The switch is in the last 10/01 at the end of the string.

 

Having a look through the info in the morning. If I find what I need I will share how to apply it

 

 

(EDIT) just found this in "First steps"

 

 Surprise me! 

Our last experiment with a single button ends with a small surprise: change the EVENT_BUTTON statement to:  EVENT_BUTTON id=1  fwd_id=LED:1  button_mode=OnOnly \ type=SysEx stream="0xf0 0x00 0x00 0x7e 0x32 0x00 0x0d 0x40 0x57 0x6F 0x77 0x21 0xf7" \ lcd_pos=1:1:1 label="Button #%3i: %3d"  ...and have a look at the MIOS Terminal while pressing the button... ;-)  Ok, this demonstration should also show you, that it's possible to send SysEx streams, and that multiple lines in the configuration file can be concatenated to a single command with the backslash (\) character.  This needs to be expanded for a dual function toggle switch so it needs an on & off string.

 

I would use it in this aspec to send my string:  EVENT_BUTTON id=1  fwd_id=LED:1  button_mode=Toggle \ type=SysEx stream="0xf0 0x00 0x01 0x16 0xE0 0x18 0x10 0xf7" 

I need to apply a "Toggle On/Off" state to the string so it has an on and off event stream.

 

Edited by ssp

Share this post


Link to post
Share on other sites

Planning on spending the day reading through the rest of code info i printed out to see if there is anything in there to explain a dual sysex stream feature on a button event.

Share this post


Link to post
Share on other sites

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