Código sensor para material particulado con PMS 5003

Dependencies:   DmTftLibrary

Files at this revision

API Documentation at this revision

Comitter:
mateojs16
Date:
Sat Nov 13 14:53:48 2021 +0000
Parent:
3:4c7554fd88a5
Commit message:
Sensor de material particulado con Pms 5003

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4c7554fd88a5 -r c8e5928f440c main.cpp
--- a/main.cpp	Fri Oct 29 21:57:36 2021 +0000
+++ b/main.cpp	Sat Nov 13 14:53:48 2021 +0000
@@ -52,13 +52,34 @@
     printf("Concentration Units (standard)\n");
     printf("PM 1.0: %u", data.pm10_standard);
     tft.drawString(70, 70, "PM 1.0:");
-    tft.drawNumber(150, 70, data.pm10_standard, 5, false);
+    tft.drawNumber(140, 70, data.pm10_standard, 5, false);
     printf("\t\tPM 2.5: %u", data.pm25_standard);
     tft.drawString(70, 110, "PM 2.5:");
-    tft.drawNumber(150, 110, data.pm25_standard, 5, false);
+    tft.drawNumber(140, 110, data.pm25_standard, 5, false);
     printf("\t\tPM 10: %u\n", data.pm100_standard);
     tft.drawString(70, 150, "PM 10.0:");
-    tft.drawNumber(150, 150, data.pm100_standard, 5, false);
+    tft.drawNumber(140, 150, data.pm100_standard, 5, false);
+    
+     if ((data.pm25_standard>=0 && data.pm25_standard<=12) || (data.pm100_standard>=0 && data.pm100_standard<=54) ){
+          tft.fillCircle(120, 250, 40, 0x7E0);
+        }
+    else if ((data.pm25_standard>=13 && data.pm25_standard<=37) || (data.pm100_standard>=55 && data.pm100_standard<=154) ){
+        tft.fillCircle(120, 250, 40, 0xFFE0);
+        }
+    else if ((data.pm25_standard>=38 && data.pm25_standard<=55) || (data.pm100_standard>=155 && data.pm100_standard<=254) ){
+        tft.fillCircle(120, 250, 40, 0xFBE0);
+        }
+    else if ((data.pm25_standard>=56 && data.pm25_standard<=150) || (data.pm100_standard>=255 && data.pm100_standard<=354) ){
+        tft.fillCircle(120, 250, 40, 0xF800);
+        }
+    else if ((data.pm25_standard>=151 && data.pm25_standard<=250) || (data.pm100_standard>=355 && data.pm100_standard<=424) ){
+        tft.fillCircle(120, 250, 40, 0xF81F);
+        }
+    else{
+        tft.fillCircle(120, 250, 40, 0x0000);
+        }
+        
+        
     printf("---------------------------------------\n");
     printf("Concentration Units (environmental)\n");
     printf("PM 1.0: %u", data.pm10_env);
@@ -89,13 +110,12 @@
     uint16_t w = tft.width();
     uint16_t h = tft.height();
     tft.fillRectangle(0, 0, 1000,1000, 0xFFFF);
-    tft.fillCircle(130, 250, 40, 0xF81F);
-    tft.setTextColor(0xFFFF,0xF81F);
+    tft.setTextColor(0xFFFF,0x0000);
     tft.drawString(35, 30, "Cantidad de particulas : ");
 
 
     // This callback runs in an interrupt context, thus we debounce to the event queue here
     pm25.enable(queue.event(&pm25_data_callback));
+    queue.dispatch_forever();
 
-    queue.dispatch_forever();
 }