2021_Colours_ModelRocket / Mbed 2 deprecated Camera_andIM920

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
MatsumotoKouki
Date:
Sat Feb 12 15:11:01 2022 +0000
Parent:
0:8cc9c11c6785
Commit message:
start camera from IM command

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Jan 13 06:54:11 2022 +0000
+++ b/main.cpp	Sat Feb 12 15:11:01 2022 +0000
@@ -2,54 +2,69 @@
 #include "Serial.h"
 DigitalOut cam_sw1(D10);      //カメラの電源スイッチに接続(Highで電源ON)
 DigitalOut cam_sw2(D9);      //カメラの撮影スイッチ(FET)に接続(HighでD-S導通)
+DigitalOut IM_busy(PA_0);
 Serial device(PA_2,PA_3);
-Serial im920(PA_9,PA_10,19200);
+Serial im920(PA_9,PA_10);
+Serial pc(USBTX, USBRX);
 DigitalOut led(LED1);
 
-char str[10];
+
+char str[100];
 int i=0;
 int k=0;
+char buf[100];
+
 void cmd(){
-    if(im920.readable()){ 
+
         while(1) {
         if(im920.readable()) { //IM920からのデータがある場合
             char temp = im920.getc();//一文字読み込む
-            if(temp != '\r') { //読み込み文字が改行で無い場合
-                str[i] = temp;
-                i++;
-            } else if(temp == '\r') { //読み込み文字が改行の場合
-                if(str[i-1]=='S'||'s'){
-                    cam_sw1 = 1;             //カメラの電源スイッチON
-                    wait(3);
-                    cam_sw1 = 0;
-                    wait(10);                //カメラの電源ON
-                    while(i<5){    
-                        led=1;
-                        wait(0.5);
-                        i++;
-                    }      
-                }else if(str[i-1]=='T'||'t'){
-                    cam_sw2 = 1;             //撮影スイッチON(撮影開始指示)
-                    wait(0.2);               //撮影開始
-                    cam_sw2=0;
-                }else if(str[i-1]=='E'||'e'){
-                    cam_sw2=1;               //撮影スイッチON(撮影終了指示)
-                    wait(0.2);               //撮影終了
-                    cam_sw2=0;
-                }else if(str[i-1]=='A'||'a'||'B'||'b'||'C'||'c'){
-                device.putc(str[i-1]);           
+            pc.printf("%c",temp);
+            if(temp != '\n') { //読み込み文字が改行で無い場合(順番では\r\n)
+                str[i++] = temp;
+            } else if(temp == '\n') { //読み込み文字が改行の場合
+                //printf("get Command\r\n");
+            }if(str[i-2]=='1'&&str[i-1]=='1'){  //スリープに入るor抜け出す際にはコマンド"11"
+                //printf("get 11 !!\r\n");
+                cam_sw1 = 1;             //カメラの電源スイッチON
+                wait(3);
+                cam_sw1 = 0;
+                wait(10);                //カメラの電源ON
+            }else if(str[i-2]=='2'&&str[i-1]=='2'){ //撮影開始の際にはコマンド"22"
+                cam_sw2 = 1;             //撮影スイッチON(撮影開始指示)
+                wait(0.2);               //撮影開始
+                cam_sw2=0;
+                printf("get 22\r\n");
+            }else if(str[i-2]=='3'&&str[i-1]=='3'){ //ス撮影終了の際にはコマンド"33"
+                printf("get 33\r\n");
+                cam_sw2=1;               //撮影スイッチON(撮影終了指示)
+                wait(0.2);               //撮影終了
+                cam_sw2=0;
+            }
+            
+           /* im920.scanf("%s",buf);
+            pc.printf("%s",buf);
+                 
+            
+                
+            else if(str[i-1]=='A'||'a'||'B'||'b'||'C'||'c'){
+            device.putc(str[i-1]);           
             }else{
-                im920.printf("command error");
-            }   
-    }
+            im920.printf("command error");
+            printf("command error");
+            i=0;
+            }  */         
+        }   
     }
-    }
-    }
-    }
+}
+    
     
 int main(){
-    device.baud(9600);
-    device.attach(cmd,Serial::RxIrq);
-    while(1){
-    }
+    //device.baud(9600);
+    im920.baud(19200);
+    pc.baud(38400);
+    
+    //device.attach(cmd,Serial::RxIrq);
+    IM_busy=0;
+    cmd();
 } 
--- a/mbed.bld	Thu Jan 13 06:54:11 2022 +0000
+++ b/mbed.bld	Sat Feb 12 15:11:01 2022 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/7c328cabac7e
\ No newline at end of file