JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

Revision:
42:6eb557ade29c
Parent:
41:db959505e044
Child:
43:b45ede0e3ba6
diff -r db959505e044 -r 6eb557ade29c square_app.cpp
--- a/square_app.cpp	Thu Dec 17 14:38:22 2015 +0000
+++ b/square_app.cpp	Thu Dec 17 16:15:42 2015 +0000
@@ -2,14 +2,14 @@
 
 SquareApp::SquareApp(Serial* serial) : App("Square wave", serial) {
     this->analogOut = new AnalogOut (PA_4);
-    this->amplitude = 3.0f;
+    this->amplitude = 2.95f;
     this->frequence = 50.0f;
 }
 
 void SquareApp::start()
 {
     App::start();
-    this->analogOut->write(this->amplitude/3.0f);
+    this->analogOut->write(this->amplitude/2.95f);
     this->timer.start(); 
 
 }
@@ -20,7 +20,17 @@
    p = (frequence*timer.read())-floor(frequence*timer.read());
    if ( p < 0.5f ) {
        this->analogOut->write(0);
-    } else { this->analogOut->write(this->amplitude/3.0f);} 
+    } else { this->analogOut->write(this->amplitude/2.95f);} 
+   float frequence;
+   frequence = 50.0f;
+   if ( frequence > 50.0f ) {
+       this->analogOut->write(0);
+    } else { this->analogOut->write(this->amplitude/2.95f);}
+    float amplitude;
+    amplitude = 2.95;
+    if ( amplitude > 2.95f ) {
+       this->analogOut->write(0);
+    } else { this->analogOut->write(this->amplitude/2.95f);}
 }
 
 void SquareApp::stop()