ps3 with sbdbt
Dependents: NHK2019manualver2 NHK2019manualver2_10_3
Diff: PS3.h
- Revision:
- 0:87f83956cb4c
- Child:
- 2:fe29007fb56c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PS3.h Tue May 10 08:18:54 2016 +0000 @@ -0,0 +1,60 @@ +#ifndef PS3_H +#define PS3_H +#include "mbed.h" + //bit,button +#define sikaku 16 //00010000 +#define sankaku 36 //00100100 +#define batu 37 //00100101 +#define maru 38 //00100110 +#define ue 32 //00100000 +#define sita 33 //00100001 +#define migi 34 //00100010 +#define hidari 35 //00100011 +#define L1 17 //00010001 +#define L2 18 //00010010 +#define R1 19 //00010011 +#define R2 20 //00010100 + +#define PI 3.141592654 + +class PS3 : public Serial +{ + public: + PS3(PinName TX, PinName RX);/* : Serial(TX,RX) + { + PS3Data[0] = 128; + PS3Data[1] = 0; + PS3Data[2] = 0; + PS3Data[3] = 64; + PS3Data[4] = 64; + PS3Data[5] = 64; + PS3Data[6] = 64; + PS3Data[7] = 0; + baud(2400); + attach(this, &PS3::getdata, Serial::RxIrq); + }*/ + void getdata(); + /*{ + if(Serial::readable()) + { + for(int i = 0;i < 8;i++) + *(PS3Data+i) = Serial::getc(); + } + }*/ + bool getButtonState(int button); + /*{ + return (*(PS3Data+(button>>4)) >> (button & 0x0f)) & 1; + }*/ + double getRightJoystickAngle(); + /*{ + return atan2(double(PS3Data[6]*-1+64), double(PS3Data[5]-64))*double(180/PI); + }*/ + double getLeftJoystickAngle(); + /*{ + return atan2(double(PS3Data[4]*-1+64), double(PS3Data[3]-64))*double(180/PI); + }*/ + private: + char PS3Data[8]; +}; + +#endif \ No newline at end of file