blob: cbb81978dd9c8a9dcf1c36925b052795a0daad32 [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 __HiTechnicCompass_h__
8#define __HiTechnicCompass_h__
9
10#include "SensorBase.h"
11#include "LiveWindow/LiveWindowSendable.h"
12
13class I2C;
14
15/**
16 * HiTechnic NXT Compass.
17 *
18 * This class alows access to a HiTechnic NXT Compass on an I2C bus.
19 * These sensors to not allow changing addresses so you cannot have more
20 * than one on a single bus.
21 *
22 * Details on the sensor can be found here:
23 * http://www.hitechnic.com/index.html?lang=en-us&target=d17.html
24 *
25 * @todo Implement a calibration method for the sensor.
26 */
27class HiTechnicCompass : public SensorBase, public LiveWindowSendable
28{
29public:
30 explicit HiTechnicCompass(UINT8 moduleNumber);
31 virtual ~HiTechnicCompass();
32 float GetAngle();
33
34 void UpdateTable();
35 void StartLiveWindowMode();
36 void StopLiveWindowMode();
37 std::string GetSmartDashboardType();
38 void InitTable(ITable *subTable);
39 ITable * GetTable();
40
41private:
42 static const UINT8 kAddress = 0x02;
43 static const UINT8 kManufacturerBaseRegister = 0x08;
44 static const UINT8 kManufacturerSize = 0x08;
45 static const UINT8 kSensorTypeBaseRegister = 0x10;
46 static const UINT8 kSensorTypeSize = 0x08;
47 static const UINT8 kHeadingRegister = 0x44;
48
49 I2C* m_i2c;
50
51 ITable *m_table;
52};
53
54#endif
55