放出機構コントローラ用プログラム

Dependencies:   mbed BMP180

Files at this revision

API Documentation at this revision

Comitter:
scb01166
Date:
Wed Dec 16 13:13:15 2020 +0000
Parent:
2:76f6a32f9404
Commit message:
Added "NoSignal" message; Improved the response when pushing the deploy button

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 76f6a32f9404 -r 52396b1b5867 main.cpp
--- a/main.cpp	Tue Dec 15 20:45:56 2020 +0000
+++ b/main.cpp	Wed Dec 16 13:13:15 2020 +0000
@@ -212,8 +212,26 @@
         }
         led_button = 0;
         //buf[0] = '0';
+        int nosignal = 0;
+        bool push = false;
         while(xbee.readable()==0) {
             xbee.printf("G");
+            nosignal++;
+            bb = button;
+            if(nosignal == 5000){
+                lcd_setCursor(0,0);
+                lcd_printStr("NoSignal");
+                lcd_setCursor(0,1);
+                lcd_printStr("        ");
+                contrast = 35;  
+            }else if(!bb && nosignal<5000){
+                push = true;
+                break;   
+            }
+        }
+        if(push){
+            printf("1");
+            continue;
         }
         while(1) {
             int c = xbee.getc();
@@ -229,7 +247,10 @@
                 sscanf(buf,"PP%fT%f\n", &pressure, &temp);
                 pressure += 1.77f;
                 buf_count = 0;
-                bool push = false;
+                while(xbee.readable()==1) {
+                    c = xbee.getc();
+                }
+                push = false;
                 for(int i=0;i<8;i++){
                     bb = button;
                     if(!bb){
@@ -239,7 +260,10 @@
                     }
                     wait(0.1);
                 }
-                if(push) break;
+                if(push){
+                    printf("2");
+                    break;
+                }
                 led = 1;
                 for(int i=0;i<2;i++){
                     bb = button;
@@ -252,7 +276,10 @@
                     led = !led;
                 }
                 led = 0;
-                if(push) break;
+                if(push){
+                    printf("3");
+                    break;
+                }
                 ground_P = get_P();
                 ground_T = get_T();
                 //height = ( pow(ground_P/pressure, 1/5.257f)-1 )*(temp+273.15f)/0.0065f;