7 #include "HiTechnicCompass.h"
8 #include "DigitalModule.h"
10 #include "NetworkCommunication/UsageReporting.h"
11 #include "WPIErrors.h"
12 #include "LiveWindow/LiveWindow.h"
14 const uint8_t HiTechnicCompass::kAddress;
15 const uint8_t HiTechnicCompass::kManufacturerBaseRegister;
16 const uint8_t HiTechnicCompass::kManufacturerSize;
17 const uint8_t HiTechnicCompass::kSensorTypeBaseRegister;
18 const uint8_t HiTechnicCompass::kSensorTypeSize;
19 const uint8_t HiTechnicCompass::kHeadingRegister;
33 m_i2c = module->
GetI2C(kAddress);
36 const uint8_t kExpectedManufacturer[] =
"HiTechnc";
37 const uint8_t kExpectedSensorType[] =
"Compass ";
38 if ( ! m_i2c->
VerifySensor(kManufacturerBaseRegister, kManufacturerSize, kExpectedManufacturer) )
40 wpi_setWPIError(CompassManufacturerError);
43 if ( ! m_i2c->
VerifySensor(kSensorTypeBaseRegister, kSensorTypeSize, kExpectedSensorType) )
45 wpi_setWPIError(CompassTypeError);
48 nUsageReporting::report(nUsageReporting::kResourceType_HiTechnicCompass, moduleNumber - 1);
74 m_i2c->
Read(kHeadingRegister,
sizeof(heading), (uint8_t *)&heading);
77 heading = (heading >> 8) | (heading << 8);
79 return (
float)heading;
83 if (m_table != NULL) {
97 return "HiTechnicCompass";
void StartLiveWindowMode()
virtual void PutNumber(std::string key, double value)=0
virtual ~HiTechnicCompass()
void InitTable(ITable *subTable)
std::string GetSmartDashboardType()
void AddSensor(const char *subsystem, const char *name, LiveWindowSendable *component)
static LiveWindow * GetInstance()
bool Read(uint8_t registerAddress, uint8_t count, uint8_t *data)
HiTechnicCompass(uint8_t moduleNumber)
void StopLiveWindowMode()
static DigitalModule * GetInstance(uint8_t moduleNumber)
bool VerifySensor(uint8_t registerAddress, uint8_t count, const uint8_t *expected)
I2C * GetI2C(uint32_t address)