2010-12-28 19:27:12 -04:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
|
|
|
//
|
|
|
|
// Shim GPS driver, for use when the actual GPS data is coming from somewhere else.
|
|
|
|
// Code by Mike Smith
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
#ifndef AP_GPS_Shim_h
|
|
|
|
#define AP_GPS_Shim_h
|
|
|
|
|
2011-04-30 23:05:17 -03:00
|
|
|
#include "GPS.h"
|
2010-12-28 19:27:12 -04:00
|
|
|
|
2010-12-28 20:35:53 -04:00
|
|
|
class AP_GPS_Shim : public GPS
|
|
|
|
{
|
2010-12-28 19:27:12 -04:00
|
|
|
public:
|
2012-12-17 22:31:05 -04:00
|
|
|
virtual void init(AP_HAL::UARTDriver *s, enum GPS_Engine_Setting nav_setting = GPS_ENGINE_NONE) {
|
|
|
|
_port = s;
|
2012-08-17 03:19:44 -03:00
|
|
|
};
|
|
|
|
virtual bool read(void) {
|
|
|
|
bool updated = _updated;
|
2011-10-28 15:52:50 -03:00
|
|
|
_updated = false;
|
|
|
|
return updated;
|
|
|
|
}
|
2010-12-28 19:27:12 -04:00
|
|
|
|
2011-10-28 15:52:50 -03:00
|
|
|
/// Set-and-mark-updated macro for the public member variables; each instance
|
|
|
|
/// defines a member function set_<variable>(<type>)
|
|
|
|
///
|
2012-08-17 03:19:44 -03:00
|
|
|
#define __GPS_SHIM_SET(__type, __name) void set_ ## __name(__type v) { __name = v; _updated = true; }
|
2012-06-02 01:26:34 -03:00
|
|
|
__GPS_SHIM_SET(uint32_t, time);
|
2011-10-28 15:52:50 -03:00
|
|
|
__GPS_SHIM_SET(long, latitude);
|
|
|
|
__GPS_SHIM_SET(long, longitude);
|
|
|
|
__GPS_SHIM_SET(long, altitude);
|
|
|
|
__GPS_SHIM_SET(long, ground_speed);
|
|
|
|
__GPS_SHIM_SET(long, ground_course);
|
|
|
|
__GPS_SHIM_SET(long, speed_3d);
|
|
|
|
__GPS_SHIM_SET(int, hdop);
|
2010-12-28 20:35:53 -04:00
|
|
|
#undef __GPS_SHIM_SET
|
|
|
|
|
|
|
|
private:
|
2012-08-17 03:19:44 -03:00
|
|
|
bool _updated; ///< set anytime a member is updated, cleared when read() returns true
|
2010-12-28 19:27:12 -04:00
|
|
|
};
|
|
|
|
|
2012-08-17 03:19:44 -03:00
|
|
|
#endif // AP_GPS_HIL_H
|