skipper_raspi_uart_test

Dependencies:   mbed MPU6050_2 HMC5883L_4 SDFileSystem3

Revision:
11:d44d137831b9
Parent:
10:63fe920595a7
Child:
12:083662bca47d
--- a/main.cpp	Sun Feb 10 09:05:27 2019 +0000
+++ b/main.cpp	Sun Feb 10 18:13:37 2019 +0000
@@ -5,8 +5,8 @@
 //MPU_check用
 #define PI 3.14159265358979
 
-#define servo_NEUTRAL_R    1900
-#define servo_NEUTRAL_L    1900
+#define servo_NEUTRAL_R    1614
+#define servo_NEUTRAL_L    1621
 #define servo_FORWARD_R    1860
 #define servo_FORWARD_L    1860
 #define servo_back_R       1060
@@ -15,9 +15,9 @@
 #define servo_slow_FORWARD_L    1560
 #define servo_slow_back_R       1360
 #define servo_slow_back_L       1360
-#define TurnTable_NEUTRAL     1500 //カメラ台座のサーボ
+#define TurnTable_NEUTRAL     1180 //カメラ台座のサーボ
 #define MatchSpeed 1500 + 100 //カメラと方向を合わせるときの車輪の速度
-#define minFocus  1200  //焦点合わせ用サーボの最小値
+#define Focus_NEUTRAL  1455  //焦点合わせ用サーボの最小値
 
 #define MOVE_NEUTRAL    0
 #define MOVE_FORWARD    1   
@@ -58,6 +58,11 @@
 
 Timer t;
 
+RawSerial pc(PA_2,PA_3,115200); //uart2
+//pa2:UART2_TX,pa3:UART2_RX
+//RawSerial pc2(PB_6,PB_7,115200); //uart1
+//pb6:UART1_TX,pb7:UART1_RX
+
 //PWM pin宣言
 PwmOut servoR(PC_6);           //TIM3_CH1 車輪右
 PwmOut servoL(PC_7);           //TIM3_CH2 車輪左
@@ -79,11 +84,6 @@
 //外付けコンパス
 HMC5883L compass(PB_9, PB_8);    //コンパスセンサー TIM4_CH3とCH4
 
-RawSerial pc(PA_2,PA_3,115200); //uart2
-//pa2:UART2_TX,pa3:UART2_RX
-RawSerial pc2(PB_6,PB_7,115200); //uart1
-//pb6:UART1_TX,pb7:UART1_RX
-
 char g_landingcommand='N';
 
 //MPU_check用
@@ -95,9 +95,11 @@
     //MPU_check
     setup();
     
+    servoCameradeg.pulsewidth_us(1400);
+    
     // シリアル通信受信の割り込みイベント登録
     pc.attach(getSF_Serial_jevois, Serial::RxIrq);
-    pc2.attach(getSF_Serial_pi, Serial::RxIrq);
+    //pc2.attach(getSF_Serial_pi, Serial::RxIrq);
     
     while(1) {
         if(jevoisFlag==true) NVIC_DisableIRQ(USART1_IRQn);
@@ -199,8 +201,8 @@
 void MoveCameraBoard(){
     MoveCansat('N');
     g_landingcommand='N';
-    servoTurnTable.pulsewidth_us(2000);
-    wait_ms(300);
+    servoTurnTable.pulsewidth_us(1800);
+    wait_ms(600);
     servoTurnTable.pulsewidth_us(TurnTable_NEUTRAL);
     if(jevoisFlag == true) FocusAdjust();
     else wait(1);
@@ -210,7 +212,7 @@
         servoCameradeg.pulsewidth_us(1800);
         CameraDegFlag=!CameraDegFlag;
         }else{
-        servoCameradeg.pulsewidth_us(1500);
+        servoCameradeg.pulsewidth_us(1400);
         CameraDegFlag = !CameraDegFlag;
     }
         
@@ -233,13 +235,15 @@
 }
 
 void FocusAdjust(){
-    servoCameraPinto.pulsewidth_us(minFocus);
+    servoCameraPinto.pulsewidth_us(Focus_NEUTRAL-200);
+    pc.printf("set\r\n");
+    wait(1);
     
-    for(int i=0; i<400; i++){
-        servoCameraPinto.pulsewidth_us(minFocus+i);
-        wait_ms(30);
-        if(g_landingcommand!='N') return;
-    }
+    servoCameraPinto.pulsewidth_us(Focus_NEUTRAL+30);
+    pc.printf("check\r\n");
+    wait(3);
+    servoCameraPinto.pulsewidth_us(Focus_NEUTRAL);
+      
   return;      
 }    
 
@@ -291,7 +295,7 @@
 }
 
 
-void getSF_Serial_pi(){
+/*void getSF_Serial_pi(){
     
     //NVIC_DisableIRQ(USART2_IRQn);
 
@@ -338,7 +342,7 @@
     
     //NVIC_EnableIRQ(USART2_IRQn);
                     
-}
+}*/
 
 
 void setup(){