Wojciech Rynczuk / Mbed 2 deprecated vcdMaker_Demo

Dependencies:   mbed vcdLogger vcdSignal

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers button.cpp Source File

button.cpp

Go to the documentation of this file.
00001 /*!
00002   @file button.cpp
00003 
00004   The implementation of the button signal class.
00005 
00006   @par Full Description
00007   The implementation of the button 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   @endif
00013 
00014   @ingroup Signal
00015 
00016   The MIT License (MIT)
00017   Copyright (c) 2016 Wojciech Rynczuk
00018 
00019 */
00020 
00021 #include "button.hpp "
00022   
00023 Button::Button(const string& name, const PinName pin, Logger& logger) : DigitalIn(pin), Signal(name,1,logger)
00024 {
00025 }
00026     
00027 void Button::PrintState()
00028 {
00029   string  suffix("");
00030   int32_t time_ref = 0;
00031   if (read())
00032   {
00033     string msg("Key released");
00034     PrintVector(0, suffix, msg, time_ref);
00035   }
00036   else
00037   {
00038     string msg("Key pressed");
00039     PrintVector(1, suffix, msg, time_ref);
00040   }
00041 }