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:
- 0:4289fbe66d45
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun Jun 21 01:48:47 2020 +0000
@@ -0,0 +1,105 @@
+#include "mbedserial.h"
+#include "dualshock3.h"
+
+Dualshock3 controller(D1,D0);
+Serial pc(USBTX,USBRX,115200);
+Mbedserial Ms(pc);
+
+/*
+void CallBack_float();
+void CallBack_int();
+void CallBack_char();
+*/
+
+int main(){
+ //受信コールバック関数の設定
+/*
+ Ms.float_attach(CallBack_float);
+ Ms.int_attach(CallBack_int);
+ Ms.char_attach(CallBack_char);
+*/
+
+ //ボーレート(通信速度)を2400bpsに設定
+ controller.set_baudrate(2400);
+ //dualshock3との通信開始
+ controller.initialize();
+
+// int data[2] = {70,70};
+ int buttons_info[14] = {};
+ float sticks_info[4] = {};
+
+ while(1){
+ controller.get_all_buttons_info(buttons_info);
+ controller.get_all_sticks_info(sticks_info);
+/*
+ pc.printf("buttons:");
+ for(int i=0;i<14;i++){
+ pc.printf("%d ",buttons_info[i]);
+ }
+ pc.printf("\r\n");
+ pc.printf("sticks:");
+ for(int i=0;i<4;i++){
+ pc.printf("%f_",sticks_info[i]);
+ }
+ pc.printf("\r\n");
+*/
+/*
+ printf("L_x = %.2f ", controller.get_left_stick_x());
+ printf("L_y = %.2f ", controller.get_left_stick_y());
+ printf("R_x = %.2f ", controller.get_right_stick_x());
+ printf("R_y = %.2f\r\n", controller.get_right_stick_y());
+*/
+ Ms.int_write(buttons_info,14);
+ wait(0.5);
+ Ms.float_write(sticks_info,4);
+ wait(0.5);
+
+ // Ms.int_write(data,2);
+/*
+ if(data[0]<73)
+ data[0]++;
+ else
+ data[0]-=3;
+ if(data[1]>70)
+ data[1]--;
+ else
+ data[1]+=3;
+ */
+
+ //ループの最後に呼ぶこと
+ controller.clear();
+ wait(0.1);
+ }
+}
+
+/*
+void CallBack_float(){
+ //受信
+ //配列サイズを取得
+ int size = Ms.floatarraysize;
+ //データを取得
+ float *f = Ms.getfloat;
+ //送信
+ Ms.float_write(f,size);
+}
+
+void CallBack_int(){
+ //受信
+ //配列サイズを取得
+ int size = Ms.intarraysize;
+ //データを取得
+ int *i = Ms.getint;
+ //送信
+ Ms.int_write(i,size);
+}
+
+void CallBack_char(){
+ //受信
+ //配列サイズを取得
+ int size = Ms.chararraysize;
+ //データを取得
+ char *c = Ms.getchar;
+ //送信
+ Ms.char_write(c,size);
+}
+*/
\ No newline at end of file