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: PololuLedStrip mbed
Pulser.cpp
00001 #include "Pulser.h" 00002 00003 Pulser::Pulser(PinName _pin): 00004 out(_pin) 00005 { 00006 lastUpdate = 0; 00007 value = 65535; 00008 direction = -256; 00009 timer.start(); 00010 } 00011 00012 void Pulser::pulse() { 00013 uint32_t now = timer.read_ms(); 00014 while (now - lastUpdate > delay) { 00015 lastUpdate += delay; 00016 value += direction; 00017 if (value >= 69120 || value <= 53760) direction = -direction; 00018 } 00019 if (value < 65535) out.write_u16(value); 00020 } 00021 00022 void Pulser::steady() { 00023 out.write_u16(32768); 00024 } 00025 00026 void Pulser::off() { 00027 out.write_u16(0); 00028 value = 65535; 00029 direction = -256; 00030 lastUpdate = timer.read_ms(); 00031 }
Generated on Tue Jul 19 2022 02:43:48 by
1.7.2