Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_L476VG COMPASS_DISCO_L476VG mbed vcdLogger vcdSignal
Signals/magnetometer.cpp
- Committer:
- ketjow
- Date:
- 2016-12-07
- Revision:
- 2:fcfb6ced9c00
- Parent:
- 0:936379a8793e
File content as of revision 2:fcfb6ced9c00:
/*!
@file magnetometer.cpp
The implementation of the magnetometer signal class.
@par Full Description
The implementation of the magnetometer signal class.
@if REVISION_HISTORY_INCLUDED
@par Edit History
@li [0] wojciech.rynczuk@wp.pl 04-MAR-2016 Initial file revision.
@endif
@ingroup Signal
The MIT License (MIT)
Copyright (c) 2016 Wojciech Rynczuk
*/
#include "magnetometer.hpp"
Magnetometer::Magnetometer(const string& name, COMPASS_DISCO_L476VG& compass, Logger& logger) : Signal(name, 32, logger), m_pCompass(&compass)
{
m_MagXYZ[0] = 0;
m_MagXYZ[1] = 0;
m_MagXYZ[2] = 0;
m_PrevMagXYZ[0] = 0;
m_PrevMagXYZ[1] = 0;
m_PrevMagXYZ[2] = 0;
}
Magnetometer::~Magnetometer()
{
}
void Magnetometer::PrintState()
{
string suffix("MagX");
string msg("");
int32_t time_ref = 0;
m_pCompass->MagGetXYZ(m_MagXYZ);
if ( (CheckFilter()) || \
(fabs((float)(m_MagXYZ[0] - m_PrevMagXYZ[0])) > 50) || \
(fabs((float)(m_MagXYZ[1] - m_PrevMagXYZ[1])) > 50) || \
(fabs((float)(m_MagXYZ[2] - m_PrevMagXYZ[2])) > 50))
{
PrintReal(m_MagXYZ[0], suffix, msg, time_ref);
suffix = "MagY";
time_ref = 0;
PrintReal(m_MagXYZ[1], suffix, msg, time_ref);
suffix = "MagZ";
time_ref = 0;
PrintReal(m_MagXYZ[2], suffix, msg, time_ref);
m_PrevMagXYZ[0] = m_MagXYZ[0];
m_PrevMagXYZ[1] = m_MagXYZ[1];
m_PrevMagXYZ[2] = m_MagXYZ[2];
}
}