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@0:9a59cffaafad, 2016-02-12 (annotated)
- Committer:
- ketjow
- Date:
- Fri Feb 12 21:38:04 2016 +0000
- Revision:
- 0:9a59cffaafad
- Child:
- 1:446154224f92
vcdMaker demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ketjow | 0:9a59cffaafad | 1 | #include "magnetometer.hpp" |
ketjow | 0:9a59cffaafad | 2 | |
ketjow | 0:9a59cffaafad | 3 | Magnetometer::Magnetometer(const string& name, Logger& logger) : Signal(name, 32, logger) |
ketjow | 0:9a59cffaafad | 4 | { |
ketjow | 0:9a59cffaafad | 5 | m_Magnetometer = new MAG3110(PTE25, PTE24); |
ketjow | 0:9a59cffaafad | 6 | m_MagXPrev = 0; |
ketjow | 0:9a59cffaafad | 7 | m_MagYPrev = 0; |
ketjow | 0:9a59cffaafad | 8 | m_MagZPrev = 0; |
ketjow | 0:9a59cffaafad | 9 | m_MagXCurr = 0;; |
ketjow | 0:9a59cffaafad | 10 | m_MagYCurr = 0; |
ketjow | 0:9a59cffaafad | 11 | m_MagZCurr = 0; |
ketjow | 0:9a59cffaafad | 12 | } |
ketjow | 0:9a59cffaafad | 13 | |
ketjow | 0:9a59cffaafad | 14 | Magnetometer::~Magnetometer() |
ketjow | 0:9a59cffaafad | 15 | { |
ketjow | 0:9a59cffaafad | 16 | delete m_Magnetometer; |
ketjow | 0:9a59cffaafad | 17 | } |
ketjow | 0:9a59cffaafad | 18 | |
ketjow | 0:9a59cffaafad | 19 | void Magnetometer::PrintState() |
ketjow | 0:9a59cffaafad | 20 | { |
ketjow | 0:9a59cffaafad | 21 | string suffix("MagX"); |
ketjow | 0:9a59cffaafad | 22 | string msg(""); |
ketjow | 0:9a59cffaafad | 23 | int32_t time_ref = 0; |
ketjow | 0:9a59cffaafad | 24 | |
ketjow | 0:9a59cffaafad | 25 | m_MagXCurr = m_Magnetometer->readVal(MAG_OUT_X_MSB); |
ketjow | 0:9a59cffaafad | 26 | m_MagYCurr = m_Magnetometer->readVal(MAG_OUT_Y_MSB); |
ketjow | 0:9a59cffaafad | 27 | m_MagZCurr = m_Magnetometer->readVal(MAG_OUT_Z_MSB); |
ketjow | 0:9a59cffaafad | 28 | if ( (CheckFilter()) || \ |
ketjow | 0:9a59cffaafad | 29 | (fabs((float)(m_MagXCurr - m_MagXPrev)) > 50) || \ |
ketjow | 0:9a59cffaafad | 30 | (fabs((float)(m_MagYCurr - m_MagYPrev)) > 50) || \ |
ketjow | 0:9a59cffaafad | 31 | (fabs((float)(m_MagZCurr - m_MagZPrev)) > 50)) |
ketjow | 0:9a59cffaafad | 32 | { |
ketjow | 0:9a59cffaafad | 33 | PrintVector(m_MagXCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 34 | suffix = "MagY"; |
ketjow | 0:9a59cffaafad | 35 | time_ref = 0; |
ketjow | 0:9a59cffaafad | 36 | PrintVector(m_MagYCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 37 | suffix = "MagZ"; |
ketjow | 0:9a59cffaafad | 38 | time_ref = 0; |
ketjow | 0:9a59cffaafad | 39 | PrintVector(m_MagZCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 40 | m_MagXPrev = m_MagXCurr; |
ketjow | 0:9a59cffaafad | 41 | m_MagYPrev = m_MagYCurr; |
ketjow | 0:9a59cffaafad | 42 | m_MagZPrev = m_MagZCurr; |
ketjow | 0:9a59cffaafad | 43 | } |
ketjow | 0:9a59cffaafad | 44 | } |