2011-02-14 00:27:07 -04:00
|
|
|
/*
|
|
|
|
AP_Compass_HIL.cpp - Arduino Library for HIL model of HMC5843 I2C Magnetometer
|
|
|
|
Code by James Goppert. DIYDrones.com
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and / or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "AP_Compass_HIL.h"
|
|
|
|
|
|
|
|
// Public Methods //////////////////////////////////////////////////////////////
|
|
|
|
|
2011-12-28 05:31:36 -04:00
|
|
|
bool AP_Compass_HIL::read()
|
2011-02-14 00:27:07 -04:00
|
|
|
{
|
2011-12-28 05:31:36 -04:00
|
|
|
// values set by setHIL function
|
2012-03-04 05:34:44 -04:00
|
|
|
last_update = millis(); // record time of update
|
2011-12-28 05:31:36 -04:00
|
|
|
return true;
|
2011-02-14 00:27:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update raw magnetometer values from HIL data
|
|
|
|
//
|
|
|
|
void AP_Compass_HIL::setHIL(float _mag_x, float _mag_y, float _mag_z)
|
|
|
|
{
|
2012-02-15 07:33:50 -04:00
|
|
|
Vector3f ofs = _offset.get();
|
|
|
|
mag_x = _mag_x + ofs.x;
|
|
|
|
mag_y = _mag_y + ofs.y;
|
|
|
|
mag_z = _mag_z + ofs.z;
|
|
|
|
healthy = true;
|
2011-02-14 00:27:07 -04:00
|
|
|
}
|