Multiple buttons, one special case
Torquewrench
Posts: 28
Hi,
I'm working on a controller circuit for a paintball gun that involves an LCD screen. I've borrowed heavily from NV #62 on using menus, and I had a question about how to treat the trigger button, which is a special case compared to the other buttons.
Here is a list of the buttons I'm dealing with:
Mode
Select
Safety
Trigger
In NV62 Jon Williams dealt with debouncing multiple inputs by ANDing a byte the inputs with a temp byte repeatedly. This definitely works for the mode, select, and safety, but for the trigger I'm looking for some special behavior I previously achieved using BUTTON.
The special behavior is this: The trigger is used three modes, semi, burst, and auto.
In semi the trigger should fire only once until released (BUTTON delay = 255 for no repeat)
In burst the trigger should fire multiple shots only once until released (BUTTON delay = 255 with a FOR loop)
In auto the trigger should fire continuously until released (BUTTON with a delay for auto-repeat)
How can I achieve this in my new code while I'm looking at these other buttons?
Thanks,
Phil
I'm working on a controller circuit for a paintball gun that involves an LCD screen. I've borrowed heavily from NV #62 on using menus, and I had a question about how to treat the trigger button, which is a special case compared to the other buttons.
Here is a list of the buttons I'm dealing with:
Mode
Select
Safety
Trigger
In NV62 Jon Williams dealt with debouncing multiple inputs by ANDing a byte the inputs with a temp byte repeatedly. This definitely works for the mode, select, and safety, but for the trigger I'm looking for some special behavior I previously achieved using BUTTON.
The special behavior is this: The trigger is used three modes, semi, burst, and auto.
In semi the trigger should fire only once until released (BUTTON delay = 255 for no repeat)
In burst the trigger should fire multiple shots only once until released (BUTTON delay = 255 with a FOR loop)
In auto the trigger should fire continuously until released (BUTTON with a delay for auto-repeat)
How can I achieve this in my new code while I'm looking at these other buttons?
Thanks,
Phil
bs2
26K
Comments
·· You may be overcomplicating things now.· You have new code, yes, but, unless I am missing something, why can't the code handle the firing modes based on the trigger being pressed?· That way the trigger button doesn't need to be handled in a special way.· Unless the code you refer to won't let you hold it down.··I would just make it so that when the trigger is pressed, the code decides based on the mode how to trigger the solenoid or whatever is firing your paintball gun.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
But I would really like to learn how to accomplish the trigger button features without BUTTON, if you could show me how.
Thank you,
Phil
1. Safety:
When held down, will display "SAFE" in place of shot count (4-digit number) in main screen, until released (this is mechanical rotary level that acts on a lever snap switch, so when the mechanical lever is in SAFE the button will be held down).
Increment fire mode (semi, burst, full) each time safety is pressed (or pressed and released, doesn't matter)
2. Trigger:
In semi mode, I would like adjustable debounce but no repeat.
With the BUTTON command I can get no repeat with the delay=255 option, but the debounce time is not adjustable. From the Getkey routine I can see how the button command likely works, except for how it achieves the no-repeat. Can someone show me the BUTTON command in software or how to write the Getkey routine with no repeat?
I'm thinking it might involve a bit variable that gets flipped when the button is pressed and sends out a pulse then flips back when the button is released.
Attached is my latest code, I'm using the BUTTON and Getkey subroutine, but not getting the behavior I'm looking for.
Thank you,
Phil
Thanks for all your help,
Phil