メインマイコンのプログラム

Dependencies:   mbed SBDBT_for_2022gourobo arrc_mbed

Committer:
guesta
Date:
Fri Jan 21 08:52:19 2022 +0000
Revision:
3:e4b5563563af
Parent:
1:642ee25ea489
Child:
6:fd9b59f828e8
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
guesta 0:d8faed605a5c 1 #include "mbed.h"
guesta 3:e4b5563563af 2 #include "scrp_slave.hpp"
guesta 3:e4b5563563af 3 #include "sbdbt.hpp"
guesta 0:d8faed605a5c 4
guesta 0:d8faed605a5c 5 int main(){
guesta 1:642ee25ea489 6 //---------------初期設定---------------
guesta 3:e4b5563563af 7 //scrp_slave
guesta 3:e4b5563563af 8 ScrpSlave scrp(PC_12,PD_2,PH_1,0x0807f800);
guesta 3:e4b5563563af 9 //sbdbt
guesta 3:e4b5563563af 10 sbdbt sb(A0,A1);
guesta 3:e4b5563563af 11 //scrp_slaveのid設定
guesta 3:e4b5563563af 12 const int wheel_num = 255;
guesta 3:e4b5563563af 13 const int BeanbagGet_num = 2;
guesta 3:e4b5563563af 14 const int BeanbagShot_num = 3;
guesta 3:e4b5563563af 15 const int TakoGetPut_num = 4;
guesta 3:e4b5563563af 16 //コマンド番号設定
guesta 3:e4b5563563af 17 const int x_component_cmd = 1;
guesta 3:e4b5563563af 18 const int y_component_cmd = 2;
guesta 3:e4b5563563af 19 const int l2_cmd = 3;
guesta 3:e4b5563563af 20 const int r2_cmd = 4;
guesta 3:e4b5563563af 21 const int select = 5;
guesta 1:642ee25ea489 22 //変数
guesta 3:e4b5563563af 23 int x_component;
guesta 3:e4b5563563af 24 int y_component;
guesta 3:e4b5563563af 25 int l2_num;
guesta 3:e4b5563563af 26 int r2_num;
guesta 3:e4b5563563af 27 //-------------------------------------
guesta 3:e4b5563563af 28 //スティックの返り値-128~127
guesta 1:642ee25ea489 29 while(true){
guesta 3:e4b5563563af 30 sb.button_state();
guesta 3:e4b5563563af 31 x_component = sb.lsx();
guesta 3:e4b5563563af 32 y_component = sb.lsy();
guesta 3:e4b5563563af 33 l2_num = sb.l2An();
guesta 3:e4b5563563af 34 r2_num = sb.r2An();
guesta 3:e4b5563563af 35 //printf("%d %d",x_component,y_component);
guesta 3:e4b5563563af 36 scrp.send1(wheel_num,x_component_cmd,x_component);
guesta 3:e4b5563563af 37 wait_ms(1);
guesta 3:e4b5563563af 38 scrp.send1(wheel_num,y_component_cmd,y_component);
guesta 3:e4b5563563af 39 wait_ms(1);
guesta 3:e4b5563563af 40 scrp.send1(wheel_num,l2_cmd,l2_num);
guesta 3:e4b5563563af 41 wait_ms(1);
guesta 3:e4b5563563af 42 scrp.send1(wheel_num,r2_cmd,r2_num);
guesta 3:e4b5563563af 43 wait_ms(1);
guesta 3:e4b5563563af 44 scrp.send1(wheel_num,select,sb.select());
guesta 3:e4b5563563af 45 wait_ms(1);
guesta 1:642ee25ea489 46 }
guesta 0:d8faed605a5c 47 }