EEP fORK

Dependencies:   BLE_API mbed nRF51822

Fork of MCS_LRF by Farshad N

laser.h

Committer:
Farshad
Date:
2015-12-22
Revision:
11:0dafbbb3a686
Parent:
10:d37cd13dd529
Child:
12:cf8af0b4e0d2

File content as of revision 11:0dafbbb3a686:

#pragma once

#ifndef _LASER_
#define _LASER_

#include <stdio.h>
//#include <iostream>
#include <vector>

#include "mbed.h"



using namespace std;


class Laser
{
public:
    Laser(Serial& serial);
    ~Laser();

    void enableMeasurement(bool enable);
    void triggerDistanceMeasurement();
    void setDistaceCallback(void (*distanceCallback)(float distance, float elapsedTime));
    void setDebugCallback(void (*debugCallback)(char*));
    void setRedDot(bool on);
    
    //   float getDistance();
    //   void processRxData(char d);

private:
    bool timerRunning;
    Timer timer;
    uint8_t idx;
    static const uint8_t bufSize = 100;
    char buf[bufSize];
    Serial& serial;
    bool sendCommand(char cmd[]);
    bool processResponse();
    void split(char s[], char c, std::vector<char*>& v);
    void (*distanceCallback)(float distance, float elapsedTime);
    void (*debugCallback)(char data[]);
    
    //    void processBuffer();
};

#endif // _LASER_