JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

sine_app.cpp

Committer:
GGHHHH
Date:
2015-12-17
Revision:
34:498a218cf53e
Parent:
33:c084f49cd403
Child:
36:a9f4a3409c89

File content as of revision 34:498a218cf53e:

#include "sine_app.h"

SineApp::SineApp(Serial* serial) : App("Sine wave", serial) {
    this->analogOut = new AnalogOut (PA_4);
    this->amplitude = 20.0f;
}

void SineApp::start()
{
    App::start();
    this->analogOut->write(this->amplitude/20.0f);
    this->timer.start(); 

}

void SineApp::run()
{
   this->analogOut->write(2.0/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;
}