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.
PS3.h
00001 #ifndef PS3_H 00002 #define PS3_H 00003 #include "mbed.h" 00004 //bit,button 00005 #define sikaku 16 //00010000 00006 #define sankaku 36 //00100100 00007 #define batu 37 //00100101 00008 #define maru 38 //00100110 00009 #define ue 32 //00100000 00010 #define sita 33 //00100001 00011 #define migi 34 //00100010 00012 #define hidari 35 //00100011 00013 #define L1 17 //00010001 00014 #define L2 18 //00010010 00015 #define R1 19 //00010011 00016 #define R2 20 //00010100 00017 00018 #define PI 3.141592654 00019 00020 class PS3 : public Serial 00021 { 00022 public: 00023 PS3(PinName TX, PinName RX);/* : Serial(TX,RX) 00024 { 00025 PS3Data[0] = 128; 00026 PS3Data[1] = 0; 00027 PS3Data[2] = 0; 00028 PS3Data[3] = 64; 00029 PS3Data[4] = 64; 00030 PS3Data[5] = 64; 00031 PS3Data[6] = 64; 00032 PS3Data[7] = 0; 00033 baud(2400); 00034 attach(this, &PS3::getdata, Serial::RxIrq); 00035 }*/ 00036 void getdata(); 00037 /*{ 00038 if(Serial::readable()) 00039 { 00040 for(int i = 0;i < 8;i++) 00041 *(PS3Data+i) = Serial::getc(); 00042 } 00043 }*/ 00044 void myattach(); 00045 void addattach(void (*Func)()); 00046 void nothingFunc(); 00047 bool getButtonState(int button); 00048 bool getSELECTState(); 00049 bool getSTARTState(); 00050 int getRightJoystickXaxis(); 00051 int getRightJoystickYaxis(); 00052 int getLeftJoystickXaxis(); 00053 int getLeftJoystickYaxis(); 00054 /*{ 00055 return (*(PS3Data+(button>>4)) >> (button & 0x0f)) & 1; 00056 }*/ 00057 double getRightJoystickAngle(); 00058 /*{ 00059 return atan2(double(PS3Data[6]*-1+64), double(PS3Data[5]-64))*double(180/PI); 00060 }*/ 00061 double getLeftJoystickAngle(); 00062 /*{ 00063 return atan2(double(PS3Data[4]*-1+64), double(PS3Data[3]-64))*double(180/PI); 00064 }*/ 00065 void printdata(); 00066 private: 00067 char PS3Data[8]; 00068 void (*fpFunc)(); 00069 bool addflag; 00070 }; 00071 00072 #endif
Generated on Mon Jul 25 2022 14:52:19 by
