[PD] [OT] Converting hex values to individual bytes

B. Bogart ben at ekran.org
Wed Jul 20 17:44:40 CEST 2005


Hey all,

I'm working on an abstraction to control a Canon VC-C50i serial-control
camera from PD. Things are going pretty well and I have the basic
trigger commands done. The problem I'm running into is the continuous
controls.

Lets take the pan as an example.

The documentation states that the minimum angle is 0x7c87, while the
maximum is 0x8379.
To set the angle of the camera I need to issue a command made of up
individual bytes (converted into decimal for comport) in this case
something like:

255,48,48,0,98,p,p,p,p,t,t,t,t,239 (in decimal)

Where the four P bytes are the panning angle and the four t bytes are
the tilt angle.

So what I want to do is to take a range (say floats 0-1) to map to the
min and max panning angle. How do I convert the miniumum angle (31879 in
decimal) to four seperate decimal messages for use in the above command?
Obviously I would like the granularity of the steps to be continuous so
I could do some interpolation without sending invalid values.

I could sit here for a couple hours to figure it out, but I thought
someone on the list would have a short cut for me.

Oh and according to the documentation (and testing) the following is correct:

Hex value | decimal message
----------+------------------
0x7c87    = 55,67,56,55 (min)
0x8379    = 56,51,55,57 (max)

Thank you!

B.






More information about the Pd-list mailing list