Wojciech Rynczuk / Mbed 2 deprecated vcdMaker_Demo_DISCO_L476

Dependencies:   BSP_DISCO_L476VG COMPASS_DISCO_L476VG mbed vcdLogger vcdSignal

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers magnetometer.cpp Source File

magnetometer.cpp

Go to the documentation of this file.
00001 /*!
00002   @file magnetometer.cpp
00003 
00004   The implementation of the magnetometer signal class.
00005 
00006   @par Full Description
00007   The implementation of the magnetometer signal class.
00008 
00009   @if REVISION_HISTORY_INCLUDED
00010   @par Edit History
00011   @li [0]    wojciech.rynczuk@wp.pl    04-MAR-2016    Initial file revision.
00012   @endif
00013 
00014   @ingroup Signal
00015 
00016   The MIT License (MIT)
00017   Copyright (c) 2016 Wojciech Rynczuk
00018 
00019 */
00020 
00021 #include "magnetometer.hpp "
00022 
00023 Magnetometer::Magnetometer(const string& name, COMPASS_DISCO_L476VG& compass, Logger& logger) : Signal(name, 32, logger), m_pCompass(&compass)
00024 {
00025     m_MagXYZ[0] = 0;
00026     m_MagXYZ[1] = 0;
00027     m_MagXYZ[2] = 0;
00028     m_PrevMagXYZ[0] = 0;
00029     m_PrevMagXYZ[1] = 0;
00030     m_PrevMagXYZ[2] = 0;
00031 }
00032 
00033 Magnetometer::~Magnetometer()
00034 {
00035 }
00036   
00037 void Magnetometer::PrintState()
00038 {
00039     string  suffix("MagX");
00040     string  msg("");
00041     int32_t time_ref = 0;
00042     
00043     m_pCompass->MagGetXYZ(m_MagXYZ);
00044     if ( (CheckFilter()) || \
00045          (fabs((float)(m_MagXYZ[0] - m_PrevMagXYZ[0])) > 50) || \
00046          (fabs((float)(m_MagXYZ[1] - m_PrevMagXYZ[1])) > 50) || \
00047          (fabs((float)(m_MagXYZ[2] - m_PrevMagXYZ[2])) > 50))
00048     {
00049         PrintReal(m_MagXYZ[0], suffix, msg, time_ref);
00050         suffix = "MagY";
00051         time_ref = 0;
00052         PrintReal(m_MagXYZ[1], suffix, msg, time_ref);
00053         suffix = "MagZ";
00054         time_ref = 0;
00055         PrintReal(m_MagXYZ[2], suffix, msg, time_ref);
00056         m_PrevMagXYZ[0] = m_MagXYZ[0];
00057         m_PrevMagXYZ[1] = m_MagXYZ[1];
00058         m_PrevMagXYZ[2] = m_MagXYZ[2];
00059     }
00060 }