gyo
Diff: SBDBT.cpp
- Revision:
- 9:8538fc8f6259
- Parent:
- 7:30e05998769b
- Child:
- 10:b352937cda3b
--- a/SBDBT.cpp Tue Sep 12 00:00:50 2017 +0000 +++ b/SBDBT.cpp Sat Feb 16 07:24:19 2019 +0000 @@ -1,9 +1,6 @@ #include "SBDBT.h" -namespace raven -{ - - SBDBT::SBDBT(PinName p1, PinName p2) + SBDBT::SBDBT(PinName p1, PinName p2) { i = 0; readable = 0; @@ -62,118 +59,46 @@ data[6] = tmp[6]; data[7] = tmp[7]; readable = 1; //全データ受信完了 + check(); i=0; //位置を初期化 } } void SBDBT::print() { - printf("%3d %3d %3d %3d %3d %3d %3d %3d\n",data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]); - } - - char SBDBT::maru() - { - if(data[2] & 64) - return 1; - return 0; - } - - char SBDBT::batu() - { - if(data[2] & 32) - return 1; - return 0; - } - - char SBDBT::sikaku() - { - if(data[1] & 1) - return 1; - return 0; + printf("%3d %3d %3d %3d %3d %3d %3d %3d\r\n",data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]); } - char SBDBT::sankaku() - { - if(data[2] & 16) - return 1; - return 0; - } - - char SBDBT::L1() + int8_t SBDBT::State_check() { - if(data[1] & 2) - return 1; - return 0; - } - - char SBDBT::L2() - { - if(data[1] & 4) - return 1; - return 0; - } - - char SBDBT::R1() - { - if(data[1] & 8) - return 1; - return 0; + if(readable == 1)return 1; + else return 0; } - char SBDBT::R2() - { - if(data[1] & 16) - return 1; - return 0; - } - - char SBDBT::ue() - { - if(data[2] & 1) - return 1; - return 0; - } - - char SBDBT::sita() - { - if(data[2] & 2) - return 1; - return 0; + void SBDBT::check() + { + SQUARE=((data[1] & 1) ? 1 : 0); + L1 = ((data[1] & 2) ? 1 : 0); + L2 = ((data[1] & 4) ? 1 : 0); + L3 = ((data[1] & 8) ? 1 : 0); + R1 = ((data[1] & 16)? 1 : 0); + R2 = ((data[1] & 32)? 1 : 0); + R3 = ((data[1] & 64)? 1 : 0); + + UPkey = ((data[2] & 1) ? 1 : 0); + DOWNkey = ((data[2] & 2) ? 1 : 0); + RIGHTkey = ((data[2] & 4) ? 1 : 0); + LEFTkey = ((data[2] & 8) ? 1 : 0); + TRIANGLE = ((data[2] & 16)? 1 : 0); + CROSS = ((data[2] & 32)? 1 : 0); + CIRCLE = ((data[2] & 64)? 1 : 0); + + LX = data[3]; + LY = data[4]; + RX = data[5]; + RY = data[6]; } - char SBDBT::migi() - { - if(data[2] & 4) - return 1; - return 0; - } - - char SBDBT::hidari() - { - if(data[2] & 8) - return 1; - return 0; - } - - signed char SBDBT::rs_x() - { - return data[5]; - } - - signed char SBDBT::rs_y() - { - return data[6]; - } - - signed char SBDBT::ls_x() - { - return data[3]; - } - - signed char SBDBT::ls_y() - { - return data[4]; - } char SBDBT::rs_x_check() { @@ -201,4 +126,4 @@ delete tmp; delete data; } -}//namespace \ No newline at end of file +