Za liniju

Dependents:   Lilnija_29012017

joystick.cpp

Committer:
mario_meh
Date:
2017-01-29
Revision:
0:bd9f3303564e
Child:
1:95b8a1055816
Child:
2:bdd4ee83ec25

File content as of revision 0:bd9f3303564e:

#include "mbed.h"
#include "tipkalo.h"

Joystick::Joystick() : _x(PTB0), _y(PTB1)
        
                     //  PTB0  |   PTB1  
{
    
    Tipkalo tjoys = new Tipkalo(PT); 

}

JoysKompas Joystick::read() {
    
    JoysKompas data;
    
    data.horizontala   = X();
    data.vertikala     = Y();
    data.jTipkalo      = t_status.radim;
    return data;
    
}

//------------- KOMPAS NAV Y --- -----------/
Kompas Joystick::Y() {
    if(_y.read() < 0.022222222) {
        return Dolje; 
    } else if(_y.read() > 0.9888888) {
        return Gore;
    }
}

//------------- KOMPAS NAV X ---------------/
Kompas Joystick::X() {
    if(_x.read() < 0.022222222) {
        return Lijevo; 
    } else if(_x.read() > 0.9888888) {
        return Desno;
    }
}

//------------- KOMPAS TIPKA ---------------/
Kompas tipka() {
    if(tjoys->tDolje()) {
        return NijeOdabir;
    } else {
        return Odabir;
    }
}