Bernard Mentink / Mbed 2 deprecated MCS_LRF_EEP

Dependencies:   BLE_API mbed nRF51822

Fork of MCS_LRF by Farshad N

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers laser.h Source File

laser.h

00001 #pragma once
00002 
00003 #ifndef _LASER_
00004 #define _LASER_
00005 
00006 #include <stdio.h>
00007 #include <vector>
00008 
00009 #include "mbed.h"
00010 
00011 using namespace std;
00012 
00013 
00014 class Laser
00015 {
00016 public:
00017     Laser(Serial& serial, int nSamples = 10);
00018     ~Laser();
00019 
00020     void enableMeasurement(bool enable);
00021     void triggerDistanceMeasurement();
00022     void setDistaceCallback(void (*distanceCallback)(float distance, float elapsedTime));
00023     void setDebugCallback(void (*debugCallback)(char*));
00024     void setRedDot(bool on);
00025     void turnLaserPowerOn();
00026     void turnLaserPowerOff();
00027     void setNumberOfSamples(int n) {nSamples = n;}
00028 
00029 private:
00030     bool timerRunning;
00031     uint8_t idx;
00032     Serial& serial;
00033     bool powerOffState; 
00034     bool busy;
00035     int nSamples;
00036     
00037     static const uint8_t bufSize = 100;
00038     char buf[bufSize];
00039     Timer timer;
00040     bool sendCommand(char cmd[]);
00041     bool processResponse();
00042     void split(char s[], char c, std::vector<char*>& v);
00043     void (*distanceCallback)(float distance, float elapsedTime);
00044     void (*debugCallback)(char data[]);
00045     void discardResponse();
00046     void connectPower();
00047     void removePower();
00048 };
00049 
00050 #endif // _LASER_