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:
- 23:a162feaea9ab
- Parent:
- 22:97328720703c
- Child:
- 24:deda85e681a2
--- a/main.cpp Sun Mar 06 06:34:20 2022 +0000
+++ b/main.cpp Fri Mar 11 04:19:33 2022 +0000
@@ -36,19 +36,20 @@
//発射開始を受信
bool get_shoot(int rx_data,int &tx_data){
- if(shoot_phase == 0 && shoot_start == 0){//フェーズ0以外は、発射できないように
- shoot_start = 1;
- shoot_phase = 1;
+ if(shoot_phase == 0){//フェーズ0以外は、発射できないように
+ if(rx_data == 1){
+ shoot_phase = 1;
+ }
}
return true;
}
//非常停止を受信
bool get_stop(int rx_data,int &tx_data){
- if(emergency == 0){
+ /*if(emergency == 0){
emergency = 1;//停止
shoot_phase = 10;
- }
+ }*/
return true;
}
@@ -114,28 +115,24 @@
wait(0.1);
printf("waiting\n");
}
- if(count < 7){
- shoot_phase = 1;
- }else{
- emergency = 1;
- shoot_phase = 10;
- }
- printf("finished waiting\n");
+ printf("finished waiting\n");
break;
case 1://装填動作
- while(limit_1.read() == 0){
- motor_shoot.output(load_pwm);
- printf("loading\n");
- if(limit_2.read() == 1){
- break;
- }
- wait(0.1);
+ if(count < 7){
+ while(limit_1.read() == 0){
+ motor_shoot.output(load_pwm);
+ printf("loading\n");
+ wait(0.1);
+ }
+ motor_shoot.output(0);
+ shoot_phase = 2;
+ printf("finished loading\n");
+ wait(0.1);
+ }else{
+ emergency = 1;
+ shoot_phase = 10;
}
- motor_shoot.output(0);
- shoot_phase = 2;
- printf("finished loading\n");
- wait(0.1);
break;
case 2://リボルバー回転,モーター復帰
@@ -144,6 +141,7 @@
revolver_back(count);
shoot_phase = 3;
printf("finished backing\n");
+ wait_ms(2);
wait(0.5);
break;
@@ -152,10 +150,12 @@
printf("%d shot\n",count);
wait(1);
servo.pulsewidth_us(theta_0);
- motor_shoot.output(load_pwm);
- wait(0.15);
- motor_shoot.output(0);
- shoot_phase = 0;
+ if(count != 6){
+ motor_shoot.output(load_pwm);
+ wait(0.15);
+ motor_shoot.output(0);
+ }
+ shoot_phase = 1;
printf("finished init\n");
count ++;
break;