Can I combine bitwise '&' with CASE?
lardom
Posts: 1,659
in Propeller 1
I want to use bits 0-3 to pass a value and bits 4-7 to point to specific variables in an object that recieves values wirelessly.
I have in mind four variables, let's call them A, B, C and D. I want to point to them like this:
%0001_xxxx (copy to variable a)
%0010_xxxx (copy to variable b)
%0011_xxxx (copy to variable c)
%0100_xxxx (copy to variable d)
I really want to eliminate a lot of IF statements.
I have in mind four variables, let's call them A, B, C and D. I want to point to them like this:
%0001_xxxx (copy to variable a)
%0010_xxxx (copy to variable b)
%0011_xxxx (copy to variable c)
%0100_xxxx (copy to variable d)
I really want to eliminate a lot of IF statements.
Comments
Yes, the argument to a case can be any expression.
You can even put an assignment operation there if you like, such as "x++" or "x *= 23"
I would recommend that you instead write: or even: That way, you won't need to change the same thing in two places if you want to change the top part constant or add more cases.
I was successfully able to control the speed of one motor EDIT: (with a joystick) foward and reverse using the nrf24L01 transceiver.
Wireless control of two motors differentially is a major jump (for me) because of the 8-bit bottleneck.
1)Rotate left/right
2)turn left/right forward
3)turn left/right backward
I also want to add pan/tilt for a camera and an arm with a gripper.