KAIQUE DOGNANI
/
LCD_JOYSTICK
Utilizando a Nucleo F103RB com um módulo LCD e um Joystick para interface
main.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 | // / |
kaiquedog | 0:bf743d54917c | 2 | // _,.------....___,.' ',.-. |
kaiquedog | 0:bf743d54917c | 3 | // ,-' _,.--" | |
kaiquedog | 0:bf743d54917c | 4 | // ,' _.-' . |
kaiquedog | 0:bf743d54917c | 5 | // / , ,' ` |
kaiquedog | 0:bf743d54917c | 6 | // . / / ``. |
kaiquedog | 0:bf743d54917c | 7 | // | | . \.\ |
kaiquedog | 0:bf743d54917c | 8 | // ____ |___._. | __ \ `. |
kaiquedog | 0:bf743d54917c | 9 | // .' `---"" ``"-.--"'` \ . \ |
kaiquedog | 0:bf743d54917c | 10 | // . , __ ` | . |
kaiquedog | 0:bf743d54917c | 11 | // `,' ,-"' . \ | L |
kaiquedog | 0:bf743d54917c | 12 | // ,' ' _.' -._ / | |
kaiquedog | 0:bf743d54917c | 13 | // ,`-. ,". `--' >. ,' | |
kaiquedog | 0:bf743d54917c | 14 | // . .'\' `-' __ , ,-. / `.__.- ,' |
kaiquedog | 0:bf743d54917c | 15 | // ||:, . ,' ; / / \ ` `. . .'/ |
kaiquedog | 0:bf743d54917c | 16 | // j|:D \ `--' ' ,'_ . . `.__, \ , / |
kaiquedog | 0:bf743d54917c | 17 | // L:_ | . "' :_; `.'.' |
kaiquedog | 0:bf743d54917c | 18 | //. ""' """""' V |
kaiquedog | 0:bf743d54917c | 19 | // `. . `. _,.. ` |
kaiquedog | 0:bf743d54917c | 20 | // `,_ . . _,-'/ .. `,' __ ` |
kaiquedog | 0:bf743d54917c | 21 | // ) \`._ ___....----"' ,' .' \ | ' \ . |
kaiquedog | 0:bf743d54917c | 22 | // / `. "`-.--"' _,' ,' `---' | `./ | |
kaiquedog | 0:bf743d54917c | 23 | // . _ `""'--.._____..--" , ' | |
kaiquedog | 0:bf743d54917c | 24 | // | ." `. `-. /-. / , |
kaiquedog | 0:bf743d54917c | 25 | // | `._.' `,_ ; / ,' . |
kaiquedog | 0:bf743d54917c | 26 | // .' /| `-. . ,' , , |
kaiquedog | 0:bf743d54917c | 27 | // '-.__ __ _,',' '`-..___;-...__ ,.'\ ____.___.' |
kaiquedog | 0:bf743d54917c | 28 | // `"^--'..' '-`-^-'"-- `-^-'`.''"""""`.,^.`.--' |
kaiquedog | 0:bf743d54917c | 29 | #include "mbed.h" |
kaiquedog | 0:bf743d54917c | 30 | #include "LCD_ka.h" |
kaiquedog | 0:bf743d54917c | 31 | #include "Joystick.h" |
kaiquedog | 0:bf743d54917c | 32 | |
rhisis | 8:5b030b6cb4cd | 33 | Joystick Joy (A1, A2, USER_BUTTON); // (VRX, VRY, SW/PC_13) |
rhisis | 5:c549c4b25997 | 34 | LCD lcd (D8, D9, D4, D5, D6, D7); // Para conectar como arduíno: (D8, D9, D4, D5, D6, D7); Para default: (D6, D7, D2, D3, D4, D5); |
kaiquedog | 0:bf743d54917c | 35 | |
kaiquedog | 0:bf743d54917c | 36 | /* |
kaiquedog | 0:bf743d54917c | 37 | ************************** |
kaiquedog | 0:bf743d54917c | 38 | ***** INICIA FUNÇÕES ***** |
kaiquedog | 0:bf743d54917c | 39 | ************************** |
kaiquedog | 0:bf743d54917c | 40 | */ |
kaiquedog | 0:bf743d54917c | 41 | |
kaiquedog | 9:891ffa97d8fb | 42 | void Loop_Menu(); // Loop da tela de menu |
kaiquedog | 3:fcdbe4af1b6d | 43 | |
kaiquedog | 0:bf743d54917c | 44 | |
kaiquedog | 0:bf743d54917c | 45 | /* |
kaiquedog | 0:bf743d54917c | 46 | ************************** |
kaiquedog | 0:bf743d54917c | 47 | **** INICIA VARIÁVEIS **** |
kaiquedog | 0:bf743d54917c | 48 | ************************** |
kaiquedog | 0:bf743d54917c | 49 | */ |
kaiquedog | 3:fcdbe4af1b6d | 50 | |
kaiquedog | 9:891ffa97d8fb | 51 | int menu = 1; // Variável que guarda o estado do menu |
kaiquedog | 3:fcdbe4af1b6d | 52 | |
kaiquedog | 0:bf743d54917c | 53 | /* |
kaiquedog | 0:bf743d54917c | 54 | ************************ |
kaiquedog | 0:bf743d54917c | 55 | **** LOOP PRINCIPAL **** |
kaiquedog | 0:bf743d54917c | 56 | ************************ |
kaiquedog | 0:bf743d54917c | 57 | */ |
kaiquedog | 0:bf743d54917c | 58 | |
kaiquedog | 0:bf743d54917c | 59 | int main(){ |
kaiquedog | 0:bf743d54917c | 60 | Loop_Menu(); |
kaiquedog | 0:bf743d54917c | 61 | } |
kaiquedog | 0:bf743d54917c | 62 | |
kaiquedog | 3:fcdbe4af1b6d | 63 | |
kaiquedog | 0:bf743d54917c | 64 | /* |
kaiquedog | 0:bf743d54917c | 65 | ************************ |
kaiquedog | 0:bf743d54917c | 66 | **** DEFINE FUNÇÕES **** |
kaiquedog | 0:bf743d54917c | 67 | ************************ |
kaiquedog | 0:bf743d54917c | 68 | */ |
kaiquedog | 0:bf743d54917c | 69 | |
kaiquedog | 0:bf743d54917c | 70 | void Loop_Menu(){ |
kaiquedog | 0:bf743d54917c | 71 | wait(0.2); |
kaiquedog | 0:bf743d54917c | 72 | lcd.clc(); |
kaiquedog | 9:891ffa97d8fb | 73 | lcd.printf("Primeiros Testes"); |
kaiquedog | 9:891ffa97d8fb | 74 | lcd.home(); |
kaiquedog | 0:bf743d54917c | 75 | lcd.pos(2,1); |
kaiquedog | 9:891ffa97d8fb | 76 | lcd.WRI(0x00); |
kaiquedog | 9:891ffa97d8fb | 77 | lcd.WRI(0x01); |
kaiquedog | 9:891ffa97d8fb | 78 | lcd.WRI(0x02); |
kaiquedog | 9:891ffa97d8fb | 79 | lcd.WRI(0x03); |
kaiquedog | 9:891ffa97d8fb | 80 | lcd.WRI(0x04); |
kaiquedog | 9:891ffa97d8fb | 81 | lcd.WRI(0x05); |
kaiquedog | 9:891ffa97d8fb | 82 | lcd.WRI(0x06); |
kaiquedog | 9:891ffa97d8fb | 83 | lcd.WRI(0x07); |
kaiquedog | 9:891ffa97d8fb | 84 | lcd.WRI(0x08); |
kaiquedog | 9:891ffa97d8fb | 85 | while(True) |
kaiquedog | 9:891ffa97d8fb | 86 | { |
kaiquedog | 0:bf743d54917c | 87 | switch (Joy.ler_x()) |
kaiquedog | 0:bf743d54917c | 88 | { |
kaiquedog | 9:891ffa97d8fb | 89 | case 0: lcd.cima(); break; |
kaiquedog | 9:891ffa97d8fb | 90 | case 1: lcd.baixo(); break; |
kaiquedog | 0:bf743d54917c | 91 | } |
kaiquedog | 0:bf743d54917c | 92 | switch (Joy.ler_y()) |
kaiquedog | 0:bf743d54917c | 93 | { |
kaiquedog | 9:891ffa97d8fb | 94 | case 0: lcd.direita(); break; |
kaiquedog | 9:891ffa97d8fb | 95 | case 1: lcd.esquerda(); break; |
kaiquedog | 0:bf743d54917c | 96 | } |
kaiquedog | 9:891ffa97d8fb | 97 | |
kaiquedog | 0:bf743d54917c | 98 | } |
kaiquedog | 0:bf743d54917c | 99 | |
kaiquedog | 0:bf743d54917c | 100 | } |
kaiquedog | 0:bf743d54917c | 101 |