jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/
|
| 2 | /* Copyright (c) FIRST 2011. All Rights Reserved. */
|
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */
|
| 4 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
| 5 | /*----------------------------------------------------------------------------*/
|
| 6 |
|
| 7 | #ifndef __TRIGGER_H__
|
| 8 | #define __TRIGGER_H__
|
| 9 |
|
| 10 | #include "SmartDashboard/Sendable.h"
|
| 11 |
|
| 12 | class Command;
|
| 13 |
|
| 14 | /**
|
| 15 | * This class provides an easy way to link commands to inputs.
|
| 16 | *
|
| 17 | * It is very easy to link a polled input to a command. For instance, you could
|
| 18 | * link the trigger button of a joystick to a "score" command or an encoder reaching
|
| 19 | * a particular value.
|
| 20 | *
|
| 21 | * It is encouraged that teams write a subclass of Trigger if they want to have
|
| 22 | * something unusual (for instance, if they want to react to the user holding
|
| 23 | * a button while the robot is reading a certain sensor input). For this, they
|
| 24 | * only have to write the {@link Trigger#Get()} method to get the full functionality
|
| 25 | * of the Trigger class.
|
| 26 | *
|
| 27 | * @author Brad Miller, Joe Grinstead
|
| 28 | */
|
| 29 | class Trigger : public Sendable
|
| 30 | {
|
| 31 | public:
|
| 32 | Trigger();
|
| 33 | virtual ~Trigger() {}
|
| 34 | bool Grab();
|
| 35 | virtual bool Get() = 0;
|
| 36 | void WhenActive(Command *command);
|
| 37 | void WhileActive(Command *command);
|
| 38 | void WhenInactive(Command *command);
|
| 39 |
|
| 40 | virtual void InitTable(ITable* table);
|
| 41 | virtual ITable* GetTable();
|
| 42 | virtual std::string GetSmartDashboardType();
|
| 43 | protected:
|
| 44 | ITable* m_table;
|
| 45 | };
|
| 46 |
|
| 47 | #endif
|