I have a control surface encoder that sends B0 10 pp (pp= 0x01 thru 0x7F). I am expected to send this encoder data to a software knob expecting to see Mackie encoder data. Here is the explanation:
Mackie:
B0, 1i, XX
i V-Pot ID (00—07)
XX delta value in the form of ( 0 s v v v v v v )
s direction bit:
0 = clockwise,
1 = counter clockwise
vv number of ticks
Examples:
• B0, 10, 01 = V-Pot Ch. 1 is being turned clockwise by one
tick.
• B0, 17, 47 = V-Pot Ch. 8 is being turned counter-clockwise by 7 ticks.
So basically I’m trying to translate the linear encoder data to this Mackie encoder data and I’m a little stumped on how to do this. Any help is greatly appreciated
I use the global variable ga for the last known value of the incoming absolute encoder.
The example is only for the first encoder, you will need to set up a different global variable for each encoder. I document and initializes global variable used in this project in the rules of translator 0.2
Translator 2.0 is the translator used for conversion.
You can learn more about aliases from this tutorial.
Here are the rules with comments.
// Positive Movement
if pp>ga then tt=pp-ga
// Negative Movement
if pp<ga then tt=ga-pp
if pp<ga then tt=tt|64
// lower end
if pp==0 then tt=65
//higher end
if pp==127 then tt=1
//update for next iteration
ga=pp
// no higher than 127
if ga>127 then ga=127
// no lower than 0
if ga<0 then ga=0
Log "Log outgoing value is 0x%02x tt%"