ps3 with sbdbt
Dependents: NHK2019manualver2 NHK2019manualver2_10_3
PS3.h@2:fe29007fb56c, 2016-09-26 (annotated)
- Committer:
- sgrsn
- Date:
- Mon Sep 26 10:28:39 2016 +0000
- Revision:
- 2:fe29007fb56c
- Parent:
- 0:87f83956cb4c
- Child:
- 3:5640aae53391
be able to add function in serial attach
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgrsn | 0:87f83956cb4c | 1 | #ifndef PS3_H |
sgrsn | 0:87f83956cb4c | 2 | #define PS3_H |
sgrsn | 0:87f83956cb4c | 3 | #include "mbed.h" |
sgrsn | 0:87f83956cb4c | 4 | //bit,button |
sgrsn | 0:87f83956cb4c | 5 | #define sikaku 16 //00010000 |
sgrsn | 0:87f83956cb4c | 6 | #define sankaku 36 //00100100 |
sgrsn | 0:87f83956cb4c | 7 | #define batu 37 //00100101 |
sgrsn | 0:87f83956cb4c | 8 | #define maru 38 //00100110 |
sgrsn | 0:87f83956cb4c | 9 | #define ue 32 //00100000 |
sgrsn | 0:87f83956cb4c | 10 | #define sita 33 //00100001 |
sgrsn | 0:87f83956cb4c | 11 | #define migi 34 //00100010 |
sgrsn | 0:87f83956cb4c | 12 | #define hidari 35 //00100011 |
sgrsn | 0:87f83956cb4c | 13 | #define L1 17 //00010001 |
sgrsn | 0:87f83956cb4c | 14 | #define L2 18 //00010010 |
sgrsn | 0:87f83956cb4c | 15 | #define R1 19 //00010011 |
sgrsn | 0:87f83956cb4c | 16 | #define R2 20 //00010100 |
sgrsn | 0:87f83956cb4c | 17 | |
sgrsn | 0:87f83956cb4c | 18 | #define PI 3.141592654 |
sgrsn | 0:87f83956cb4c | 19 | |
sgrsn | 0:87f83956cb4c | 20 | class PS3 : public Serial |
sgrsn | 0:87f83956cb4c | 21 | { |
sgrsn | 0:87f83956cb4c | 22 | public: |
sgrsn | 0:87f83956cb4c | 23 | PS3(PinName TX, PinName RX);/* : Serial(TX,RX) |
sgrsn | 0:87f83956cb4c | 24 | { |
sgrsn | 0:87f83956cb4c | 25 | PS3Data[0] = 128; |
sgrsn | 0:87f83956cb4c | 26 | PS3Data[1] = 0; |
sgrsn | 0:87f83956cb4c | 27 | PS3Data[2] = 0; |
sgrsn | 0:87f83956cb4c | 28 | PS3Data[3] = 64; |
sgrsn | 0:87f83956cb4c | 29 | PS3Data[4] = 64; |
sgrsn | 0:87f83956cb4c | 30 | PS3Data[5] = 64; |
sgrsn | 0:87f83956cb4c | 31 | PS3Data[6] = 64; |
sgrsn | 0:87f83956cb4c | 32 | PS3Data[7] = 0; |
sgrsn | 0:87f83956cb4c | 33 | baud(2400); |
sgrsn | 0:87f83956cb4c | 34 | attach(this, &PS3::getdata, Serial::RxIrq); |
sgrsn | 0:87f83956cb4c | 35 | }*/ |
sgrsn | 0:87f83956cb4c | 36 | void getdata(); |
sgrsn | 0:87f83956cb4c | 37 | /*{ |
sgrsn | 0:87f83956cb4c | 38 | if(Serial::readable()) |
sgrsn | 0:87f83956cb4c | 39 | { |
sgrsn | 0:87f83956cb4c | 40 | for(int i = 0;i < 8;i++) |
sgrsn | 0:87f83956cb4c | 41 | *(PS3Data+i) = Serial::getc(); |
sgrsn | 0:87f83956cb4c | 42 | } |
sgrsn | 0:87f83956cb4c | 43 | }*/ |
sgrsn | 2:fe29007fb56c | 44 | void myattach(); |
sgrsn | 2:fe29007fb56c | 45 | void addattach(void (*Func)()); |
sgrsn | 2:fe29007fb56c | 46 | void nothingFunc(); |
sgrsn | 0:87f83956cb4c | 47 | bool getButtonState(int button); |
sgrsn | 2:fe29007fb56c | 48 | int getRightJoystickXaxis(); |
sgrsn | 2:fe29007fb56c | 49 | int getRightJoystickYaxis(); |
sgrsn | 2:fe29007fb56c | 50 | int getLeftJoystickXaxis(); |
sgrsn | 2:fe29007fb56c | 51 | int getLeftJoystickYaxis(); |
sgrsn | 0:87f83956cb4c | 52 | /*{ |
sgrsn | 0:87f83956cb4c | 53 | return (*(PS3Data+(button>>4)) >> (button & 0x0f)) & 1; |
sgrsn | 0:87f83956cb4c | 54 | }*/ |
sgrsn | 0:87f83956cb4c | 55 | double getRightJoystickAngle(); |
sgrsn | 0:87f83956cb4c | 56 | /*{ |
sgrsn | 0:87f83956cb4c | 57 | return atan2(double(PS3Data[6]*-1+64), double(PS3Data[5]-64))*double(180/PI); |
sgrsn | 0:87f83956cb4c | 58 | }*/ |
sgrsn | 0:87f83956cb4c | 59 | double getLeftJoystickAngle(); |
sgrsn | 0:87f83956cb4c | 60 | /*{ |
sgrsn | 0:87f83956cb4c | 61 | return atan2(double(PS3Data[4]*-1+64), double(PS3Data[3]-64))*double(180/PI); |
sgrsn | 0:87f83956cb4c | 62 | }*/ |
sgrsn | 0:87f83956cb4c | 63 | private: |
sgrsn | 0:87f83956cb4c | 64 | char PS3Data[8]; |
sgrsn | 2:fe29007fb56c | 65 | void (*fpFunc)(); |
sgrsn | 2:fe29007fb56c | 66 | bool addflag; |
sgrsn | 0:87f83956cb4c | 67 | }; |
sgrsn | 0:87f83956cb4c | 68 | |
sgrsn | 0:87f83956cb4c | 69 | #endif |