Go to Post In any case, I'd like to remind everyone to practice gracious nonexpansionalism while in your pit. - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-02-2015, 10:59
arichman1257's Avatar
arichman1257 arichman1257 is offline
VP, Control Systems Captain, Coach
AKA: Alan Richman
FRC #1257 (Parallel Universe)
Team Role: Electrical
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Fanwood
Posts: 28
arichman1257 is on a distinguished road
Button Sequence Input

Is there a relatively simple way, with WPILib or without, to make the code be able to detect an input of a sequence of buttons as oppose to holding them all down? Like a cheat code.

For example, if the driver entered the sequence A B X Y on an xbox controller some LEDs would flash. This mean that they are only pressing one at a time but in sequence.
Reply With Quote
  #2   Spotlight this post!  
Unread 13-02-2015, 11:05
cgmv123's Avatar
cgmv123 cgmv123 is offline
FRC RI/FLL Field Manager
AKA: Max Vrany
FRC #1306 (BadgerBOTS)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Madison, WI
Posts: 2,073
cgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond repute
Re: Button Sequence Input

Code:
int state = 0;

while{
if buttonA && state == 0
state ++;

if buttonB && state == 1
state ++;

if buttonX && state == 2
state++;

if buttonY && state == 3
state ++;

if buttonBack
state = 0;

if state == 4
{action
state = 0;
}
This is Java-focused pseudocode, but it should be enough to get you started.
__________________
BadgerBOTS Robotics|@team1306|Facebook: BadgerBOTS
2016 FIRST Championship Tesla Division | 2016 Wisconsin Regional Engineering Inspiration Award

2015 FIRST Championship Carson Division | 2015 Wisconsin Regional Chairman's Award

2013 FIRST Championship Curie Division | 2013 Wisconsin Regional Chairman's Award

2012 FIRST Championship Archimedes Division | 2012 Wisconsin Regional Engineering Inspiration Award, Woodie Flowers Finalist Award (Lead Mentor Ben Senson)

Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2015, 11:51
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,044
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Button Sequence Input

Quote:
Originally Posted by cgmv123 View Post
Code:
int state = 0;

while{
if buttonA && state == 0
state ++;

if buttonB && state == 1
state ++;

if buttonX && state == 2
state++;

if buttonY && state == 3
state ++;

if buttonBack
state = 0;

if state == 4
{action
state = 0;
}
This is Java-focused pseudocode, but it should be enough to get you started.
Shouldn't the state be reset to 0 if a button not in the A B X Y sequence is pressed?

As the code stands, the sequence A B Z X Y would be accepted.


Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:12.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi