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.
Diff: Button.cpp
- Revision:
- 3:03aea89f2a5c
- Parent:
- 1:3385a1ea4a7d
- Child:
- 4:d54859273629
--- a/Button.cpp Thu Mar 16 13:49:03 2017 +0000
+++ b/Button.cpp Sat May 13 18:15:11 2017 +0000
@@ -1,3 +1,23 @@
+/**
+* @file Button.cpp
+* @brief Button library
+* @author Mark Peter Vargha, vmp@varghamarkpeter.hu
+*
+* Copyright (c) 2017
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
#include "Button.h"
void Button::isrFall(void)
@@ -18,7 +38,7 @@
if (_prevState == 0) //First
{
_timer.start();
- if (_fireUpDown && _onButtonEvent != NULL) _onButtonEvent(BUTTON_DOWN, _pinName);
+ if (_fireUpDown && _onButtonEvent) _onButtonEvent(BUTTON_DOWN, _pinName);
}
_autoRepeatStarter.detach();
if (_autoRepeatTime > 0) _autoRepeatStarter.attach(Callback<void()>(this, &Button::startAutoRepeat), (_longPressTime / 1000.0f));
@@ -30,8 +50,8 @@
_timer.stop();
_tickerAutoRepeat.detach();
_autoRepeatStarter.detach();
- if (_fireUpDown && _onButtonEvent != NULL) _onButtonEvent(BUTTON_UP, _pinName);
- if (_prevState == 1 && _onButtonEvent != NULL)
+ if (_fireUpDown && _onButtonEvent) _onButtonEvent(BUTTON_UP, _pinName);
+ if (_prevState == 1 && _onButtonEvent)
{
if (_timer.read_ms() >= _longPressTime) //Long press
{
@@ -54,5 +74,5 @@
void Button::autoRepeat(void)
{
- if (_onButtonEvent != NULL) _onButtonEvent(BUTTON_PRESS, _pinName);
+ if (_onButtonEvent) _onButtonEvent(BUTTON_PRESS, _pinName);
}