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.
Fork of ele350 by
sine_app.cpp
- Committer:
- GGHHHH
- Date:
- 2015-12-18
- Revision:
- 46:efa9285bf105
- Parent:
- 43:b45ede0e3ba6
- Child:
- 47:124bc7d77d5a
File content as of revision 46:efa9285bf105:
#include "sine_app.h" SineApp::SineApp(Serial* serial) : App("Sine wave", serial) { this->analogOut = new AnalogOut (PA_4); this->amplitude = 2.95f; this->frequence = 50.0f; } void SineApp::start() { App::start(); this->analogOut->write(this->amplitude/2.95f); this->timer.start(); float amplitude; amplitude = 2.95; if ( amplitude > 2.95f ) { this->analogOut->write(0); } else { this->analogOut->write(this->amplitude/2.95f);} } void SineApp::run() { this->analogOut->write(this->amplitude/3.0f*0.5f*(1.0f+sin(this->frequence*6.28f*timer.read()))); float frequence; frequence = 50.0f; if ( frequence > 50.0f ) { this->analogOut->write(0); } else { this->analogOut->write(this->amplitude/3.0f*0.5f*(1.0f+sin(this->frequence*6.28f*timer.read())));} } void SineApp::stop() { App::stop(); this->analogOut->write(0.0f); this->timer.stop(); this->timer.reset(); } void SineApp::setamplitude(float newamplitude) { this->amplitude = newamplitude; } void SineApp::setfrequence(float newfrequence) { this->frequence = newfrequence; }