run this here

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351

Revision:
2:75253a344332
Parent:
1:b965810f9bb3
Child:
3:f34bbdea0786
--- a/main.cpp	Fri Apr 27 06:03:28 2018 +0000
+++ b/main.cpp	Fri Apr 27 06:16:33 2018 +0000
@@ -185,168 +185,4 @@
     t1.start(callback(&q1, &EventQueue::dispatch_forever));
     
     wait(osWaitForever);
-}
-
-
-
-
-
-
-
-
-
-//#include "mbed.h"
-//#include <string>
-//#include <sstream>
-//#include "Ticker.h"
-//
-//
-//InterruptIn catchChange(PTD2);
-//// printing from the device
-//Serial pc(USBTX, USBRX);
-//
-//// software PWM using DigitalOut
-//DigitalOut pulse(PTA10);
-//
-//// some defaults
-//float DEFAULT_PERIOD = 0.1f;
-//float DEFAULT_DUTYCYCLE = 0.5f;
-//float currentPeriod;
-//float currentDutyCycle;
-//
-//// ticker to change from low to high and one to change from high to low
-//Ticker lowToHigh;
-//Ticker highToLow;
-//
-//// every 10 rising edges, print T and D
-//int risingEdges = 0;
-//
-//// T is time between current edge and the previous one
-//int T_prev = -1;
-//int T_curr = -1;
-//int T;
-//
-//// D is fraction of time that was high during the preceding interval
-//float D;
-//Timer highTime;
-//Timer lowTime;
-//
-//
-//// when you come on a rising edge, you should increment the rising edges
-//// and count the time as high, meaning stop the low timer and start the 
-//// high timer
-//void riseHandle() {
-//    // every time, manage the time difference between the previous rising
-//    // edge and the one that came after it
-//    T_prev = T_curr;
-//    T_curr = (int)(highTime.read() * 1000000.0f);
-//    
-//    // if it's the first rising edge of a 10 edge interval,
-//    // then reset both timers
-//    if (risingEdges == 0) {        
-//        lowTime.stop();
-//        highTime.start();
-//        lowTime.reset();
-//        highTime.reset();
-//        
-//        // and you're in high time on the first rising edge
-//        risingEdges++;
-//    }
-//    
-//    // if it's the tenth, then store D so that someone else can
-//    // print it out. reset the timers and rising edge count
-//    else if (risingEdges == 9) {
-//        float h = highTime.read();
-//        float l = lowTime.read();
-//        D = h / (h + l);
-//        
-//        T = T_curr - T_prev;
-//        
-////        pc.printf("previous rising edge: %i, this rising edge: %i\n\r",T_prev,T_curr);
-//        
-//        lowTime.stop();
-//        highTime.start();
-//        lowTime.reset();
-//        highTime.reset();
-//        
-//        risingEdges++;
-//    }
-//    
-//    // if it's rising edge 2 ... 9, then just increment and start
-//    // the high timer and stop the low timer
-//    else {
-//        risingEdges++;
-//        lowTime.stop();
-//        highTime.start(); 
-//    }
-//}
-//
-//// when you come to a falling edge, you should stop the high timer and
-//// start the low timer
-//void fallHandle() {
-//    lowTime.start();
-//    highTime.stop();   
-//}
-//
-//void inputHandle() {
-//   int T_temp;
-//   float D_temp;
-//   pc.scanf("%i, %f",&T_temp,&D_temp);
-//   pc.printf("read in T as %i, D as %f\r\n",T_temp,D_temp);
-//   
-//    // make the changes to the period and duty cycle as long
-//    // as they are within range
-//    if ((T_temp >= 1000 && T_temp <= 60000) &&
-//        (D_temp >= 0.0f && D_temp <= 1.0f))
-//    {
-//        currentPeriod = (float)T_temp / 1000000.0f;
-//        currentDutyCycle = D_temp;
-//        
-//        pc.printf("period is now %f, duty cycle is now %f\n\r",(float)T_temp/1000000.0f,D_temp);
-//    }
-//    
-//    else {
-//        pc.printf("mbed> ERROR\n\r");
-//    }
-//}
-//
-//void tickerHandle() {
-//    if (pulse.read() == 1) {
-//        pulse.write(0);   
-//    } else {
-//        pulse.write(1);
-//    }
-//}
-//    
-//int main() {
-//    catchChange.rise(&riseHandle);
-//    catchChange.fall(&fallHandle);
-//    pc.attach(&inputHandle);
-//    
-//    currentPeriod = DEFAULT_PERIOD;
-//    currentDutyCycle = DEFAULT_DUTYCYCLE;
-//    
-//    // start at a low signal
-//    pulse.write(0);
-//    
-//    // go from low to high every period seconds
-//    float riseInterval = currentPeriod;
-//    // go from high to low every period + period*dutyCycle seconds
-//    float fallInterval = riseInterval + currentPeriod * currentDutyCycle;
-//    
-//    // set ticker to change signal given intervals above
-//    lowToHigh.attach(&tickerHandle, riseInterval);
-//    highToLow.attach(&tickerHandle, fallInterval);
-//    
-//    pc.printf("Starting main function!!!\n\r");
-//    
-//    pc.printf("rise interval: %f, fall interval: %f\n\r",riseInterval,fallInterval);
-//    
-//    while (1) {
-//        if (risingEdges >= 10) {
-//            risingEdges = 0;
-//            pc.printf("mbed> %u, %.3f\n\r", T, D);
-//        }   
-//        
-//    }
-//}
+}
\ No newline at end of file