JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

Committer:
GGHHHH
Date:
Thu Dec 17 16:37:43 2015 +0000
Revision:
44:913bd7824dae
Parent:
34:498a218cf53e
Child:
45:e03bac876518
h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GGHHHH 29:8ec9451b1a59 1 #include "constant_app.h"
GGHHHH 29:8ec9451b1a59 2
GGHHHH 29:8ec9451b1a59 3 ConstantApp::ConstantApp(Serial* serial) : App("Constant Voltage", serial) {
GGHHHH 29:8ec9451b1a59 4 this->analogOut = new AnalogOut (PA_4);
GGHHHH 34:498a218cf53e 5 this->amplitude = 3.0f;
GGHHHH 29:8ec9451b1a59 6 }
GGHHHH 29:8ec9451b1a59 7
GGHHHH 29:8ec9451b1a59 8 void ConstantApp::start()
GGHHHH 29:8ec9451b1a59 9 {
GGHHHH 29:8ec9451b1a59 10 App::start();
GGHHHH 34:498a218cf53e 11 this->analogOut->write(this->amplitude/3.0f);
GGHHHH 44:913bd7824dae 12 this->timer.start();
GGHHHH 44:913bd7824dae 13 float amplitude;
GGHHHH 44:913bd7824dae 14 amplitude = 2.95;
GGHHHH 44:913bd7824dae 15 if ( amplitude > 2.95f ) {
GGHHHH 44:913bd7824dae 16 this->analogOut->write(0);
GGHHHH 44:913bd7824dae 17 } else { this->analogOut->write(this->amplitude/2.95f);}
GGHHHH 29:8ec9451b1a59 18
GGHHHH 29:8ec9451b1a59 19 }
GGHHHH 29:8ec9451b1a59 20
GGHHHH 29:8ec9451b1a59 21 void ConstantApp::run()
GGHHHH 29:8ec9451b1a59 22 {
GGHHHH 29:8ec9451b1a59 23
GGHHHH 29:8ec9451b1a59 24 }
GGHHHH 29:8ec9451b1a59 25
GGHHHH 29:8ec9451b1a59 26 void ConstantApp::stop()
GGHHHH 29:8ec9451b1a59 27 {
GGHHHH 29:8ec9451b1a59 28 App::stop();
GGHHHH 29:8ec9451b1a59 29 this->analogOut->write(0);
GGHHHH 29:8ec9451b1a59 30 this->timer.stop();
GGHHHH 29:8ec9451b1a59 31 this->timer.reset();
GGHHHH 34:498a218cf53e 32 }
GGHHHH 34:498a218cf53e 33
GGHHHH 34:498a218cf53e 34 void ConstantApp::setamplitude(float newamplitude)
GGHHHH 34:498a218cf53e 35 {
GGHHHH 34:498a218cf53e 36 this->amplitude = newamplitude;
GGHHHH 29:8ec9451b1a59 37 }