ps3 with sbdbt

Dependents:   Base_Hybrid_Latihan_Ok_Hajar_servo_senso 2016_mother_3

PS3.h

Committer:
sgrsn
Date:
2016-05-10
Revision:
0:87f83956cb4c
Child:
2:fe29007fb56c

File content as of revision 0:87f83956cb4c:

#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