Grove Air Quality Sensor.

Fork of Grove_Air_Quality_Sensor_Library by Seeed

Files at this revision

API Documentation at this revision

Comitter:
lucianovici
Date:
Tue Dec 27 13:47:39 2016 +0200
Parent:
6:34bf941285af
Commit message:
Make heating delay configurable

Changed in this revision

Air_Quality.cpp Show annotated file Show diff for this revision Revisions of this file
Air_Quality.h Show annotated file Show diff for this revision Revisions of this file
diff -r 34bf941285af -r 38425a51906f Air_Quality.cpp
--- a/Air_Quality.cpp	Tue Dec 27 12:55:56 2016 +0200
+++ b/Air_Quality.cpp	Tue Dec 27 13:47:39 2016 +0200
@@ -23,6 +23,7 @@
 AirQuality::AirQuality() {
     _s = 0;
     _sum_vol = 0;
+    _heating_delay_s = 20;
 }
 
 void AirQuality::set_calc_avg_volt_period(uint16_t seconds) {
@@ -50,8 +51,8 @@
     _pin = pin;
     AnalogIn sensor(_pin);
     unsigned char minutes = 0;
-    debug_if(DEBUG_AIR_QUALITY, "Air Quality Sensor Starting Up...(20s)");
-    wait(20);
+    debug_if(DEBUG_AIR_QUALITY, "Air Quality Sensor Starting Up... (%d s)", _heating_delay_s);
+    wait(_heating_delay_s);
     init_voltage = (uint16_t) (sensor.read() * 1000); // boost the value to be on a 0 -> 1000 scale for compatibility
     debug_if(DEBUG_AIR_QUALITY, "The initial voltage is %d%% of source ", init_voltage / 10);
     while (init_voltage) {
@@ -109,3 +110,7 @@
     return ret;
 }
 
+void AirQuality::set_heating_delay(uint16_t seconds) {
+    _heating_delay_s = seconds;
+}
+
diff -r 34bf941285af -r 38425a51906f Air_Quality.h
--- a/Air_Quality.h	Tue Dec 27 12:55:56 2016 +0200
+++ b/Air_Quality.h	Tue Dec 27 13:47:39 2016 +0200
@@ -47,12 +47,14 @@
 
     void set_calc_avg_volt_period(uint16_t seconds);
     void set_sampling_period(uint16_t seconds);
+    void set_heating_delay(uint16_t seconds);
 
     void init(PinName pin);
 
     air_quality_values slope(void);
 
 protected:
+    uint16_t _heating_delay_s;
     uint16_t _sampling_period_s;
     uint16_t _sum_vol;
     uint16_t _calc_avg_volt_period_s;