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/accelerometer.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 "accelerometer.hpp" |
ketjow | 0:9a59cffaafad | 2 | |
ketjow | 0:9a59cffaafad | 3 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
ketjow | 0:9a59cffaafad | 4 | |
ketjow | 0:9a59cffaafad | 5 | Accelerometer::Accelerometer(const string& name, Logger& logger) : Signal(name, 32, logger) |
ketjow | 0:9a59cffaafad | 6 | { |
ketjow | 0:9a59cffaafad | 7 | m_Accelerometer = new MMA8451Q(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
ketjow | 0:9a59cffaafad | 8 | m_Filter = 1; |
ketjow | 0:9a59cffaafad | 9 | m_AccXPrev = 0; |
ketjow | 0:9a59cffaafad | 10 | m_AccYPrev = 0; |
ketjow | 0:9a59cffaafad | 11 | m_AccZPrev = 0; |
ketjow | 0:9a59cffaafad | 12 | m_AccXCurr = 0; |
ketjow | 0:9a59cffaafad | 13 | m_AccYCurr = 0; |
ketjow | 0:9a59cffaafad | 14 | m_AccZCurr = 0; |
ketjow | 0:9a59cffaafad | 15 | } |
ketjow | 0:9a59cffaafad | 16 | |
ketjow | 0:9a59cffaafad | 17 | Accelerometer::~Accelerometer() |
ketjow | 0:9a59cffaafad | 18 | { |
ketjow | 0:9a59cffaafad | 19 | delete m_Accelerometer; |
ketjow | 0:9a59cffaafad | 20 | } |
ketjow | 0:9a59cffaafad | 21 | |
ketjow | 0:9a59cffaafad | 22 | void Accelerometer::PrintState() |
ketjow | 0:9a59cffaafad | 23 | { |
ketjow | 0:9a59cffaafad | 24 | string suffix("AccX"); |
ketjow | 0:9a59cffaafad | 25 | string msg("f"); |
ketjow | 0:9a59cffaafad | 26 | int32_t time_ref = 0; |
ketjow | 0:9a59cffaafad | 27 | |
ketjow | 0:9a59cffaafad | 28 | m_AccXCurr = m_Accelerometer->getAccX(); |
ketjow | 0:9a59cffaafad | 29 | m_AccYCurr = m_Accelerometer->getAccY(); |
ketjow | 0:9a59cffaafad | 30 | m_AccZCurr = m_Accelerometer->getAccZ(); |
ketjow | 0:9a59cffaafad | 31 | if ( (CheckFilter()) || \ |
ketjow | 0:9a59cffaafad | 32 | (fabs(m_AccXCurr - m_AccXPrev) > 0.1) || \ |
ketjow | 0:9a59cffaafad | 33 | (fabs(m_AccYCurr - m_AccYPrev) > 0.1) || \ |
ketjow | 0:9a59cffaafad | 34 | (fabs(m_AccZCurr - m_AccZPrev) > 0.1)) |
ketjow | 0:9a59cffaafad | 35 | { |
ketjow | 0:9a59cffaafad | 36 | PrintReal(m_AccXCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 37 | suffix = "AccY"; |
ketjow | 0:9a59cffaafad | 38 | PrintReal(m_AccYCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 39 | suffix = "AccZ"; |
ketjow | 0:9a59cffaafad | 40 | PrintReal(m_AccZCurr, suffix, msg, time_ref); |
ketjow | 0:9a59cffaafad | 41 | m_AccXPrev = m_AccXCurr; |
ketjow | 0:9a59cffaafad | 42 | m_AccYPrev = m_AccYCurr; |
ketjow | 0:9a59cffaafad | 43 | m_AccZPrev = m_AccZCurr; |
ketjow | 0:9a59cffaafad | 44 | } |
ketjow | 0:9a59cffaafad | 45 | } |