Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- tummastt
- Date:
- 2012-07-30
- Revision:
- 0:efb27fbc92c0
- Child:
- 1:227db871d328
File content as of revision 0:efb27fbc92c0:
/*
    D- (Orange) is pin5 on AUX
    D+ (Yellow) is pin8 on AUX
    GND is pin 1 on AUX
    +12V is pin 3 on AUX
 */
#include "mbed.h"
#include "Parameters.h"
#include "PingDetect/PingDetect.h"
Ticker t;
DigitalOut l2(LED2);
DigitalOut l3(LED3);
DigitalOut l4(LED4);
bool Input=0, NewInput=0;
void Stop();
void Start();
void CalculateFFT();
void Run();
void Find();
int Command = doNothing;
int Found = notFound;
PingDetect PD;
int main() {
    while (1) {
//        PD.SendSerial(Command);
        //
        switch (Command) {
            case start:
                Start();
                break;
            case calcFFT:
                CalculateFFT();
                break;
            case stop:
                Stop();
                break;
                
            case doNothing:
                
            default:
                break;
        }
        Command = PD.ReadSerial(Command);
    }
}
void Stop() {
    t.detach();
    l2=0;
    l3=0;
    l4=0;
    Command = doNothing;
}
void Start() {
    l2=1;
    t.detach();
//    t.attach_us(&Find,10000);
    t.attach_us(&Find,5000);
    Command = doNothing;
}
void CalculateFFT() {
    t.detach();
    PD.CalculateFFT();    
    Command = doNothing;
}
void Run () {
    l3=!l3;
    PD.Run();
}
void Find() {
    l4=!l4;
    Found = PD.Search();
    if(Found == found){
        l2=0;
        t.detach();
//        wait_ms(1000-TIME_OFFSET);
        wait_ms(1000-TIME_OFFSET);
        t.attach(&Run,1);
        Run();
    }
        
}