Ensar Muratovic Haris Spahić

Dependencies:   PS2 mbed

Fork of PS2_Test_V2 by Emir Sokic

main.cpp

Committer:
tim007
Date:
2014-06-05
Revision:
1:1c70f61a8486
Parent:
0:a18457486d66

File content as of revision 1:1c70f61a8486:


#include "mbed.h"
#include "PS2Mouse.h"

//CLKpin, DATApin
PS2Mouse ps2ms(dp10, dp11);
Serial pc(USBTX,USBRX);
DigitalOut ledica(dp28);
DigitalOut enable(dp14);
int sumax=0;
int sumay=0;
int br=0;


int main()
{
    ledica=1;
    enable=0;
    wait(0.5);
    pc.printf("Inicijaliziran");
    pc.putc('\n');
    enable=1;
    wait(0.5);
    enable=0;

    PS2Mouse::mouse_event_t evt_ms;

    pc.printf("Zakacen Event");
    pc.putc('\n');
    enable=1;
    wait(0.5);
    enable=0;


    while (1) {

        if (ps2ms.processing(&evt_ms)) {
            //pc.printf("L:%d C:%d R:%d X:%4d Y:%4d Z:%2d\n",  int(evt_ms.left), int(evt_ms.center),  int(evt_ms.right), evt_ms.x, evt_ms.y, evt_ms.z);
            int pom=0;
            if (evt_ms.x>0) pom=1;
            if (evt_ms.x<0) pom=-1;
            sumax=sumax+pom;

            int pomy=0;
            if (evt_ms.y>0) pomy=1;
            if (evt_ms.y<0) pomy=-1;
            sumay=sumay+pomy;
            
            pc.printf("x: %d , y: %d \n", sumax, sumay);
            /*pc.printf("%d",evt_ms.x);
            if (evt_ms.x<0) pc.printf("Lijevo"); else pc.printf("Desno");
            if (evt_ms.y<=0) pc.printf("Dole\n"); else pc.printf("Gore\n");
            if (evt_ms.left) pc.printf("Kliknut lijevo\n");
            if (evt_ms.right) pc.printf("Kliknut desno\n");
                 pc.printf("L: %c\n", evt_ms.left);
                     pc.printf("C: %c\n", evt_ms.center);
                     pc.printf("R: %c\n", evt_ms.right);
                     pc.printf("X: %4d\n", evt_ms.x);
                     pc.printf("Y: %4d\n", evt_ms.y);
                     pc.printf("Z: %2d\n", evt_ms.z);
                     pc.printf("----------------\n");
                    */
        }
       
        //sumax=0;
        //sumay=0;
    }
}