Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ipst.h> // IPST-SE Board
- #include <PS2X_lib.h>
- #define PS2_DAT 26
- #define PS2_CMD 27
- #define PS2_SEL 28
- #define PS2_CLK 29
- int error;
- int x;
- PS2X psx;
- void setup(){
- setTextSize(2);glcdMode(1);
- glcd(0,0,"OK->Bluetooth");
- glcd(1,0,"SW1->JOY PSX");
- while(1){
- if(sw1()){joy();}
- if(sw_OK()){blue();}
- }
- }
- void loop(){}
- void blue(){
- glcdClear();
- setTextSize(3);glcdMode(1);
- setTextColor(GLCD_BLUE);
- glcd(1,0,"Bluetooth");
- pinMode(2,INPUT_PULLUP);
- while(!sw1()){
- if (uart1_available()) {
- x=uart1_getkey();
- if(x==0x38){fd(100);}
- else if(x==0x32){bk(100);}
- else if(x==0x34){sl(100);}
- else if(x==0x36){sr(100);}
- else {ao();}
- }
- }
- }
- void joy(){
- glcdClear();
- setTextSize(3);glcdMode(1);
- setTextColor(GLCD_YELLOW);
- glcd(1,0,"JOY PSX");
- while(1){
- if (!psx.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, false, false)){
- setTextColor(GLCD_RED);setTextSize(2);
- glcd(3,0,"Connected ");
- break;
- }
- }
- while(!sw_OK()){
- psx.read_gamepad(0,0); // Read PSX
- if(psx.Button(PSB_PAD_UP)||psx.Button(PSB_TRIANGLE)){fd(100);}
- else if(psx.Button(PSB_PAD_DOWN)||psx.Button(PSB_CROSS)){bk(100);}
- else if(psx.Button(PSB_PAD_LEFT)||psx.Button(PSB_SQUARE)){sl(100);}
- else if(psx.Button(PSB_PAD_RIGHT)||psx.Button(PSB_CIRCLE)){sr(100);}
- else{ao();}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement