blob: acfce1e0c64ca7e09912c8f7aa6ea68e8d219b1f [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 ACCELEROMETER_H_
8#define ACCELEROMETER_H_
9
10#include "AnalogChannel.h"
11#include "SensorBase.h"
12#include "PIDSource.h"
13#include "LiveWindow/LiveWindowSendable.h"
14
15/**
16 * Handle operation of the accelerometer.
17 * The accelerometer reads acceleration directly through the sensor. Many sensors have
18 * multiple axis and can be treated as multiple devices. Each is calibrated by finding
19 * the center value over a period of time.
20 */
21class Accelerometer : public SensorBase, public PIDSource, public LiveWindowSendable {
22public:
23 explicit Accelerometer(UINT32 channel);
24 Accelerometer(UINT8 moduleNumber, UINT32 channel);
25 explicit Accelerometer(AnalogChannel *channel);
26 virtual ~Accelerometer();
27
28 float GetAcceleration();
29 void SetSensitivity(float sensitivity);
30 void SetZero(float zero);
31 double PIDGet();
32
33 void UpdateTable();
34 void StartLiveWindowMode();
35 void StopLiveWindowMode();
36 std::string GetSmartDashboardType();
37 void InitTable(ITable *subTable);
38 ITable * GetTable();
39
40private:
41 void InitAccelerometer();
42
43 AnalogChannel *m_analogChannel;
44 float m_voltsPerG;
45 float m_zeroGVoltage;
46 bool m_allocatedChannel;
47
48 ITable *m_table;
49};
50
51#endif