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.
ToggleFlash Class Reference
LED Toggle-Flashing (50% duty) library based on Ticker interrupts instead of wait. More...
#include <ToggleFlash.h>
| Public Member Functions | |
| ToggleFlash (PinName pin) | |
| Create a Flasherer object connected to a pin. | |
| ToggleFlash (PinName pin, float time) | |
| Create a Flasherer object connected to a pin and set the on-off time. | |
| void | setTime (float time) | 
| Set the on-off time ex. | |
| float | getTime () | 
| Retrieve the current time setting of the flasher object. | |
| void | enable () | 
| Enable the flasher to start toggling pin. | |
| void | disableTo (int state) | 
| Disable the flasher and give the pin a constant state. | |
| int | readFlasher () | 
| Return the current status of the flasher. | |
| int | read () | 
| Return the current state of the pin. | |
| ToggleFlash & | operator= (int state) | 
| An operator shorthand for disableTo(int state) to give the pin a constant state. | |
| operator int () | |
| An operator shorthand for read() to read pin's current state. | |
Detailed Description
LED Toggle-Flashing (50% duty) library based on Ticker interrupts instead of wait.
Example
Flasher myflasher(p20, 1.5); // A flasher object attached to pin 20 with 1.5 second timing int main() { while (1) { myflasher.enable(); // Turn on flasher wait(3); // More code, simulated by wait myflasher.disableTo(1); // Hold pin high myflasher.setTime(2); // Set new timing wait(3); myflasher.enable(); // Resume flashing wait(3); myflasher = 0; // Hold pin low (shorthand for disableTo(int state)) } }
Definition at line 47 of file ToggleFlash.h.
Constructor & Destructor Documentation
| ToggleFlash | ( | PinName | pin ) | 
Create a Flasherer object connected to a pin.
- Parameters:
- 
  pin The pin to which the Flasherer is attached 
Definition at line 25 of file ToggleFlash.cpp.
| ToggleFlash | ( | PinName | pin, | 
| float | time | ||
| ) | 
Create a Flasherer object connected to a pin and set the on-off time.
- Parameters:
- 
  pin The pin to which the Flasherer is attached time The specified on-off time in seconds 
Definition at line 28 of file ToggleFlash.cpp.
Member Function Documentation
| void disableTo | ( | int | state ) | 
Disable the flasher and give the pin a constant state.
- Parameters:
- 
  state 1 or 0 for constant on or constant off 
Definition at line 48 of file ToggleFlash.cpp.
| void enable | ( | ) | 
Enable the flasher to start toggling pin.
Definition at line 43 of file ToggleFlash.cpp.
| float getTime | ( | ) | 
Retrieve the current time setting of the flasher object.
- Returns:
- The current on-off time of the Flasher object
Definition at line 40 of file ToggleFlash.cpp.
| operator int | ( | ) | 
An operator shorthand for read() to read pin's current state.
Definition at line 91 of file ToggleFlash.h.
| ToggleFlash& operator= | ( | int | state ) | 
An operator shorthand for disableTo(int state) to give the pin a constant state.
Definition at line 85 of file ToggleFlash.h.
| int read | ( | ) | 
Return the current state of the pin.
- Returns:
- 1 or 0 for currently set high or low
Definition at line 56 of file ToggleFlash.cpp.
| int readFlasher | ( | ) | 
Return the current status of the flasher.
- Returns:
- 1 or 0 for flasher enabled or flasher disabled
Definition at line 53 of file ToggleFlash.cpp.
| void setTime | ( | float | time ) | 
Set the on-off time ex.
1.5 means on for 1.5 seconds off for 1.5 seconds
- Parameters:
- 
  time The specified on-off time in seconds 
Definition at line 32 of file ToggleFlash.cpp.
Generated on Wed Jul 20 2022 14:06:48 by
 1.7.2
 1.7.2