This is the vcdMaker demo project. See http://vcdmaker.org for details. vcdMaker is supposed to help engineers to debug their applications and systems. It transforms text log files into the VCD format which can be easily displayed as a waveform.

Dependencies:   mbed vcdLogger vcdSignal

Committer:
ketjow
Date:
Sat Feb 20 20:48:44 2016 +0000
Revision:
1:446154224f92
Parent:
0:9a59cffaafad
Child:
2:a13cde5c679c
vcdMaker Demo release 1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ketjow 1:446154224f92 1 /*!
ketjow 1:446154224f92 2 @file magnetometer.cpp
ketjow 1:446154224f92 3
ketjow 1:446154224f92 4 The implementation of the magnetometer signal class.
ketjow 1:446154224f92 5
ketjow 1:446154224f92 6 @par Full Description
ketjow 1:446154224f92 7 The implementation of the magnetometer signal class.
ketjow 1:446154224f92 8
ketjow 1:446154224f92 9 @if REVISION_HISTORY_INCLUDED
ketjow 1:446154224f92 10 @par Edit History
ketjow 1:446154224f92 11 @li [0] wojciech.rynczuk@wp.pl 20-JAN-2015 Initial file revision.
ketjow 1:446154224f92 12 @endif
ketjow 1:446154224f92 13
ketjow 1:446154224f92 14 @ingroup Signal
ketjow 1:446154224f92 15
ketjow 1:446154224f92 16 @par Copyright (c) MMXV Wojciech Rynczuk
ketjow 1:446154224f92 17
ketjow 1:446154224f92 18 Distributed under MIT License
ketjow 1:446154224f92 19
ketjow 1:446154224f92 20 */
ketjow 1:446154224f92 21
ketjow 0:9a59cffaafad 22 #include "magnetometer.hpp"
ketjow 0:9a59cffaafad 23
ketjow 0:9a59cffaafad 24 Magnetometer::Magnetometer(const string& name, Logger& logger) : Signal(name, 32, logger)
ketjow 0:9a59cffaafad 25 {
ketjow 0:9a59cffaafad 26 m_Magnetometer = new MAG3110(PTE25, PTE24);
ketjow 0:9a59cffaafad 27 m_MagXPrev = 0;
ketjow 0:9a59cffaafad 28 m_MagYPrev = 0;
ketjow 0:9a59cffaafad 29 m_MagZPrev = 0;
ketjow 0:9a59cffaafad 30 m_MagXCurr = 0;;
ketjow 0:9a59cffaafad 31 m_MagYCurr = 0;
ketjow 0:9a59cffaafad 32 m_MagZCurr = 0;
ketjow 0:9a59cffaafad 33 }
ketjow 0:9a59cffaafad 34
ketjow 0:9a59cffaafad 35 Magnetometer::~Magnetometer()
ketjow 0:9a59cffaafad 36 {
ketjow 0:9a59cffaafad 37 delete m_Magnetometer;
ketjow 0:9a59cffaafad 38 }
ketjow 0:9a59cffaafad 39
ketjow 0:9a59cffaafad 40 void Magnetometer::PrintState()
ketjow 0:9a59cffaafad 41 {
ketjow 0:9a59cffaafad 42 string suffix("MagX");
ketjow 0:9a59cffaafad 43 string msg("");
ketjow 0:9a59cffaafad 44 int32_t time_ref = 0;
ketjow 0:9a59cffaafad 45
ketjow 0:9a59cffaafad 46 m_MagXCurr = m_Magnetometer->readVal(MAG_OUT_X_MSB);
ketjow 0:9a59cffaafad 47 m_MagYCurr = m_Magnetometer->readVal(MAG_OUT_Y_MSB);
ketjow 0:9a59cffaafad 48 m_MagZCurr = m_Magnetometer->readVal(MAG_OUT_Z_MSB);
ketjow 0:9a59cffaafad 49 if ( (CheckFilter()) || \
ketjow 0:9a59cffaafad 50 (fabs((float)(m_MagXCurr - m_MagXPrev)) > 50) || \
ketjow 0:9a59cffaafad 51 (fabs((float)(m_MagYCurr - m_MagYPrev)) > 50) || \
ketjow 0:9a59cffaafad 52 (fabs((float)(m_MagZCurr - m_MagZPrev)) > 50))
ketjow 0:9a59cffaafad 53 {
ketjow 0:9a59cffaafad 54 PrintVector(m_MagXCurr, suffix, msg, time_ref);
ketjow 0:9a59cffaafad 55 suffix = "MagY";
ketjow 0:9a59cffaafad 56 time_ref = 0;
ketjow 0:9a59cffaafad 57 PrintVector(m_MagYCurr, suffix, msg, time_ref);
ketjow 0:9a59cffaafad 58 suffix = "MagZ";
ketjow 0:9a59cffaafad 59 time_ref = 0;
ketjow 0:9a59cffaafad 60 PrintVector(m_MagZCurr, suffix, msg, time_ref);
ketjow 0:9a59cffaafad 61 m_MagXPrev = m_MagXCurr;
ketjow 0:9a59cffaafad 62 m_MagYPrev = m_MagYCurr;
ketjow 0:9a59cffaafad 63 m_MagZPrev = m_MagZCurr;
ketjow 0:9a59cffaafad 64 }
ketjow 0:9a59cffaafad 65 }