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

Dependencies:   mbed

Fork of F3RC_syudou_master_3 by 日記

Committer:
abcdefgh
Date:
Sat Apr 29 11:48:36 2017 +0000
Revision:
15:c5258a4dee75
Parent:
14:5c92c3c78290
Child:
16:b232fd9ee9c2
ps3

Who changed what in which revision?

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