Za liniju
Diff: joystick.cpp
- Revision:
- 0:bd9f3303564e
- Child:
- 1:95b8a1055816
- Child:
- 2:bdd4ee83ec25
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/joystick.cpp Sun Jan 29 23:48:12 2017 +0000 @@ -0,0 +1,49 @@ +#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; + } +} \ No newline at end of file