marko puric / DustSenzor

Dependents:   PMS5003

Fork of DustSenzor by marko puric

Revision:
3:e382316d6d00
Parent:
2:4c3bdadb6bc4
Child:
4:2a1e9c7225a5
--- 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();
+        }
     }