Grove Air Quality Sensor.

Fork of Grove_Air_Quality_Sensor_Library by Seeed

Revision:
1:e312d147cadd
Parent:
0:885417624ec2
Child:
2:95009177a860
diff -r 885417624ec2 -r e312d147cadd Air_Quality.cpp
--- a/Air_Quality.cpp	Fri Sep 05 19:13:07 2014 +0000
+++ b/Air_Quality.cpp	Thu Dec 22 22:33:19 2016 +0000
@@ -34,7 +34,7 @@
     if(i==150) { //sum 5 minutes
         vol_standard=temp/150;
         temp=0;
-        printf("Vol_standard in 5 minutes: %d\n\r",vol_standard);
+        debug("Vol_standard in 5 minutes: %d\n\r",vol_standard);
         i=0;
     } else {
         temp+=first_vol;
@@ -47,65 +47,65 @@
     _pin=pin;
     AnalogIn sensor(_pin);
     unsigned char i = 0;
-    printf("Air Quality Sensor Starting Up...(20s)\n\r");
+    debug("Air Quality Sensor Starting Up...(20s)\n\r");
     wait(20); //20s
     init_voltage = sensor.read() * 1000; // boost the value to be on a 0 -> 1000 scale for compatibility
-    printf("The initial voltage is %d%% of source \n\r",init_voltage/10);
+    debug("The initial voltage is %d%% of source \n\r",init_voltage/10);
     while(init_voltage) {
         if((init_voltage < 798) && (init_voltage > 10)) {
             // the init voltage is ok
             first_vol = sensor.read() * 1000;//initialize first value
             last_vol = first_vol;
             vol_standard = last_vol;
-            printf("Sensor ready.\n\r");
+            debug("Sensor ready.\n\r");
             error = false;;
             break;
         } else if(init_voltage > 798 || init_voltage <= 10) {
             // The sensor is not ready, wait a bit for it to cool off
             i++;
-            printf("Sensor not ready (%d), try %d/5, waiting 60 seconds...\n\r",init_voltage,i);
+            debug("Sensor not ready (%d), try %d/5, waiting 60 seconds...\n\r",init_voltage,i);
             wait(60);//60s
             init_voltage = sensor.read() * 1000;
             if(i==5) {
                 // After 5 minutes warn user that the sensor may be broken
                 i = 0;
                 error = true;
-                printf("Sensor Error! You may have a bad sensor. :-(\n\r");
+                debug("Sensor Error! You may have a bad sensor. :-(\n\r");
             }
         } else
             break;
     }
     // Call AirQualityInterrupt every 2seconds
     IntHandler.attach(IRQ, 2.0);
-    printf("Test begin...\n\r");
+    debug("Test begin...\n\r");
 }
 
 int AirQuality::slope(void)
 {
     while(timer_index) {
         if(first_vol-last_vol > 400 || first_vol > 700) {
-            printf("High pollution! Force signal active.\n\r");
+            debug("High pollution! Force signal active.\n\r");
             timer_index = 0;
             avgVoltage();
             return 0;
         } else if((first_vol - last_vol > 400 && first_vol < 700) || first_vol - vol_standard > 150) {
-            printf("sensor_value:%d",first_vol);
-            printf("\t High pollution!\n\r");
+            debug("sensor_value:%d",first_vol);
+            debug("\t High pollution!\n\r");
             timer_index = 0;
             avgVoltage();
             return 1;
 
         } else if((first_vol-last_vol > 200 && first_vol < 700) || first_vol - vol_standard > 50) {
-            //printf(first_vol-last_vol);
-            printf("sensor_value:%d",first_vol);
-            printf("\t Low pollution!\n\r");
+            //debug(first_vol-last_vol);
+            debug("sensor_value:%d",first_vol);
+            debug("\t Low pollution!\n\r");
             timer_index = 0;
             avgVoltage();
             return 2;
         } else {
             avgVoltage();
-            printf("sensor_value:%d",first_vol);
-            printf("\t Air fresh\n\r");
+            debug("sensor_value:%d",first_vol);
+            debug("\t Air fresh\n\r");
             timer_index = 0;
             return 3;
         }