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/light.cpp

Committer:
ketjow
Date:
2016-12-07
Revision:
3:6d5e16097db0
Parent:
2:a13cde5c679c

File content as of revision 3:6d5e16097db0:

/*!
  @file light.cpp

  The implementation of the light sensor signal class.

  @par Full Description
  The implementation of the light sensor signal class.

  @if REVISION_HISTORY_INCLUDED
  @par Edit History
  @li [0]    wojciech.rynczuk@wp.pl    20-JAN-2015    Initial file revision.
  @li [1]    wojciech.rynczuk@wp.pl    04-MAR-2016    Fixed real printing.
  @endif

  @ingroup Signal

  The MIT License (MIT)
  Copyright (c) 2016 Wojciech Rynczuk

*/

#include "light.hpp"

Light::Light(const string& name, const PinName pin, Logger& logger) : Signal(name, 1, logger), AnalogIn(pin)
{
    m_LightPrev = 0;
    m_LightCurr = 0;
}
  
void Light::PrintState()
{
    string  suffix("");
    string  msg("");
    int32_t time_ref = 0;
    
    m_LightCurr = read();
    if ( (CheckFilter()) || \
         (fabs((m_LightCurr - m_LightPrev)) > 0.1))
    {
        PrintReal(m_LightCurr, suffix, msg, time_ref);
        m_LightPrev = m_LightCurr;
    }
}