EEP fORK

Dependencies:   BLE_API mbed nRF51822

Fork of MCS_LRF by Farshad N

Committer:
bmentink
Date:
Tue Mar 06 21:34:31 2018 +0000
Revision:
21:c19355cc5e79
Parent:
15:bc4f8c597c26
Child:
16:dc9956bac1a3
Added following:; 1. ACA modules that control VBUS and ID pins; 2. Turned off laser after powerup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Farshad 7:8a23a257b66a 1 #pragma once
Farshad 7:8a23a257b66a 2
Farshad 7:8a23a257b66a 3 #ifndef _LASER_
Farshad 7:8a23a257b66a 4 #define _LASER_
Farshad 7:8a23a257b66a 5
Farshad 7:8a23a257b66a 6 #include <stdio.h>
Farshad 7:8a23a257b66a 7 #include <vector>
Farshad 7:8a23a257b66a 8
Farshad 7:8a23a257b66a 9 #include "mbed.h"
Farshad 7:8a23a257b66a 10
Farshad 7:8a23a257b66a 11 using namespace std;
Farshad 7:8a23a257b66a 12
Farshad 7:8a23a257b66a 13
Farshad 7:8a23a257b66a 14 class Laser
Farshad 7:8a23a257b66a 15 {
Farshad 7:8a23a257b66a 16 public:
Farshad 15:bc4f8c597c26 17 Laser(Serial& serial, int nSamples = 10);
Farshad 7:8a23a257b66a 18 ~Laser();
Farshad 7:8a23a257b66a 19
Farshad 7:8a23a257b66a 20 void enableMeasurement(bool enable);
Farshad 11:0dafbbb3a686 21 void triggerDistanceMeasurement();
Farshad 8:ed66e7ef8243 22 void setDistaceCallback(void (*distanceCallback)(float distance, float elapsedTime));
Farshad 8:ed66e7ef8243 23 void setDebugCallback(void (*debugCallback)(char*));
Farshad 10:d37cd13dd529 24 void setRedDot(bool on);
Farshad 15:bc4f8c597c26 25 void turnLaserPowerOn();
Farshad 15:bc4f8c597c26 26 void turnLaserPowerOff();
Farshad 15:bc4f8c597c26 27 void setNumberOfSamples(int n) {nSamples = n;}
Farshad 7:8a23a257b66a 28
Farshad 7:8a23a257b66a 29 private:
Farshad 8:ed66e7ef8243 30 bool timerRunning;
Farshad 8:ed66e7ef8243 31 uint8_t idx;
Farshad 15:bc4f8c597c26 32 Serial& serial;
Farshad 15:bc4f8c597c26 33 bool powerOffState;
Farshad 15:bc4f8c597c26 34 bool busy;
Farshad 15:bc4f8c597c26 35 int nSamples;
Farshad 15:bc4f8c597c26 36
Farshad 8:ed66e7ef8243 37 static const uint8_t bufSize = 100;
Farshad 8:ed66e7ef8243 38 char buf[bufSize];
Farshad 15:bc4f8c597c26 39 Timer timer;
Farshad 7:8a23a257b66a 40 bool sendCommand(char cmd[]);
Farshad 8:ed66e7ef8243 41 bool processResponse();
Farshad 7:8a23a257b66a 42 void split(char s[], char c, std::vector<char*>& v);
Farshad 8:ed66e7ef8243 43 void (*distanceCallback)(float distance, float elapsedTime);
Farshad 8:ed66e7ef8243 44 void (*debugCallback)(char data[]);
Farshad 12:cf8af0b4e0d2 45 void discardResponse();
Farshad 15:bc4f8c597c26 46 void connectPower();
Farshad 15:bc4f8c597c26 47 void removePower();
Farshad 7:8a23a257b66a 48 };
Farshad 7:8a23a257b66a 49
Farshad 7:8a23a257b66a 50 #endif // _LASER_