KAIQUE DOGNANI
/
LCD_JOYSTICK
Utilizando a Nucleo F103RB com um módulo LCD e um Joystick para interface
Joystick.cpp@10:d77ef093800b, 2021-08-25 (annotated)
- Committer:
- kaiquedog
- Date:
- Wed Aug 25 13:02:16 2021 +0000
- Revision:
- 10:d77ef093800b
- Parent:
- 9:891ffa97d8fb
Finalizado
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaiquedog | 0:bf743d54917c | 1 | #include "Joystick.h" |
kaiquedog | 0:bf743d54917c | 2 | |
kaiquedog | 0:bf743d54917c | 3 | Joystick::Joystick(PinName vrx, PinName vry, PinName Sw) : VRX(vrx), VRY(vry), Switch(Sw){ |
kaiquedog | 0:bf743d54917c | 4 | } |
kaiquedog | 0:bf743d54917c | 5 | /* |
kaiquedog | 0:bf743d54917c | 6 | *************** |
kaiquedog | 0:bf743d54917c | 7 | **** LER_X **** |
kaiquedog | 0:bf743d54917c | 8 | *************** |
kaiquedog | 0:bf743d54917c | 9 | */ |
kaiquedog | 0:bf743d54917c | 10 | int Joystick::ler_x(void){ |
kaiquedog | 0:bf743d54917c | 11 | int a = 2; |
kaiquedog | 9:891ffa97d8fb | 12 | |
kaiquedog | 9:891ffa97d8fb | 13 | if (VRX.read()*1000 > 800) |
kaiquedog | 9:891ffa97d8fb | 14 | { |
kaiquedog | 0:bf743d54917c | 15 | a = 1; |
kaiquedog | 0:bf743d54917c | 16 | } |
kaiquedog | 9:891ffa97d8fb | 17 | |
kaiquedog | 9:891ffa97d8fb | 18 | if (VRX.read()*1000 < 200) |
kaiquedog | 9:891ffa97d8fb | 19 | { |
kaiquedog | 0:bf743d54917c | 20 | a = 0; |
kaiquedog | 0:bf743d54917c | 21 | } |
kaiquedog | 9:891ffa97d8fb | 22 | |
kaiquedog | 0:bf743d54917c | 23 | return a; |
kaiquedog | 0:bf743d54917c | 24 | } |
kaiquedog | 0:bf743d54917c | 25 | |
kaiquedog | 0:bf743d54917c | 26 | /* |
kaiquedog | 0:bf743d54917c | 27 | *************** |
kaiquedog | 0:bf743d54917c | 28 | **** LER_Y **** |
kaiquedog | 0:bf743d54917c | 29 | *************** |
kaiquedog | 0:bf743d54917c | 30 | */ |
kaiquedog | 0:bf743d54917c | 31 | int Joystick::ler_y(void){ |
kaiquedog | 0:bf743d54917c | 32 | int a = 2; |
kaiquedog | 9:891ffa97d8fb | 33 | |
kaiquedog | 9:891ffa97d8fb | 34 | if (VRY.read()*1000 > 800) |
kaiquedog | 9:891ffa97d8fb | 35 | { |
kaiquedog | 0:bf743d54917c | 36 | a = 1; |
kaiquedog | 0:bf743d54917c | 37 | } |
kaiquedog | 9:891ffa97d8fb | 38 | |
kaiquedog | 9:891ffa97d8fb | 39 | if (VRY.read()*1000 < 200) |
kaiquedog | 9:891ffa97d8fb | 40 | { |
kaiquedog | 0:bf743d54917c | 41 | a = 0; |
kaiquedog | 0:bf743d54917c | 42 | } |
kaiquedog | 9:891ffa97d8fb | 43 | |
kaiquedog | 0:bf743d54917c | 44 | return a; |
kaiquedog | 0:bf743d54917c | 45 | } |
kaiquedog | 0:bf743d54917c | 46 | |
kaiquedog | 0:bf743d54917c | 47 | /* |
kaiquedog | 0:bf743d54917c | 48 | ******************** |
kaiquedog | 0:bf743d54917c | 49 | **** BOT_SELECT **** |
kaiquedog | 0:bf743d54917c | 50 | ******************** |
kaiquedog | 0:bf743d54917c | 51 | */ |
kaiquedog | 0:bf743d54917c | 52 | int Joystick::bot_select(void){ |
kaiquedog | 0:bf743d54917c | 53 | int a = 2; |
kaiquedog | 9:891ffa97d8fb | 54 | |
kaiquedog | 9:891ffa97d8fb | 55 | switch(Switch) |
kaiquedog | 9:891ffa97d8fb | 56 | { |
kaiquedog | 10:d77ef093800b | 57 | case 1: a = 0; break; // Botão desapertado |
kaiquedog | 10:d77ef093800b | 58 | case 0: a= 1; break; // Botão apertado |
kaiquedog | 0:bf743d54917c | 59 | } |
kaiquedog | 0:bf743d54917c | 60 | |
kaiquedog | 0:bf743d54917c | 61 | return a; |
kaiquedog | 0:bf743d54917c | 62 | } |
kaiquedog | 0:bf743d54917c | 63 |