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.
LEDControl.cpp
- Committer:
- wakestrap
- Date:
- 2015-07-09
- Revision:
- 0:8aa281e74b4a
- Child:
- 1:1f6bd61833a3
File content as of revision 0:8aa281e74b4a:
#include "LEDControl.h" #include "mbed.h" LEDControl::LEDControl(PinName pin, Timer *time): _led(pin), _nextBlink( 0 ), _Time ( time ) { _led = 0; } void LEDControl::blink(float rate) { long _currentTime = _Time->read_ms(); if(_currentTime - _nextBlink > 0) { if(_currentTime > 20000000) { _Time->reset(); _currentTime = 0; } _led = !_led; _nextBlink = 1000/rate + _currentTime; } } void LEDControl::off() { _led = 0; } void LEDControl::on() { _led = 1; } void LEDControl::toggle() { _led = !_led; }