Dust sensor
Fork of DustSenzor by
Diff: DustSenzor.h
- Revision:
- 6:f6a93c155525
- Parent:
- 5:fd42a3f8c7eb
- Child:
- 7:067de0268900
--- a/DustSenzor.h Mon Jun 05 08:12:24 2017 +0000 +++ b/DustSenzor.h Thu Jun 08 16:50:46 2017 +0000 @@ -1,30 +1,58 @@ #ifndef DUSTSENZOR_H #define DUSTSENZOR_H #include"mbed.h" -#include"TextLCD.h" + +/** Simple class for reading values from Plantower PMS5003 dust concentration sensor. + * Example: + * @code: + * #include "mbed.h" + * #include "DustSenzor.h" + + * DustSenzor ds(p5, p9, p10); + * float values [6]; + * float *ptr; + + * int main() { + * ds.start(); + * ptr = ds.read(); + + * for( int i = 0; i < 6; i++) { + * values [i] = *(ptr + i); + * } + * } + * @endcode +*/ -class DustSenzor{ +class DustSenzor { + public: - DustSenzor(PinName set, PinName uartTx, PinName uartRx); + DustSenzor ( PinName set, PinName uartTx, PinName uartRx ); + /** Start the communication with sensor. + */ void start(); + + /** Stop the communication with sensor. + */ + void stop(); + /** Read the values from a float array with 9 elements. Function is returnig a pointer to the first element of array. + */ float* read(); - void reset(); - + /** Reset the sensor. Low reset. + */ + void reset(); private: float value[9]; Serial uart; DigitalOut set; - Timer debounce; unsigned char buff[32]; bool provjera; int br; void serialSensor(); - void Racunanje(); - void modeSet(); + void readBuffer(); void save( unsigned char *); };