blob: 3ec1589a9e82b257905ae564a0c4a6e37a3b4f15 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. 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 SERVO_H
8#define SERVO_H
9
10#include "SafePWM.h"
11#include "SpeedController.h"
12
13/**
14 * Standard hobby style servo.
15 *
16 * The range parameters default to the appropriate values for the Hitec HS-322HD servo provided
17 * in the FIRST Kit of Parts in 2008.
18 */
19class Servo : public SafePWM
20{
21public:
22 explicit Servo(UINT32 channel);
23 Servo(UINT8 moduleNumber, UINT32 channel);
24 virtual ~Servo();
25 void Set(float value);
26 void SetOffline();
27 float Get();
28 void SetAngle(float angle);
29 float GetAngle();
30 static float GetMaxAngle() { return kMaxServoAngle; };
31 static float GetMinAngle() { return kMinServoAngle; };
32
33 void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
34 void UpdateTable();
35 void StartLiveWindowMode();
36 void StopLiveWindowMode();
37 std::string GetSmartDashboardType();
38 void InitTable(ITable *subTable);
39 ITable * GetTable();
40
41 ITable *m_table;
42
43private:
44 void InitServo();
45 float GetServoAngleRange() {return kMaxServoAngle - kMinServoAngle;}
46
47 static const float kMaxServoAngle = 170.0;
48 static const float kMinServoAngle = 0.0;
49};
50
51#endif
52