プレステ1アナログコントローラ用ライブラリのサンプル

Dependencies:   mbed-src

main.cpp

Committer:
kurt
Date:
2014-04-04
Revision:
3:3a33f8294a84
Parent:
0:ab4722670dd8

File content as of revision 3:3a33f8294a84:

#include "mbed.h"
#include "pspad.h"

Serial pc(USBTX, USBRX);
Pspad  PS(PTB11,PTB10,PTB9,PTB8);
Timer LapTime;

int main() {
    pc.baud(921600);
    while(1) {
        PS.PsRead();
        
        pc.printf("time:%d",LapTime.read_us());
        LapTime.start();
        
        if(PS.BUTTON.BIT.MARU&&(0==PS.PREV.BUTTON.BIT.MARU))  PS.VIBRATE = 1-PS.VIBRATE;
        pc.printf("%5d %5d", PS.BUTTON.BIT.MARU, PS.PREV.BUTTON.BIT.MARU);
        pc.printf("%5d %5d %5d %5d %5d \r\n", PS.BUTTON.WORD, PS.right_x, PS.right_y, PS.left_x, PS.left_y);
    }
}