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
--- a/sine_app.cpp	Thu Dec 17 14:38:22 2015 +0000
+++ b/sine_app.cpp	Thu Dec 17 16:15:42 2015 +0000
@@ -2,14 +2,14 @@
 
 SineApp::SineApp(Serial* serial) : App("Sine wave", serial) {
     this->analogOut = new AnalogOut (PA_4);
-    this->amplitude = 3.0f;
+    this->amplitude = 2.95f;
     this->frequence = 50.0f;
 }
 
 void SineApp::start()
 {
     App::start();
-    this->analogOut->write(this->amplitude/3.0f);
+    this->analogOut->write(this->amplitude/2.95f);
     this->timer.start(); 
 
 }
@@ -17,6 +17,16 @@
 void SineApp::run()
 {
    this->analogOut->write(this->amplitude/3.0f*0.5f*(1.0f+sin(frequence*6.28f*timer.read())));
+   float frequence;
+   frequence = 50.0f;
+   if ( frequence > 50.0f ) {
+       this->analogOut->write(0);
+    } else { this->analogOut->write(this->amplitude/3.0f*0.5f*(1.0f+sin(frequence*6.28f*timer.read())));}
+    float amplitude;
+    amplitude = 2.95;
+    if ( amplitude > 2.95f ) {
+       this->analogOut->write(0);
+    } else { this->analogOut->write(this->amplitude/2.95f);}
    
 
 }