Grove Air Quality Sensor.

Fork of Grove_Air_Quality_Sensor_Library by Seeed

Committer:
lucianovici
Date:
Tue Dec 27 13:47:39 2016 +0200
Revision:
7:38425a51906f
Parent:
6:34bf941285af
Make heating delay configurable

Who changed what in which revision?

UserRevisionLine numberNew 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 6:34bf941285af 28 #define DEBUG_AIR_QUALITY 0
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);
lucianovici 7:38425a51906f 50 void set_heating_delay(uint16_t seconds);
lucian@192-168-0-106.rdsnet.ro 2:95009177a860 51
lucian@192-168-0-106.rdsnet.ro 3:c25365a52d78 52 void init(PinName pin);
lucian@192-168-0-106.rdsnet.ro 2:95009177a860 53
lucian@192-168-0-106.rdsnet.ro 2:95009177a860 54 air_quality_values slope(void);
lucian@192-168-0-106.rdsnet.ro 2:95009177a860 55
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 56 protected:
lucianovici 7:38425a51906f 57 uint16_t _heating_delay_s;
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 58 uint16_t _sampling_period_s;
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 59 uint16_t _sum_vol;
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 60 uint16_t _calc_avg_volt_period_s;
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 61 bool _was_sampled;
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 62 bool _has_error;
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 63
mbedAustin 0:885417624ec2 64 private:
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 65 uint8_t _s;
mbedAustin 0:885417624ec2 66 PinName _pin;
lucian@192-168-0-106.rdsnet.ro 2:95009177a860 67
lucian@192-168-0-101.rdsnet.ro 4:0ca4a9fd1b5d 68 void calcAvgVoltageFor(uint16_t minutes);
mbedAustin 0:885417624ec2 69 };
lucian@192-168-0-106.rdsnet.ro 2:95009177a860 70
mbedAustin 0:885417624ec2 71 #endif