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.
Diff: main.cpp
- Revision:
- 2:eca0702650ca
- Parent:
- 1:4847c54eed20
- Child:
- 3:31c005437fa5
--- a/main.cpp Tue Feb 11 05:55:21 2020 +0000
+++ b/main.cpp Tue Feb 11 06:28:36 2020 +0000
@@ -15,31 +15,43 @@
timer.start();
//int iMicroSec_prev = timer.read_us();
int iState_prev = 1;
- int time_start,time_end;
-
+ int time_start,time_end,time_data,delta_t;
+ int data_en = 0;
+
while(1) {
int iState = g_dpinIrReceiver;
-
+
//detect H signal
if( iState != iState_prev ) {
- //timer start
if(iState == 0) {
//timer.start();//reset
time_start = timer.read_us();//start(detect negedge
- }
- if(iState == 1) {//end (detect posedge
+
+ if(data_en == 1) {
+ //time_data = timer.read_us();
+ //delta_t = time_data - time_end;
+ delta_t = time_start - time_end;
+ data_en = 0;
+ if(delta_t > 1523) g_serial.printf("H");//625*2.5
+ else g_serial.printf("L");
+ }
+ } else if(iState == 1) { //end (detect posedge
+
+
time_end = timer.read_us();//over flow?
//compare and output
- int delta_t = time_end - time_start;
-
- if(delta_t > 8430) g_serial.printf("flame,");
- else g_serial.printf("data,");
-
- //g_serial.printf( "%d, ", time_start - time_end);
+ delta_t = time_end - time_start;
+
+ if(delta_t > 8430) g_serial.printf("flame,");//625*15
+ else {
+ data_en = 1;
+ //g_serial.printf("data,");
+ //g_serial.printf( "%d, ", time_start - time_end);
+ }
}
- }
+ }
iState_prev = iState;
-
+
//iState_prev = iState;
//int iMicroSec = timer.read_us();
//g_serial.printf( "%d, ", iMicroSec - iMicroSec_prev );