Here’s the XTouch Universal Native version.
//DISPLAY
var currentLedCodes={}
var segMapping=[0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67]
var tp=page.mHostAccess.mTransport.mTimeDisplay.mPrimary.mTransportLocator.mOnChange=function (/** @type {MR_ActiveDevice} */context,
/** @type {MR_ActiveMapping} */activeMapping,
/** @type {string} */time,
/** @type {string} */format) {
//console.log(format)
var text='0000000000' //- sysex (hex) F0 00 20 32 41 37 s1 .. s12 d1 d2 F7
// - s1..s12: segment data (bit 0: segment a, .. bit 6: segment g)
//- d1: dots for displays 1..7 (bit 0: display 1, .. bit 6: display 7)
//- d2: dots for displays 8..12 (bit 0: display 8, .. bit 4: display 12)
if(format==='Bars+Beats')
{
var fields = time.split('.');
while(fields[0].length<3)
{
fields[0]=' '.concat(fields[0])
}
text=' '.concat(fields[0],fields[1],fields[2],fields[3])
}
if(format==='Seconds')
{
var fields = time.split(/[:.]/);
while(fields[0].length<3)
{
fields[0]=' '.concat(fields[0])
}
text=' '.concat(fields[0],fields[1],fields[2],fields[3])
}
if(format==='Timecode')
{
var fields = time.split(':');
while(fields[0].length<3)
{
fields[0]=' '.concat(fields[0])
}
text=' '.concat(fields[0],fields[1],fields[2],fields[3],' ')
}
if(format==='Samples')
{
text=time;
while(text.length<10)
{
text=' '.concat(text)
}
text=' '.concat(text)
}
//console.log(text)
for(var i=0;i<12;i++)
{
var c=text.charCodeAt(i);
if(c<32)
c=32
if(c>57)
c=32
if(c==32)
{
currentLedCodes[i]=0;
}
else
{
currentLedCodes[i]=segMapping[c-48];
}
}
midiOutput.sendMidi(context, [
0xf0,00,0x20,0x32, //HEADER
0x14,0x37, //Device ID, CMD=4c
currentLedCodes[0],currentLedCodes[1],
currentLedCodes[2],currentLedCodes[3],currentLedCodes[4],
currentLedCodes[5],currentLedCodes[6],
currentLedCodes[7],currentLedCodes[8],
currentLedCodes[9],currentLedCodes[10],currentLedCodes[11],
0x00,0x00,
0xf7])
//console.log(time)
}