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-17
- Revision:
- 37:83b729ea17d4
- Parent:
- 36:a9f4a3409c89
- Child:
- 39:ab2557044815
File content as of revision 37:83b729ea17d4:
#include "sine_app.h" SineApp::SineApp(Serial* serial) : App("Sine wave", serial) { this->analogOut = new AnalogOut (PA_4); this->amplitude = 3.0f; } void SineApp::start() { App::start(); this->analogOut->write(this->amplitude/3.0f); this->timer.start(); } void SineApp::run() { this->analogOut->write(this->amplitude/3.0*0.5*(1+sin(20.0*3.14159*2*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; }