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 max32630fthr
LEDStatus.h
00001 /******************************************************************************* 00002 * Author: Shaun Kelsey, shaun.kelsey@maximintegrated.com 00003 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a 00006 * copy of this software and associated documentation files (the "Software"), 00007 * to deal in the Software without restriction, including without limitation 00008 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00009 * and/or sell copies of the Software, and to permit persons to whom the 00010 * Software is furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included 00013 * in all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00016 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00018 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00019 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00020 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00021 * OTHER DEALINGS IN THE SOFTWARE. 00022 * 00023 * Except as contained in this notice, the name of Maxim Integrated 00024 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00025 * Products, Inc. Branding Policy. 00026 * 00027 * The mere transfer of this software does not imply any licenses 00028 * of trade secrets, proprietary technology, copyrights, patents, 00029 * trademarks, maskwork rights, or any other form of intellectual 00030 * property whatsoever. Maxim Integrated Products, Inc. retains all 00031 * ownership rights. 00032 ******************************************************************************* 00033 */ 00034 #ifndef _LEDSTATUS_H_ 00035 #define _LEDSTATUS_H_ 00036 #include "mbed.h" 00037 00038 class LEDStatus 00039 { 00040 public: 00041 00042 /** Create an LED_Status controller 00043 * 00044 * @param red PinName of red LED 00045 * @param rstate Initial state of red LED 00046 * @param green PinName of green LED 00047 * @param gstate Initial state of green LED 00048 * @param blue PinName of blue LED 00049 * @param bstate Initial state of blue LED 00050 */ 00051 LEDStatus(PinName red, int rstate, PinName green, int gstate, PinName blue, int bstate); 00052 00053 /** Set the active state of each LED 00054 * 00055 * @param rstate active state of red LED 00056 * @param gstate active state of green LED 00057 * @param bstate active state of blue LED 00058 */ 00059 void set_state(int rstate, int gstate, int bstate); 00060 00061 /** Set and keep the LEDs in their active state */ 00062 void solid(); 00063 00064 /** Set the LEDs to toggle between their active state and their off state 00065 * 00066 * @param ontime The amount of time (in milliseconds) to remain in the active state 00067 * @param offtime The amount of time (in milliseconds) to remain off 00068 * @param nb The number of times to blink before remaining in the off state 00069 * Set to -1 to blink indefinitely 00070 * 00071 */ 00072 void blink(int ontime, int offtime, int nb = -1); 00073 00074 /** Set the LEDs to toggle between their active state and their off state 00075 * 00076 * @param period The period of each blink (in milliseconds) 00077 * @param offtime The percentage of the period during which the LEDs will be in their active state 00078 * @param nb The number of times to blink before remaining in the off state 00079 * Set to -1 to blink indefinitely 00080 */ 00081 void blink(int period, float duty, int nb = -1); 00082 00083 /** Get whether LEDState is in the blinking state 00084 */ 00085 bool is_blinking(); 00086 00087 /** Called in main loop of program to advance the state of the class 00088 * @detail Instead of using a Ticker and generating additional interrupts and overhead, 00089 * LEDStatus relies on update being called at a decent interval in order 00090 * to advance its interval time keeping and blink LEDs and the correct rate. 00091 * If only using solid() mode, update() does not need to be called. 00092 */ 00093 void update(); 00094 00095 private: 00096 00097 DigitalOut rLED; 00098 DigitalOut gLED; 00099 DigitalOut bLED; 00100 00101 int r_act; 00102 int g_act; 00103 int b_act; 00104 00105 bool blinking; 00106 bool bs; 00107 int count; 00108 int total; 00109 00110 uint64_t ont_us; 00111 uint64_t offt_us; 00112 00113 Timer timer; 00114 00115 }; 00116 00117 #endif
Generated on Sat Jul 16 2022 17:57:31 by
1.7.2
Heart Rate SpO2 Algorithm EvKit Health Monitor Development System Board MAXREFDES220