Wojciech Rynczuk / Mbed 2 deprecated vcdMaker_Demo

Dependencies:   mbed vcdLogger vcdSignal

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers light.cpp Source File

light.cpp

Go to the documentation of this file.
00001 /*!
00002   @file light.cpp
00003 
00004   The implementation of the light sensor signal class.
00005 
00006   @par Full Description
00007   The implementation of the light sensor signal class.
00008 
00009   @if REVISION_HISTORY_INCLUDED
00010   @par Edit History
00011   @li [0]    wojciech.rynczuk@wp.pl    20-JAN-2015    Initial file revision.
00012   @li [1]    wojciech.rynczuk@wp.pl    04-MAR-2016    Fixed real printing.
00013   @endif
00014 
00015   @ingroup Signal
00016 
00017   The MIT License (MIT)
00018   Copyright (c) 2016 Wojciech Rynczuk
00019 
00020 */
00021 
00022 #include "light.hpp "
00023 
00024 Light::Light(const string& name, const PinName pin, Logger& logger) : Signal(name, 1, logger), AnalogIn(pin)
00025 {
00026     m_LightPrev = 0;
00027     m_LightCurr = 0;
00028 }
00029   
00030 void Light::PrintState()
00031 {
00032     string  suffix("");
00033     string  msg("");
00034     int32_t time_ref = 0;
00035     
00036     m_LightCurr = read();
00037     if ( (CheckFilter()) || \
00038          (fabs((m_LightCurr - m_LightPrev)) > 0.1))
00039     {
00040         PrintReal(m_LightCurr, suffix, msg, time_ref);
00041         m_LightPrev = m_LightCurr;
00042     }
00043 }