Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBDevice mbed-rtos mbed
Fork of JoyStick by
Button.cpp
00001 #include "Button.h" 00002 00003 00004 Button::Button(PinName pin, bool reversed, bool pullUp) : _digitalIn(new DigitalIn(pin)), _value(false), _reversed(reversed) 00005 { 00006 _digitalIn->mode(pullUp?PullUp:PullDown); 00007 _lastValue=_digitalIn; 00008 } 00009 00010 Button::~Button() 00011 { 00012 delete(_digitalIn); 00013 } 00014 00015 void Button::measure () 00016 { 00017 _value = _digitalIn->read() ^_reversed; 00018 } 00019 00020 bool Button::getData() const 00021 { 00022 return _value; 00023 } 00024 00025 bool Button::getIsChanged() 00026 { 00027 const bool lv = _lastValue; 00028 _lastValue = _value; 00029 return _value ^ lv; 00030 }
Generated on Wed Jul 13 2022 20:21:10 by
1.7.2
