What do you mean scale an offset???
First and foremost...I apologize if I cannot answer you, but it's been years since I tinkered with FS stuff....version 5.0 was the last time I flew anything...but I will try and answer or assist your specific question in regards to programming.
Anyways,
Scale an offset...well you can't...cuz an offset is an offset...you change the number any and you'll change the data your after too...
The value returned at offset
0BC0
is an short integer with a range of 32768 or like you said (+-)16383. You cannot do an explicit cast to a
BYTE
which holds the values 0-255 or (+-)128...cuz you will likely always result in loss of data.
So what I would suggest is calculate the percentage of the first and convert that into the byte code your trying to send over the serial port...
For instance:
a value of 5243...
5243 / 32768 = 0.16
0.16 * 100 = 16% elevator trim
Note: The values stored at offset: 0BC0 appears to be signed by the looks of things, so you will need to convert the value into an unsigned value before plugging that into the equation above...
Now you calculate the value (If I fail to use proper math terminology...it's cuz...i'm not a math guy...i'm a geek...computers do my work for me :oops: ) required for the serial port based on the percentage above :)
So... 16% of 255 (A serial port I believe can send/recv only a single byte at a time which is a 0-255 unsigned)
255 * 0.16 = 40.8
Remember an integer doesn't allow for any precision, so whole numbers are only allowed...so in reality...
40.8 will likely become 40
Not sure what the hell the above process is called...I think it's interpolation or extrapolation or something...but who cares...as long as you understand it and it works :)
Hope this helps 8)
Cheers :)