One more thing, the value depending on size is:
1-BYTE Range: -64 -> 64 Old Range: 0-255
2-BYTE Range: -8192 -> 8191 Old Range: 0-65535
3-BYTE Range: -1048576 -> 1048575
4-BYTE Range: ??? Old Range:-2147483648 to 2147483647
5-BYTE Range: ???
Calculations to determine the most efficient way:
X,Y normally within a Short 0-65535, should also work with the -8192 -> 8191 range
.
This means always 2 bytes each for X,Y,Z,Dir,Key. Total data in a normal case would be 10-bytes!
With this method X,Y,Z,Dir,Key is each 1-2byte + 1byte(the extra byte as separator). Results in 9 to 14 bytes.
Also with separators a 0 value does not need to be sent. But it's not often that is an issue anyway. Also this a very good way to send changes (delta) becuase they are usually small.
-Wait!
I can't have a separator with numbers, because one of the numbers could be represented as that separator if I have badluck. which could mess up the sent data.
1-BYTE Range: -64 -> 64 Old Range: 0-255
2-BYTE Range: -8192 -> 8191 Old Range: 0-65535
3-BYTE Range: -1048576 -> 1048575
4-BYTE Range: ??? Old Range:-2147483648 to 2147483647
5-BYTE Range: ???
Calculations to determine the most efficient way:
X,Y normally within a Short 0-65535, should also work with the -8192 -> 8191 range
.
This means always 2 bytes each for X,Y,Z,Dir,Key. Total data in a normal case would be 10-bytes!
With this method X,Y,Z,Dir,Key is each 1-2byte + 1byte(the extra byte as separator). Results in 9 to 14 bytes.
Also with separators a 0 value does not need to be sent. But it's not often that is an issue anyway. Also this a very good way to send changes (delta) becuase they are usually small.
-Wait!
I can't have a separator with numbers, because one of the numbers could be represented as that separator if I have badluck. which could mess up the sent data.