主導機 mbed用のプログラムです 改良しました

Dependencies:   mbed

Fork of F3RC_syudou_master_3 by 日記

Committer:
hirokimineshita
Date:
Thu Apr 30 06:15:51 2015 +0000
Revision:
3:fe59877ed801
Parent:
2:0e2a5eaebd27
Child:
4:d7f5fb6fddeb
2015/04/30 PM 3 change document

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hirokimineshita 2:0e2a5eaebd27 1 /** @file
hirokimineshita 2:0e2a5eaebd27 2 */
hirokimineshita 0:736c76a75def 3 #include "Utils.h"
hirokimineshita 0:736c76a75def 4 #include "USBHost.h"
hirokimineshita 0:736c76a75def 5 #include "hci.h"
hirokimineshita 0:736c76a75def 6 #include "ps3.h"
hirokimineshita 0:736c76a75def 7 #include "User.h"
hirokimineshita 0:736c76a75def 8
hirokimineshita 0:736c76a75def 9 #include "mbed.h"
hirokimineshita 0:736c76a75def 10
hirokimineshita 0:736c76a75def 11 //ここに関数外に書く要素を記入する
hirokimineshita 0:736c76a75def 12 int RSX,RSY,LSX,LSY,BSU,BSL;
hirokimineshita 0:736c76a75def 13 PwmOut led1(LED1);
hirokimineshita 0:736c76a75def 14 PwmOut led2(LED2);
hirokimineshita 0:736c76a75def 15 DigitalOut led3(LED3);
hirokimineshita 0:736c76a75def 16 DigitalOut led4(LED4);
hirokimineshita 0:736c76a75def 17
hirokimineshita 3:fe59877ed801 18 /** UserLoopSetting :
hirokimineshita 2:0e2a5eaebd27 19 * @bref write proguram in this funtion what you want to do 1st and once.
hirokimineshita 2:0e2a5eaebd27 20 */
hirokimineshita 0:736c76a75def 21 void UserLoopSetting(){
hirokimineshita 0:736c76a75def 22 //一度だけ行いたい初期設定をここに書く
hirokimineshita 0:736c76a75def 23 led1.period_ms(20);
hirokimineshita 0:736c76a75def 24 }
hirokimineshita 0:736c76a75def 25
hirokimineshita 3:fe59877ed801 26 /** UserLoop :
hirokimineshita 2:0e2a5eaebd27 27 * @bref write proguram in this function what you want to do.
hirokimineshita 2:0e2a5eaebd27 28 */
hirokimineshita 0:736c76a75def 29 void UserLoop(char n,const u8* data){
hirokimineshita 0:736c76a75def 30 u16 ButtonState;
hirokimineshita 0:736c76a75def 31 if(n==0){//有線Ps3USB.cpp
hirokimineshita 0:736c76a75def 32 RSX = ((ps3report*)data)->RightStickX;
hirokimineshita 0:736c76a75def 33 RSY = ((ps3report*)data)->RightStickY;
hirokimineshita 0:736c76a75def 34 LSX = ((ps3report*)data)->LeftStickX;
hirokimineshita 0:736c76a75def 35 LSY = ((ps3report*)data)->LeftStickY;
hirokimineshita 0:736c76a75def 36 BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff);
hirokimineshita 0:736c76a75def 37 BSL = (u8)(((ps3report*)data)->ButtonState >> 8);
hirokimineshita 0:736c76a75def 38 //ボタンの処理
hirokimineshita 0:736c76a75def 39 ButtonState = ((ps3report*)data)->ButtonState;
hirokimineshita 0:736c76a75def 40 }else {//無線TestShell.cpp
hirokimineshita 0:736c76a75def 41 RSX = ((ps3report*)(data + 1))->RightStickX;
hirokimineshita 0:736c76a75def 42 RSY = ((ps3report*)(data + 1))->RightStickY;
hirokimineshita 0:736c76a75def 43 LSX = ((ps3report*)(data + 1))->LeftStickX;
hirokimineshita 0:736c76a75def 44 LSY = ((ps3report*)(data + 1))->LeftStickY;
hirokimineshita 0:736c76a75def 45 BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff);
hirokimineshita 0:736c76a75def 46 BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8);
hirokimineshita 0:736c76a75def 47 //ボタンの処理
hirokimineshita 0:736c76a75def 48 ButtonState = ((ps3report*)(data + 1))->ButtonState;
hirokimineshita 0:736c76a75def 49 }
hirokimineshita 0:736c76a75def 50 //ここより下にプログラムを書く
hirokimineshita 0:736c76a75def 51 //データ取得例
hirokimineshita 0:736c76a75def 52 if((ButtonState >> BUTTONCIRCLE)&1) {
hirokimineshita 0:736c76a75def 53 //○が押されたとき
hirokimineshita 0:736c76a75def 54 }
hirokimineshita 0:736c76a75def 55 led1=LSX/256.0f;
hirokimineshita 0:736c76a75def 56 led2=LSY/256.0f;
hirokimineshita 0:736c76a75def 57 led3=ButtonState & 0x0400; //L1の状態
hirokimineshita 0:736c76a75def 58 led4=ButtonState & 0x0800; //R1の状態
hirokimineshita 0:736c76a75def 59 //値の取得はps3.hを参照
hirokimineshita 0:736c76a75def 60 }