3k04 team / Mbed 2 deprecated Pacemaker

Dependencies:   mbed Queue mbed-rtos FXOS8700Q

Fork of Pacemaker by Eric dollar

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sense.cpp Source File

sense.cpp

00001 #pragma once
00002 #include "mbed.h"
00003 #include "sense.h"
00004 #include "VVI.h"
00005 
00006 sense::sense(genData* a): mySense(PTB2){
00007     myGenData = a; 
00008     isSensed = false; 
00009     }
00010     
00011 sense::~sense(){};
00012 
00013 bool sense::returnedSense(){
00014     timeout = false;
00015     isSensed = false;
00016     mbed::Timer t;
00017     t.start();
00018     while(!timeout){
00019         //Here we check if we should still be sensing or if we should give up
00020         if(myGenData->getHyst()){       //This is the case where hysteresis is enabled, we wait the lrl plus hysteresis
00021             if(t.read_ms() >= (myGenData->getLRL()+myGenData->getHystRL())){
00022                 timeout = true; 
00023             }
00024         }
00025         else{   //Here hysteresis isn't enabled, so its just waiting the LRL. 
00026             if(t.read_ms() >= myGenData->getLRL()){
00027                 timeout = true; 
00028             }
00029         }
00030         //Here we have to check the pin and see if it is above threshold. 
00031         if(mySense.read() > 0.995){
00032             isSensed = true;
00033             timeout = true;
00034         }
00035     }
00036     t.stop();
00037     return isSensed; 
00038 }      
00039         
00040