Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DustSenzor by
Revision 3:e382316d6d00, committed 2017-05-05
- 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 *);
};
