YW51 module library for calculating PM2.5

Dependencies:   SoftSerial

Committer:
bojun0220
Date:
Tue Feb 19 14:24:36 2019 +0000
Revision:
0:1abc1344f5eb
Child:
1:9b8788ea7c85
YW51 module library for calculating PM2.5; ; #First Edition;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bojun0220 0:1abc1344f5eb 1 /* YW51 module Library
bojun0220 0:1abc1344f5eb 2 *
bojun0220 0:1abc1344f5eb 3 * Copyright (c) 2019, 黃博鈞, National Taiwan University
bojun0220 0:1abc1344f5eb 4 *
bojun0220 0:1abc1344f5eb 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
bojun0220 0:1abc1344f5eb 6 * of this software and associated documentation files (the "Software"), to deal
bojun0220 0:1abc1344f5eb 7 * in the Software without restriction, including without limitation the rights
bojun0220 0:1abc1344f5eb 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
bojun0220 0:1abc1344f5eb 9 * copies of the Software, and to permit persons to whom the Software is
bojun0220 0:1abc1344f5eb 10 * furnished to do so, subject to the following conditions:
bojun0220 0:1abc1344f5eb 11 *
bojun0220 0:1abc1344f5eb 12 * The above copyright notice and this permission notice shall be included in
bojun0220 0:1abc1344f5eb 13 * all copies or substantial portions of the Software.
bojun0220 0:1abc1344f5eb 14 *
bojun0220 0:1abc1344f5eb 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
bojun0220 0:1abc1344f5eb 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
bojun0220 0:1abc1344f5eb 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
bojun0220 0:1abc1344f5eb 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
bojun0220 0:1abc1344f5eb 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bojun0220 0:1abc1344f5eb 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
bojun0220 0:1abc1344f5eb 21 * THE SOFTWARE.
bojun0220 0:1abc1344f5eb 22 */
bojun0220 0:1abc1344f5eb 23 #include "mbed.h"
bojun0220 0:1abc1344f5eb 24
bojun0220 0:1abc1344f5eb 25 #ifndef MBED_YW51_H
bojun0220 0:1abc1344f5eb 26 #define MBED_YW51_H
bojun0220 0:1abc1344f5eb 27
bojun0220 0:1abc1344f5eb 28 class YW51
bojun0220 0:1abc1344f5eb 29 {
bojun0220 0:1abc1344f5eb 30
bojun0220 0:1abc1344f5eb 31 public:
bojun0220 0:1abc1344f5eb 32 YW51(PinName _tx, PinName _rx, int Baud);
bojun0220 0:1abc1344f5eb 33 int readData();
bojun0220 0:1abc1344f5eb 34 double ShowPM();
bojun0220 0:1abc1344f5eb 35 int PMStage(double pm);
bojun0220 0:1abc1344f5eb 36
bojun0220 0:1abc1344f5eb 37
bojun0220 0:1abc1344f5eb 38 private:
bojun0220 0:1abc1344f5eb 39 Serial _YW51;
bojun0220 0:1abc1344f5eb 40 int msg[6];
bojun0220 0:1abc1344f5eb 41 double pm;
bojun0220 0:1abc1344f5eb 42 int findK(double vo);
bojun0220 0:1abc1344f5eb 43 void getline();
bojun0220 0:1abc1344f5eb 44 };
bojun0220 0:1abc1344f5eb 45
bojun0220 0:1abc1344f5eb 46 #endif