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.
Countdown.h
00001 /******************************************************************************* 00002 * Copyright (c) 2014 IBM Corp. 00003 * 00004 * All rights reserved. This program and the accompanying materials 00005 * are made available under the terms of the Eclipse Public License v1.0 00006 * and Eclipse Distribution License v1.0 which accompany this distribution. 00007 * 00008 * The Eclipse Public License is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * and the Eclipse Distribution License is available at 00011 * http://www.eclipse.org/org/documents/edl-v10.php. 00012 * 00013 * Contributors: 00014 * Ian Craggs - initial API and implementation and/or initial documentation 00015 *******************************************************************************/ 00016 00017 #if !defined(COUNTDOWN_H) 00018 #define COUNTDOWN_H 00019 00020 class Countdown 00021 { 00022 public: 00023 Countdown() 00024 { 00025 interval_end_ms = 0L; 00026 } 00027 00028 Countdown(int ms) 00029 { 00030 countdown_ms(ms); 00031 } 00032 00033 bool expired() 00034 { 00035 return (interval_end_ms > 0L) && (millis() >= interval_end_ms); 00036 } 00037 00038 void countdown_ms(unsigned long ms) 00039 { 00040 interval_end_ms = millis() + ms; 00041 } 00042 00043 void countdown(int seconds) 00044 { 00045 countdown_ms((unsigned long)seconds * 1000L); 00046 } 00047 00048 int left_ms() 00049 { 00050 return interval_end_ms - millis(); 00051 } 00052 00053 private: 00054 unsigned long interval_end_ms; 00055 }; 00056 00057 #endif
Generated on Wed Jul 13 2022 10:46:02 by
1.7.2