input register (INA) to variable
I think I'm not understanding the Propeller Manual.
If I have a pushbutton to P8...
If ina[8] is HI then btnstatus = %0000 0001 ?
Or do I have to make btnstatus a long and then btnstatus would be %...0000_0001 0000_0000 ?
If I have a pushbutton to P8...
dira[8] = 0
byte btnstatus
btnstatus := ina[8]
If ina[8] is HI then btnstatus = %0000 0001 ?
Or do I have to make btnstatus a long and then btnstatus would be %...0000_0001 0000_0000 ?
Comments
In general, INA[ x..y ] extracts a bit field whose high order bit is x and whose low order bit is y. If y > x, then the bits are in reversed order from how they're represented as I/O pins. In all cases, this bit field is right justified in a 32 bit value.
I have:
dira[15..0] := $00FF (So 15..8 are INs, 7..0 are OUTs)
Going the btnstatus/alias route resulted in anxiety.
When I test ina[8] directly, it's as I expect, 0/1, and things move along.
I should grab a shovel and move everything closer to the computer instead of going back and forth across "the office" as I am.
Yes, this is also possible:
long btnstatus btnstatus := ina
now every bit in btnstatus represents the corresponding input pin.Andy
The objective is for a pushbutton (Jog) to advance a stepper position.
In buttonchecking2.spin, I test ina[8].
In buttonchecking3.spin, I test 'btnstatus'.
PUB buttoncheck repeat until ina[8] == 1 position := position + 1
versusPUB buttoncheck repeat until btnstatus == 1 btnstatus := ina[8] ' stays stuck w/o userpause ' dbl-clicks w/o btnstatus := ina[8] ' goes automatic w/o position := position + 1
Both work, but the second version (buttonchecking3) takes more lines of code or it'll double-pulse.Where am I going wrong?
That's OK. It's only about Spin and things Propeller, not some supercilious ancillary pretense at association with one.
Oh well.
Such is the Propeller Forum Echo Chamber.
I still found what I was looking for, within me, applying the gray matter, as ever. If anyone's interested, see #9 over here.
Anyway, I was wondering why you didn't write the second version like this:
PUB buttoncheck btnstatus := ina[8] repeat until btnstatus == 1 btnstatus := ina[8] userpause position := position + 1
The basic structure should be the same as your first version. If you use the following, does it work?
PUB buttoncheck btnstatus := ina[8] repeat until btnstatus == 1 btnstatus := ina[8] position := position + 1
I know you say you've already solved your problem (by changing the overall structure of the code) but I'm curious about what the issue here is.