marko puric / DustSenzor

Dependents:   PMS5003

Fork of DustSenzor by marko puric

Files at this revision

API Documentation at this revision

Comitter:
mpuric
Date:
Fri May 05 13:44:42 2017 +0000
Parent:
2:4c3bdadb6bc4
Child:
4:2a1e9c7225a5
Commit message:
Dust senzor PMS5003

Changed in this revision

DustSenzor.cpp Show annotated file Show diff for this revision Revisions of this file
DustSenzor.h Show annotated file Show diff for this revision Revisions of this file
--- a/DustSenzor.cpp	Fri May 05 10:37:43 2017 +0000
+++ b/DustSenzor.cpp	Fri May 05 13:44:42 2017 +0000
@@ -5,20 +5,16 @@
 
 
 
-DustSenzor::DustSenzor(void) : uart(p9,p10), tipka(p6), tipkaReset(p7), set(p5),reset(p8), pc(USBTX,USBRX), i2c_lcd(p28,p27){
-    //Pocetna();
+DustSenzor::DustSenzor(void) : uart(p9,p10), tipka(p6),set(p5), pc(USBTX,USBRX), i2c_lcd(p28,p27){
     uart.baud(9600); 
     uart.format(8,SerialBase::None,1);
     debounce.start();
-    tipka.mode(PullUp);
-    tipka.rise(this,&DustSenzor::modeSet);
-    tipkaReset.mode(PullUp);
-    tipkaReset.rise(this,&DustSenzor::senzorReset);
-    uart.attach(this,&DustSenzor::mbedTOSenzor,Serial::RxIrq); 
+    tipka.mode(PullDown);
+    tipka.fall(this,&DustSenzor::modeSet);
+    uart.attach(this,&DustSenzor::mbedTOSenzor,Serial::RxIrq); // zasto ovo u konstruktoru?
     
     br=0;
     provjera=false;
-    reset=1;
     set=0;
     PM1 =0;
     PM25 =0;
@@ -32,19 +28,9 @@
     lcd.locate(0,0);
     lcd.printf("Press the\nbutton");
     
-    while(1){
-        if(br==32){ 
-        Racunanje();
-        }
-    }
     }
     
-void DustSenzor::senzorReset(){
-    if(debounce.read_ms() > 250){
-        reset=!reset;
-        }
-    }
-    
+
  
 void DustSenzor::modeSet(){
 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD16x2);
@@ -68,6 +54,9 @@
 void DustSenzor::mbedTOSenzor(){
     buff[br]=uart.getc();
     br++; 
+    if(br==32){ 
+        Racunanje();
+        }
     } 
 
     
--- a/DustSenzor.h	Fri May 05 10:37:43 2017 +0000
+++ b/DustSenzor.h	Fri May 05 13:44:42 2017 +0000
@@ -13,9 +13,7 @@
         I2C i2c_lcd;
         Serial pc;
         DigitalOut set;
-        DigitalOut reset;
         InterruptIn tipka;
-        InterruptIn tipkaReset;
         Timer debounce;
         unsigned char buff[32];
         bool provjera;
@@ -30,8 +28,7 @@
         void Ispis();
         void Racunanje();
         void modeSet();
-        void Pocetna();
-        void senzorReset();
+
         void Koeficijenti( unsigned char *, short *, short *, short *, float *, float *, float *);
     
 };