Za liniju
joystick.cpp@0:bd9f3303564e, 2017-01-29 (annotated)
- Committer:
- mario_meh
- Date:
- Sun Jan 29 23:48:12 2017 +0000
- Revision:
- 0:bd9f3303564e
- Child:
- 1:95b8a1055816
- Child:
- 2:bdd4ee83ec25
Joystick linija upravljanja
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mario_meh | 0:bd9f3303564e | 1 | #include "mbed.h" |
mario_meh | 0:bd9f3303564e | 2 | #include "tipkalo.h" |
mario_meh | 0:bd9f3303564e | 3 | |
mario_meh | 0:bd9f3303564e | 4 | Joystick::Joystick() : _x(PTB0), _y(PTB1) |
mario_meh | 0:bd9f3303564e | 5 | |
mario_meh | 0:bd9f3303564e | 6 | // PTB0 | PTB1 |
mario_meh | 0:bd9f3303564e | 7 | { |
mario_meh | 0:bd9f3303564e | 8 | |
mario_meh | 0:bd9f3303564e | 9 | Tipkalo tjoys = new Tipkalo(PT); |
mario_meh | 0:bd9f3303564e | 10 | |
mario_meh | 0:bd9f3303564e | 11 | } |
mario_meh | 0:bd9f3303564e | 12 | |
mario_meh | 0:bd9f3303564e | 13 | JoysKompas Joystick::read() { |
mario_meh | 0:bd9f3303564e | 14 | |
mario_meh | 0:bd9f3303564e | 15 | JoysKompas data; |
mario_meh | 0:bd9f3303564e | 16 | |
mario_meh | 0:bd9f3303564e | 17 | data.horizontala = X(); |
mario_meh | 0:bd9f3303564e | 18 | data.vertikala = Y(); |
mario_meh | 0:bd9f3303564e | 19 | data.jTipkalo = t_status.radim; |
mario_meh | 0:bd9f3303564e | 20 | return data; |
mario_meh | 0:bd9f3303564e | 21 | |
mario_meh | 0:bd9f3303564e | 22 | } |
mario_meh | 0:bd9f3303564e | 23 | |
mario_meh | 0:bd9f3303564e | 24 | //------------- KOMPAS NAV Y --- -----------/ |
mario_meh | 0:bd9f3303564e | 25 | Kompas Joystick::Y() { |
mario_meh | 0:bd9f3303564e | 26 | if(_y.read() < 0.022222222) { |
mario_meh | 0:bd9f3303564e | 27 | return Dolje; |
mario_meh | 0:bd9f3303564e | 28 | } else if(_y.read() > 0.9888888) { |
mario_meh | 0:bd9f3303564e | 29 | return Gore; |
mario_meh | 0:bd9f3303564e | 30 | } |
mario_meh | 0:bd9f3303564e | 31 | } |
mario_meh | 0:bd9f3303564e | 32 | |
mario_meh | 0:bd9f3303564e | 33 | //------------- KOMPAS NAV X ---------------/ |
mario_meh | 0:bd9f3303564e | 34 | Kompas Joystick::X() { |
mario_meh | 0:bd9f3303564e | 35 | if(_x.read() < 0.022222222) { |
mario_meh | 0:bd9f3303564e | 36 | return Lijevo; |
mario_meh | 0:bd9f3303564e | 37 | } else if(_x.read() > 0.9888888) { |
mario_meh | 0:bd9f3303564e | 38 | return Desno; |
mario_meh | 0:bd9f3303564e | 39 | } |
mario_meh | 0:bd9f3303564e | 40 | } |
mario_meh | 0:bd9f3303564e | 41 | |
mario_meh | 0:bd9f3303564e | 42 | //------------- KOMPAS TIPKA ---------------/ |
mario_meh | 0:bd9f3303564e | 43 | Kompas tipka() { |
mario_meh | 0:bd9f3303564e | 44 | if(tjoys->tDolje()) { |
mario_meh | 0:bd9f3303564e | 45 | return NijeOdabir; |
mario_meh | 0:bd9f3303564e | 46 | } else { |
mario_meh | 0:bd9f3303564e | 47 | return Odabir; |
mario_meh | 0:bd9f3303564e | 48 | } |
mario_meh | 0:bd9f3303564e | 49 | } |