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
00001 #include "LEDControl.h" 00002 #include "mbed.h" 00003 00004 LEDControl::LEDControl(PinName pin, Timer *time): 00005 _led(pin), 00006 _nextBlink( 0 ), 00007 _Time ( time ) 00008 { 00009 _led = 0; 00010 } 00011 00012 void LEDControl::blink(float rate) { 00013 long _currentTime = _Time->read_ms(); 00014 00015 if(_nextBlink - _currentTime > 5000) 00016 { 00017 _nextBlink = 0; 00018 } 00019 00020 if(_currentTime - _nextBlink > 0) 00021 { 00022 if(_currentTime > 30000) 00023 { 00024 _Time->reset(); 00025 _currentTime = 0; 00026 } 00027 _led = !_led; 00028 _nextBlink = 1000/rate + _currentTime; 00029 } 00030 } 00031 void LEDControl::off() { 00032 _led = 0; 00033 } 00034 00035 void LEDControl::on() { 00036 _led = 1; 00037 } 00038 00039 void LEDControl::toggle() { 00040 _led = !_led; 00041 }
Generated on Thu Jul 21 2022 15:37:04 by
1.7.2