View Single Post
Old 01-09-2018, 08:28 AM   #31
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554

Still can't figure this out.

So, the task is:
Construct SYSEX message with various small parts, so it wouold be possible to display data from Reaper on the LCD:

lcdSysexHeader    = "\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02";    // LCD HEADER
lcdSetCursor    = "\x01";  // command to position cursor
lcdLTLine        = "\x01";  // top line on the left LCD
lcdTextStart    = "\x04";  // begin text part
lcdTextEnd        = "\x00"; // finish text part
lcdSysexEnd        = "\xF7";                                            // LCD END
strcat(lcdTrackName,sprintf(#,"%s%s%s%s%s%s%s%s",lcdSysexHeader,lcdSetCursor,position,lcdLTLine,lcdTextStart,str2hex(sysexInput),lcdTextEnd, lcdSysexEnd));
For now, two parts of the message may vary:
1. str2hex(sysexInput) where sysexInput is a currently selected track's name in string format. This one is working fine. using my custom string to hex conversion function.
2. position - cursor position on the LCD. Doesn't work, for now.
If position will be replaced by "\x00", for example, the cursor will be set to the first symbol position at the top line of the screen. "\x01" for the second position and so on.

What I need is to substitute "\x00" here with a variable\function, that would take decimal integer number as an input and convert it to hexadecimal number string, since "\x**" type of strings are used in oscii-bot. For example, 1 bill become "\x01", 11 will be converted into "\x0B".

When I'm trying to construct sysex string with
pos = sprintf(#, "\\x%X", position));
or some other methods, they don't work. pos value is always a text string, while I need it to be "hex string", like those constants above.
fundorin is offline   Reply With Quote