JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

Revision:
34:498a218cf53e
Parent:
29:8ec9451b1a59
Child:
35:6855566cc941
diff -r c084f49cd403 -r 498a218cf53e square_app.cpp
--- a/square_app.cpp	Wed Dec 16 16:09:18 2015 +0000
+++ b/square_app.cpp	Thu Dec 17 09:55:33 2015 +0000
@@ -2,22 +2,22 @@
 
 SquareApp::SquareApp(Serial* serial) : App("Square wave", serial) {
     this->analogOut = new AnalogOut (PA_4);
+    this->amplitude = 75.0f;
 }
 
 void SquareApp::start()
 {
     App::start();
-    this->analogOut->write(0);
+    this->analogOut->write(this->amplitude/75.0f);
     this->timer.start(); 
 
 }
 
 void SquareApp::run()
 {
-   this->analogOut->write(1000* this->timer.read());
+   this->analogOut->write(75.0);
    
-   if (this->timer.read()>0.001f){
-       this->timer.reset();}
+   
 }
 
 void SquareApp::stop()
@@ -26,4 +26,8 @@
     this->analogOut->write(0);
     this->timer.stop();
     this->timer.reset();
+}
+void SquareApp::setamplitude(float newamplitude)
+{
+    this->amplitude = newamplitude;
 }
\ No newline at end of file