Skip to content

Commit

Permalink
Merge ee7d7de into a615e52
Browse files Browse the repository at this point in the history
  • Loading branch information
shrit committed Mar 22, 2019
2 parents a615e52 + ee7d7de commit d474466
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
21 changes: 21 additions & 0 deletions plugins/telemetry/include/plugins/telemetry/telemetry.h
Expand Up @@ -474,6 +474,27 @@ class Telemetry : public PluginBase {
*/
Health health() const;

/**
* @brief Returns true if gyroscope health is ok (synchronous).
*
* @return True if only gyroscope flags is OK.
*/
bool health_gyrometer() const;

/**
* @brief Returns true if accelerometer health is ok (synchronous).
*
* @return True if only accelerometer flags is OK.
*/
bool health_accelerometer() const;

/**
* @brief Returns true if magnetometer health is ok (synchronous).
*
* @return True if only magnetometer flags is OK.
*/
bool health_magnetometer() const;

/**
* @brief Returns true if the overall health is ok (synchronous).
*
Expand Down
15 changes: 15 additions & 0 deletions plugins/telemetry/telemetry.cpp
Expand Up @@ -181,6 +181,21 @@ Telemetry::Health Telemetry::health() const
return _impl->get_health();
}

bool Telemetry::health_gyrometer() const
{
return _impl->get_health_gyrometer();
}

bool Telemetry::health_accelerometer() const
{
return _impl->get_health_accelerometer();
}

bool Telemetry::health_magnetometer() const
{
return _impl->get_health_magnetometer();
}

bool Telemetry::health_all_ok() const
{
return _impl->get_health_all_ok();
Expand Down
30 changes: 30 additions & 0 deletions plugins/telemetry/telemetry_impl.cpp
Expand Up @@ -759,6 +759,36 @@ Telemetry::Health TelemetryImpl::get_health() const
return _health;
}

bool TelemetryImpl::get_health_gyrometer() const
{
std::lock_guard<std::mutex> lock(_health_mutex);
if (_health.gyrometer_calibration_ok) {
return true;
} else {
return false;
}
}

bool TelemetryImpl::get_health_accelerometer() const
{
std::lock_guard<std::mutex> lock(_health_mutex);
if (_health.accelerometer_calibration_ok) {
return true;
} else {
return false;
}
}

bool TelemetryImpl::get_health_magnetometer() const
{
std::lock_guard<std::mutex> lock(_health_mutex);
if (_health.magnetometer_calibration_ok) {
return true;
} else {
return false;
}
}

bool TelemetryImpl::get_health_all_ok() const
{
std::lock_guard<std::mutex> lock(_health_mutex);
Expand Down
3 changes: 3 additions & 0 deletions plugins/telemetry/telemetry_impl.h
Expand Up @@ -63,6 +63,9 @@ class TelemetryImpl : public PluginImplBase {
Telemetry::Battery get_battery() const;
Telemetry::FlightMode get_flight_mode() const;
Telemetry::Health get_health() const;
bool get_health_gyrometer() const;
bool get_health_accelerometer() const;
bool get_health_magnetometer() const;
bool get_health_all_ok() const;
Telemetry::RCStatus get_rc_status() const;

Expand Down

0 comments on commit d474466

Please sign in to comment.