Quote:
Originally Posted by Roger
I don't know offhand the precidence of which does what first. I am assuming it is ((p3_aux & 1) << 7), not (p3_aux & (1 << 7)), but looking again I can't tell and I don't remember.
|
The bitshift operator has higher precedence than the binary and operator. So, it would be (p3_aux & (1<<7)).
What does this mean? Digital inputs are either 0 or 1. This would be like p1_sw_trig or something. It is 0 if it's not pressed and 1 if it is. An analog input can go from 0 to 255. An example of this is p1_x, which varies depending on where the joystick is.
p3_aux is an analog input, but not in the sense of p1_x. p3_aux is a combination of 8 digital inputs. The right-most bit refers to one switch, the next bit to another, etc. So p3_aux&1<<7 says, "is the seventh bit from the right true?" (It's actually the eighth bit, because we use zero-based counting here. p3_aux&1<<0 gives you the rightmost, etc.)
Does this make sense?