JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

Committer:
GGHHHH
Date:
Fri Dec 18 11:43:11 2015 +0000
Revision:
45:e03bac876518
Parent:
44:913bd7824dae
Child:
48:a72a8624bf2d
k

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 45:e03bac876518 5 this->amplitude = 2.95f;
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 45:e03bac876518 11 this->analogOut->write(this->amplitude/2.95f);
GGHHHH 44:913bd7824dae 12 this->timer.start();
GGHHHH 45:e03bac876518 13
GGHHHH 45:e03bac876518 14 }
GGHHHH 45:e03bac876518 15
GGHHHH 45:e03bac876518 16 void ConstantApp::run()
GGHHHH 45:e03bac876518 17 {
GGHHHH 44:913bd7824dae 18 float amplitude;
GGHHHH 44:913bd7824dae 19 amplitude = 2.95;
GGHHHH 44:913bd7824dae 20 if ( amplitude > 2.95f ) {
GGHHHH 44:913bd7824dae 21 this->analogOut->write(0);
GGHHHH 44:913bd7824dae 22 } else { this->analogOut->write(this->amplitude/2.95f);}
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 }