JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

constant_app.cpp

Committer:
GGHHHH
Date:
2015-12-18
Revision:
45:e03bac876518
Parent:
44:913bd7824dae
Child:
48:a72a8624bf2d

File content as of revision 45:e03bac876518:

#include "constant_app.h"

ConstantApp::ConstantApp(Serial* serial) : App("Constant Voltage", serial) {
    this->analogOut = new AnalogOut (PA_4);
    this->amplitude = 2.95f;
}

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

}

void ConstantApp::run()
{
    float amplitude;
    amplitude = 2.95;
    if ( amplitude > 2.95f ) {
       this->analogOut->write(0);
    } else { this->analogOut->write(this->amplitude/2.95f);} 

}

void ConstantApp::stop()
{
    App::stop();
    this->analogOut->write(0);
    this->timer.stop();
    this->timer.reset();
}

void ConstantApp::setamplitude(float newamplitude)
{
    this->amplitude = newamplitude;
}