i was trying to find a way to encode 3 values of a range of 0-150-150-15 into 2 bytes maximum data.
something like encoding bits into bytes or hex characters .
as a byte is got 00000000 and a range of 0-15 can be express in bynary like 0000-1111 i want to put to of this pieces into a byte and and the other piece into other so to have maximum of 2 bytes for expressing 0-150-150-15 then decode it. I can only send a maximum of 2 bytes to some hardware but need to send this 3 values so i,m trying to find how to do this bitmasking trick.
Do you know if you can use all bits of your two bytes? Depending on the protocol of your hardware this may or may not be possible. Are you in control of decoding the bytes on the hardware? If no then the hardware must dictate how you need to encode the values.
there are actually 3 ways you can combine and split the values. Radix (Value) should be the fastest… depending on the capabilities of your hardware you have to choose one of the methods there. probably bitwise operations…
thanks guys, i was testing radix yesterday but did not get the way also i was using always ascii as it is the smaller way i found as i thought it is like a raw byte, so cool i was missing this AsRaw.
i was doing now in other more humble way ;D,doing little converter plugs so in the end sending in 2 bytes in ascci.
yes i,ll test later on and see how easy it is to decode, i will use arduino to decode it actually.
hi tonfilm , what about if i want to also use the second part of the second byte , what do i need to change ? , i tried just adding another pin to the radix but did not work .
Edit : ok i needed to change the Output Base i add another 0.