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.
Buzzer.cpp
00001 #include "Buzzer.h" 00002 00003 Buzzer::Buzzer(PinName pin) 00004 { 00005 _buzzer = new DigitalOut(pin); 00006 //_ticker = new Ticker(); 00007 } 00008 00009 Buzzer::Buzzer(PinName pin, float period) 00010 { 00011 _buzzer = new DigitalOut(pin); 00012 _period = period; 00013 //_ticker = new Ticker(); 00014 } 00015 00016 Buzzer::~Buzzer() 00017 { 00018 delete _buzzer; 00019 } 00020 00021 void Buzzer::definirPeriode(float period) 00022 { 00023 _period = period; 00024 } 00025 00026 void Buzzer::changerPeriode(float period) 00027 { 00028 definirPeriode(period); 00029 demarrer(); 00030 } 00031 00032 void Buzzer::demarrer() 00033 { 00034 _ticker.attach(callback(this, &Buzzer::bipper), _period); 00035 } 00036 00037 void Buzzer::arreter() 00038 { 00039 _ticker.detach(); 00040 } 00041 00042 void Buzzer::bipper() 00043 { 00044 *_buzzer = !*_buzzer; 00045 }
Generated on Wed Aug 3 2022 08:34:12 by
