yajuan yue / Mbed 2 deprecated ele350

Dependencies:   mbed

Fork of ele350 by JIAWEI ZHANG

Revision:
3:1ad50b4e51a6
Child:
5:e820e1348f98
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/soft_pwm.cpp	Thu Nov 05 12:01:26 2015 +0000
@@ -0,0 +1,42 @@
+#include "soft_pwm.h"
+
+
+float SoftPwm::getPeriod()
+{
+      return this->period;
+}
+
+float SoftPwm::getDutyCycle()
+{
+    return this->dutyCycle;
+}
+
+void SoftPwm::setPeriod(float newPeriod)
+{
+    this->period = newPeriod;
+}
+
+void SoftPwm::setDutyCycle(float newDutyCycle)
+{
+    this->dutyCycle = newDutyCycle;
+}
+SoftPwm::SoftPwm(float initialPeriod, float initialDutyCycle)
+{
+    
+     this->period = initialPeriod;
+     this->dutyCycle = initialDutyCycle;
+     
+     pwm.setDutyCycle((1.0f+sin(breathingTimer.read()*M_PI))/2.0f);
+     this->timer.start();
+
+bool SoftPwm::isOn()
+
+    float onPhaseDuration = this->dutyCycle * this->period;
+    float currentTime = this->timer.reset();
+    
+    if (currentTime < onPhaseDuration){
+        return true;
+    }else {
+        return false;
+    }
+}