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
Signals/magnetometer.cpp@3:6d5e16097db0, 2016-12-07 (annotated)
- Committer:
- ketjow
- Date:
- Wed Dec 07 09:16:38 2016 +0000
- Revision:
- 3:6d5e16097db0
- Parent:
- 2:a13cde5c679c
Sync signal added
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:a13cde5c679c | 16 | The MIT License (MIT) |
ketjow | 2:a13cde5c679c | 17 | Copyright (c) 2016 Wojciech Rynczuk |
ketjow | 1:446154224f92 | 18 | |
ketjow | 1:446154224f92 | 19 | */ |
ketjow | 1:446154224f92 | 20 | |
ketjow | 0:9a59cffaafad | 21 | #include "magnetometer.hpp" |
ketjow | 0:9a59cffaafad | 22 | |
ketjow | 0:9a59cffaafad | 23 | Magnetometer::Magnetometer(const string& name, Logger& logger) : Signal(name, 32, logger) |
ketjow | 0:9a59cffaafad | 24 | { |
ketjow | 0:9a59cffaafad | 25 | m_Magnetometer = new MAG3110(PTE25, PTE24); |
ketjow | 0:9a59cffaafad | 26 | m_MagXPrev = 0; |
ketjow | 0:9a59cffaafad | 27 | m_MagYPrev = 0; |
ketjow | 0:9a59cffaafad | 28 | m_MagZPrev = 0; |
ketjow | 0:9a59cffaafad | 29 | m_MagXCurr = 0;; |
ketjow | 0:9a59cffaafad | 30 | m_MagYCurr = 0; |
ketjow | 0:9a59cffaafad | 31 | m_MagZCurr = 0; |
ketjow | 0:9a59cffaafad | 32 | } |
ketjow | 0:9a59cffaafad | 33 | |
ketjow | 0:9a59cffaafad | 34 | Magnetometer::~Magnetometer() |
ketjow | 0:9a59cffaafad | 35 | { |
ketjow | 0:9a59cffaafad | 36 | delete m_Magnetometer; |
ketjow | 0:9a59cffaafad | 37 | } |
ketjow | 0:9a59cffaafad | 38 | |
ketjow | 0:9a59cffaafad | 39 | void Magnetometer::PrintState() |
ketjow | 0:9a59cffaafad | 40 | { |
ketjow | 0:9a59cffaafad | 41 | string suffix("MagX"); |
ketjow | 0:9a59cffaafad | 42 | string msg(""); |
ketjow | 0:9a59cffaafad | 43 | int32_t time_ref = 0; |
ketjow | 0:9a59cffaafad | 44 | |
ketjow | 0:9a59cffaafad | 45 | m_MagXCurr = m_Magnetometer->readVal(MAG_OUT_X_MSB); |
ketjow | 0:9a59cffaafad | 46 | m_MagYCurr = m_Magnetometer->readVal(MAG_OUT_Y_MSB); |
ketjow | 0:9a59cffaafad | 47 | m_MagZCurr = m_Magnetometer->readVal(MAG_OUT_Z_MSB); |
ketjow | 0:9a59cffaafad | 48 | if ( (CheckFilter()) || \ |
ketjow | 0:9a59cffaafad | 49 | (fabs((float)(m_MagXCurr - m_MagXPrev)) > 50) || \ |
ketjow | 0:9a59cffaafad | 50 | (fabs((float)(m_MagYCurr - m_MagYPrev)) > 50) || \ |
ketjow | 0:9a59cffaafad | 51 | (fabs((float)(m_MagZCurr - m_MagZPrev)) > 50)) |
ketjow | 0:9a59cffaafad | 52 | { |
ketjow | 0:9a59cffaafad | 53 | PrintVector(m_MagXCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 54 | suffix = "MagY"; |
ketjow | 0:9a59cffaafad | 55 | time_ref = 0; |
ketjow | 0:9a59cffaafad | 56 | PrintVector(m_MagYCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 57 | suffix = "MagZ"; |
ketjow | 0:9a59cffaafad | 58 | time_ref = 0; |
ketjow | 0:9a59cffaafad | 59 | PrintVector(m_MagZCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 60 | m_MagXPrev = m_MagXCurr; |
ketjow | 0:9a59cffaafad | 61 | m_MagYPrev = m_MagYCurr; |
ketjow | 0:9a59cffaafad | 62 | m_MagZPrev = m_MagZCurr; |
ketjow | 0:9a59cffaafad | 63 | } |
ketjow | 0:9a59cffaafad | 64 | } |