IM315を用いてDS2(PS2コントローラー)を扱うライブラリ

Files at this revision

API Documentation at this revision

Comitter:
m2130
Date:
Mon Apr 04 06:19:27 2022 +0000
Parent:
0:06c265b1fbd1
Commit message:
IM315 de DS2

Changed in this revision

IM315.cpp Show annotated file Show diff for this revision Revisions of this file
IM315.hpp Show annotated file Show diff for this revision Revisions of this file
diff -r 06c265b1fbd1 -r 9ad38dad969c IM315.cpp
--- a/IM315.cpp	Mon Apr 04 06:15:23 2022 +0000
+++ b/IM315.cpp	Mon Apr 04 06:19:27 2022 +0000
@@ -24,6 +24,7 @@
     dev = new Serial(TX, RX);
     dev -> baud(19200);
     _pc -> baud(baud);
+    dev -> printf("SRST\r\n");
     dev -> attach(callback(this,&IM315::get),Serial::RxIrq);
 }
 
@@ -73,9 +74,7 @@
 
 void IM315::button_state(){_pc -> printf("U: %d, D: %d, R: %d, L: %d, TRI: %d, X: %d, O: %d, SQU: %d, L1: %d, L2: %d, R1: %d, R2: %d, STA: %d, SEL: %d, L3: %3d, R3: %3d LSX: %3d, LSY: %3d, RSX: %3d, RY: %3d\n",up(), down(), right(), left(), tri(), cross(), circle(), square(), l1(), l2(), r1(), r2(), start(), select(), l3(), r3(), lsx(), lsy(), rsx(), rsy());}
 
-void IM315::data_print(){
-    _pc -> printf("%2x %2x %2x %2x %2x %2x %2x %2x\n", DATA[0], DATA[1], DATA[2], DATA[3], DATA[4], DATA[5], DATA[6], DATA[7]);
-}
+void IM315::data_print(){_pc -> printf("%2x %2x %2x %2x %2x %2x %2x %2x\n", DATA[0], DATA[1], DATA[2], DATA[3], DATA[4], DATA[5], DATA[6], DATA[7]);}
 
 bool IM315::up(){return DATA[2] & UP ? 1 : 0;}
 
diff -r 06c265b1fbd1 -r 9ad38dad969c IM315.hpp
--- a/IM315.hpp	Mon Apr 04 06:15:23 2022 +0000
+++ b/IM315.hpp	Mon Apr 04 06:19:27 2022 +0000
@@ -27,6 +27,7 @@
   IM315 ds2(D1, D0);                           マイコン ~ PC間のボーレート指定なし(9600)
   IM315 ds2(D1, D0, 115200);                   マイコン ~ PC間のボーレート指定あり
   
+  
   DS2はArduino Nano用読み取り基盤を用いてボタンの状態を読み取り下記のような8バイトの文字列データ(16進数表記)にして送信してください
  /-------------------------------------------- 
   DATA[0]           0x80固定
@@ -38,12 +39,15 @@
   例 80010400FF808080    △ボタンと十字左ボタンが押され、Lスティックを最大まで右に倒した場合
  /--------------------------------------------
  
+ 
  /---------- sbdbtライブラリとの相違点 ----------
   ・ニュートラル関数がない(スティックのニュートラル値が定まらずほぼ機能していない)
   ・L2 R2ボタンがアナログで使用不可能
   ・L3 R3ボタン(スティック押し込み)が使用可能
   ・スティックの入力範囲が 0 ~ 255 となっている
   ・スティックの初期値(ニュートラル値)は 0x7f ~ 0x80(127 ~ 128)だと思われる 定まらない(ハードウェア上の問題?)
+ /--------------------------------------------
+ 
 */
 
 class IM315{