Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Grove_Air_Quality_Sensor_Library by
Air_Quality.h@5:7cc7ee583d10, 2016-12-27 (annotated)
- Committer:
- lucianovici
- Date:
- Tue Dec 27 12:54:24 2016 +0200
- Revision:
- 5:7cc7ee583d10
- Parent:
- 4:0ca4a9fd1b5d
- Child:
- 6:34bf941285af
Test commit hg - mbed
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedAustin | 0:885417624ec2 | 1 | /* |
| mbedAustin | 0:885417624ec2 | 2 | AirQuality library v1.0 |
| mbedAustin | 0:885417624ec2 | 3 | 2010 Copyright (c) Seeed Technology Inc. All right reserved. |
| mbedAustin | 0:885417624ec2 | 4 | |
| mbedAustin | 0:885417624ec2 | 5 | Original Author: Bruce.Qin |
| mbedAustin | 0:885417624ec2 | 6 | |
| mbedAustin | 0:885417624ec2 | 7 | This library is free software; you can redistribute it and/or |
| mbedAustin | 0:885417624ec2 | 8 | modify it under the terms of the GNU Lesser General Public |
| mbedAustin | 0:885417624ec2 | 9 | License as published by the Free Software Foundation; either |
| mbedAustin | 0:885417624ec2 | 10 | version 2.1 of the License, or (at your option) any later version. |
| mbedAustin | 0:885417624ec2 | 11 | |
| mbedAustin | 0:885417624ec2 | 12 | This library is distributed in the hope that it will be useful, |
| mbedAustin | 0:885417624ec2 | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| mbedAustin | 0:885417624ec2 | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| mbedAustin | 0:885417624ec2 | 15 | Lesser General Public License for more details. |
| mbedAustin | 0:885417624ec2 | 16 | |
| mbedAustin | 0:885417624ec2 | 17 | You should have received a copy of the GNU Lesser General Public |
| mbedAustin | 0:885417624ec2 | 18 | License along with this library; if not, write to the Free Software |
| mbedAustin | 0:885417624ec2 | 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| mbedAustin | 0:885417624ec2 | 20 | */ |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 21 | #ifndef __AIRQUALITY_H__ |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 22 | #define __AIRQUALITY_H__ |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 23 | |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 24 | #include "mbed.h" |
| lucianovici | 1:e312d147cadd | 25 | #include "mbed_debug.h" |
| lucianovici | 1:e312d147cadd | 26 | |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 27 | #ifndef DEBUG_AIR_QUALITY |
| lucianovici | 5:7cc7ee583d10 | 28 | #define DEBUG_AIR_QUALITY 1 |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 29 | #endif |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 30 | |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 31 | enum air_quality_values { |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 32 | UNKNOWN = -1, |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 33 | VERY_HIGH_POLLUTION = 0, |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 34 | HIGH_POLLUTION = 1, |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 35 | LOW_POLLUTION = 2, |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 36 | NO_POLLUTION = 3 |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 37 | }; |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 38 | |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 39 | class AirQuality { |
| mbedAustin | 0:885417624ec2 | 40 | public: |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 41 | uint16_t standard_vol; |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 42 | uint16_t init_voltage; |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 43 | uint16_t first_vol; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 44 | uint16_t last_vol; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 45 | |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 46 | AirQuality(); |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 47 | |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 48 | void set_calc_avg_volt_period(uint16_t seconds); |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 49 | void set_sampling_period(uint16_t seconds); |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 50 | |
| lucian@192-168-0-106.rdsnet.ro | 3:c25365a52d78 | 51 | void init(PinName pin); |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 52 | |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 53 | air_quality_values slope(void); |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 54 | |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 55 | protected: |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 56 | uint16_t _sampling_period_s; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 57 | uint16_t _sum_vol; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 58 | uint16_t _calc_avg_volt_period_s; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 59 | bool _was_sampled; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 60 | bool _has_error; |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 61 | |
| mbedAustin | 0:885417624ec2 | 62 | private: |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 63 | uint8_t _s; |
| mbedAustin | 0:885417624ec2 | 64 | PinName _pin; |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 65 | |
| lucian@192-168-0-101.rdsnet.ro | 4:0ca4a9fd1b5d | 66 | void calcAvgVoltageFor(uint16_t minutes); |
| mbedAustin | 0:885417624ec2 | 67 | }; |
| lucian@192-168-0-106.rdsnet.ro | 2:95009177a860 | 68 | |
| mbedAustin | 0:885417624ec2 | 69 | #endif |
