View Single Post
  #7   Spotlight this post!  
Unread 23-12-2011, 23:26
gixxy's Avatar
gixxy gixxy is offline
Programming and Arduino Mentor
AKA: Gustave Michel III
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Ruston, LA
Posts: 207
gixxy is on a distinguished road
Re: Creating a program that switch between tank and arcade

Using Java I created 3 classes and an interface.

the interface (ControlMap) was just a list of functions we would need to get the infomation from the joysticks. things like getThrottle() in arcade and getLeftJoystick() and getRightJoystick() for Tank.

Then the other two classes were tankControlBoard and arcadeControlBoard. Which implemented the ControlMap interface. This way I could use a single ControlMap object and just switch which implentation to use, and thus change what code was used to get the data needed.

That is how I did the controls selection.


Then another class i made was softSwitch. which basicly had the methods getState(), toggleState(), and setState() so that I could use a button on the joystick as an on/off toggle (as well as set the button's state in software).

so then in our ControlOperator class, which read the data from the ControlMap (and then used the proper ControlBoard) would tell the Drive Train how to drive, using Tank or Arcade.

I can't seem to find the code I used. If you need help I will gladly attempt to rewrite a simple version of it.