Reading Data from a string and comparing.
Paul K.
Posts: 150
Im having a hard time starting this on my own.· I am using the wireless playstation remote object and I have that working and
displaying that data thru my rca connection.
It's displaying the data in hex so I get something like this $FFFF5A73 this changes as I hit a button on the remote.
I have mapped out all the changes possible.
I am lost on how to read a change.·
EX: I hit the triangle button and I·get this in return $EFFF5A73 but am lost how to read the first bit in the sequence.
I know I can compare the whole string but thats alot of wasted time if each bit has 16 different options im looking at a table of like
a couple thousand different options.· If not more.· Is there a way to read each bit.
Thanks
Paul
displaying that data thru my rca connection.
It's displaying the data in hex so I get something like this $FFFF5A73 this changes as I hit a button on the remote.
I have mapped out all the changes possible.
I am lost on how to read a change.·
EX: I hit the triangle button and I·get this in return $EFFF5A73 but am lost how to read the first bit in the sequence.
I know I can compare the whole string but thats alot of wasted time if each bit has 16 different options im looking at a table of like
a couple thousand different options.· If not more.· Is there a way to read each bit.
Thanks
Paul
Comments
If the lower bits are insignificant in your comparison you can do something like this...
third_num
or even...
If you want to look at a different position, say the 3rd one from the right where the 'A' is ... $FFFF5A73
you could do something like this...
since Each HEX value represents 4 bits, the number to shift is the position from the right minus 1 times 4.
so for the 8th position... (8-1)*4 = 28
...the 3rd position... (3-1)*4 = 8
If the number that you want to look at is a BYTE (8-bits) ... same thing, but instead of multiplying by 4, multiply by 8.
in the first example... 'If hex_data>>24 & $FF == $EF'
...this was the 4th BYTE from the right... so (4-1)*8 = 24
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 10/19/2009 5:12:02 AM GMT
Thanks
Paul