Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Pipetagem_automatica
LCD.h@3:8e4c26964bd1, 2020-06-29 (annotated)
- Committer:
- alexandrezf
- Date:
- Mon Jun 29 17:24:03 2020 +0000
- Revision:
- 3:8e4c26964bd1
- Parent:
- 1:3dbb9b66b990
Comentarios finais LCD
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
terhorst | 1:3dbb9b66b990 | 1 | #include "mbed.h" |
terhorst | 1:3dbb9b66b990 | 2 | #include "TextLCD.h" |
terhorst | 1:3dbb9b66b990 | 3 | |
terhorst | 1:3dbb9b66b990 | 4 | //Portas da LCD: |
terhorst | 1:3dbb9b66b990 | 5 | TextLCD lcd(D10,D11,D4,D5,D8,D9); |
terhorst | 1:3dbb9b66b990 | 6 | |
terhorst | 1:3dbb9b66b990 | 7 | //Entrada A0 para botões LCD: |
terhorst | 1:3dbb9b66b990 | 8 | AnalogIn Botoes_LCD(A5); |
terhorst | 1:3dbb9b66b990 | 9 | AnalogIn SCL(PC_3); |
terhorst | 1:3dbb9b66b990 | 10 | AnalogIn SDA(PC_2); |
terhorst | 1:3dbb9b66b990 | 11 | |
terhorst | 1:3dbb9b66b990 | 12 | //Definição de variáveis: |
terhorst | 1:3dbb9b66b990 | 13 | int estado2 = 1; |
terhorst | 1:3dbb9b66b990 | 14 | int lcd_key = 0; |
terhorst | 1:3dbb9b66b990 | 15 | float adc_key_in = 0; |
terhorst | 1:3dbb9b66b990 | 16 | int quantidade = 0; |
terhorst | 1:3dbb9b66b990 | 17 | |
terhorst | 1:3dbb9b66b990 | 18 | //Definição Botões LCD: |
terhorst | 1:3dbb9b66b990 | 19 | #define btnDIREITA 0 |
terhorst | 1:3dbb9b66b990 | 20 | #define btnCIMA 1 |
terhorst | 1:3dbb9b66b990 | 21 | #define btnBAIXO 2 |
terhorst | 1:3dbb9b66b990 | 22 | #define btnESQUERDA 3 |
terhorst | 1:3dbb9b66b990 | 23 | #define btnSELECT 4 |
terhorst | 1:3dbb9b66b990 | 24 | #define btnRESET 5 |
terhorst | 1:3dbb9b66b990 | 25 | |
terhorst | 1:3dbb9b66b990 | 26 | //Definição Funções LCD: |
terhorst | 1:3dbb9b66b990 | 27 | void Botao_Emergencia(void); |
terhorst | 1:3dbb9b66b990 | 28 | void apeditarpipetagem(void); |
terhorst | 1:3dbb9b66b990 | 29 | void apiniciarpipetagem(void); |
terhorst | 1:3dbb9b66b990 | 30 | void apinformacoesdoprocesso(void); |
terhorst | 1:3dbb9b66b990 | 31 | void apdesligar(void); |
terhorst | 1:3dbb9b66b990 | 32 | void editarpipetagem(void); |
terhorst | 1:3dbb9b66b990 | 33 | void funcaoquantidade(void); |
terhorst | 1:3dbb9b66b990 | 34 | void funcaoposicao(void); |
terhorst | 1:3dbb9b66b990 | 35 | void iniciarpipetagem(void); |
terhorst | 1:3dbb9b66b990 | 36 | void informacoesdoprocesso(void); |
terhorst | 1:3dbb9b66b990 | 37 | void desligar(void); |
terhorst | 1:3dbb9b66b990 | 38 | void repetir(void); |
terhorst | 1:3dbb9b66b990 | 39 | void movimentacao(void); |
terhorst | 1:3dbb9b66b990 | 40 | |
terhorst | 1:3dbb9b66b990 | 41 | |
terhorst | 1:3dbb9b66b990 | 42 | //Função de leitura LCD: |
terhorst | 1:3dbb9b66b990 | 43 | int read_LCD_buttons(){ |
terhorst | 1:3dbb9b66b990 | 44 | //Recebe leitura e multiplica por 1000: |
terhorst | 1:3dbb9b66b990 | 45 | adc_key_in = Botoes_LCD.read()*1000; |
terhorst | 1:3dbb9b66b990 | 46 | //Enquanto nenhum Botão estiver ativado: |
terhorst | 1:3dbb9b66b990 | 47 | //(Funciona como um loop para garantir que não passe pela função sem que um botão haja sido pressionado) |
terhorst | 1:3dbb9b66b990 | 48 | while (adc_key_in>900){ |
terhorst | 1:3dbb9b66b990 | 49 | adc_key_in = Botoes_LCD.read()*1000; |
terhorst | 1:3dbb9b66b990 | 50 | } |
terhorst | 1:3dbb9b66b990 | 51 | //Condição de retorno para cada botão: |
terhorst | 1:3dbb9b66b990 | 52 | if (adc_key_in < 50) return btnDIREITA; |
terhorst | 1:3dbb9b66b990 | 53 | if (adc_key_in < 150) return btnCIMA; |
terhorst | 1:3dbb9b66b990 | 54 | if (adc_key_in < 300) return btnBAIXO; |
terhorst | 1:3dbb9b66b990 | 55 | if (adc_key_in < 450) return btnESQUERDA; |
terhorst | 1:3dbb9b66b990 | 56 | if (adc_key_in < 800) return btnSELECT; |
terhorst | 1:3dbb9b66b990 | 57 | |
terhorst | 1:3dbb9b66b990 | 58 | |
terhorst | 1:3dbb9b66b990 | 59 | |
terhorst | 1:3dbb9b66b990 | 60 | |
terhorst | 1:3dbb9b66b990 | 61 | } |
terhorst | 1:3dbb9b66b990 | 62 | |
terhorst | 1:3dbb9b66b990 | 63 | //Função de exibição do Menu principal: |
terhorst | 1:3dbb9b66b990 | 64 | void exibirMenu () { |
terhorst | 1:3dbb9b66b990 | 65 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 66 | lcd.printf("Selecione a"); |
terhorst | 1:3dbb9b66b990 | 67 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 68 | lcd.printf("operacao:"); |
terhorst | 1:3dbb9b66b990 | 69 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 70 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 71 | case btnBAIXO: apeditarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 72 | default: exibirMenu(); |
terhorst | 1:3dbb9b66b990 | 73 | } |
terhorst | 1:3dbb9b66b990 | 74 | } |
terhorst | 1:3dbb9b66b990 | 75 | |
terhorst | 1:3dbb9b66b990 | 76 | //Função de apresentação da parte "Editar Pipetagem": |
terhorst | 1:3dbb9b66b990 | 77 | void apeditarpipetagem() { |
terhorst | 1:3dbb9b66b990 | 78 | //Limpa a tela |
terhorst | 1:3dbb9b66b990 | 79 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 80 | //Inicia das coordenadas 0,0 |
terhorst | 1:3dbb9b66b990 | 81 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 82 | //Apresenta o texto ao usuário: |
terhorst | 1:3dbb9b66b990 | 83 | lcd.printf("Editar pipetagem"); |
terhorst | 1:3dbb9b66b990 | 84 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 85 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 86 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 87 | //Caso direita tenha sido pressionada: |
terhorst | 1:3dbb9b66b990 | 88 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 89 | //Limpa tela |
terhorst | 1:3dbb9b66b990 | 90 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 91 | //Inicia função "Editar Pipetagem" |
terhorst | 1:3dbb9b66b990 | 92 | editarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 93 | //Caso baixo tenha sido pressionada |
terhorst | 1:3dbb9b66b990 | 94 | //Segue para próxima apresentação |
terhorst | 1:3dbb9b66b990 | 95 | case btnBAIXO: apiniciarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 96 | //Caso nenhum dos anteriores tenha sido pressionado, reinicia a função, para que não interrompa o programa por erro de aperto de botão. |
terhorst | 1:3dbb9b66b990 | 97 | default: apeditarpipetagem(); |
terhorst | 1:3dbb9b66b990 | 98 | } |
terhorst | 1:3dbb9b66b990 | 99 | } |
alexandrezf | 3:8e4c26964bd1 | 100 | //Função da parte "Editar pipetagem": |
terhorst | 1:3dbb9b66b990 | 101 | void editarpipetagem(){ |
terhorst | 1:3dbb9b66b990 | 102 | |
terhorst | 1:3dbb9b66b990 | 103 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 104 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 105 | lcd.printf("Quantidade?"); |
terhorst | 1:3dbb9b66b990 | 106 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 107 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 108 | |
terhorst | 1:3dbb9b66b990 | 109 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 110 | case btnESQUERDA: apeditarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 111 | |
alexandrezf | 3:8e4c26964bd1 | 112 | //Caso acesse quantidade: |
terhorst | 1:3dbb9b66b990 | 113 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 114 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 115 | funcaoquantidade(); break; |
terhorst | 1:3dbb9b66b990 | 116 | |
terhorst | 1:3dbb9b66b990 | 117 | case btnBAIXO: |
terhorst | 1:3dbb9b66b990 | 118 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 119 | lcd.printf("Posicao?"); |
terhorst | 1:3dbb9b66b990 | 120 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 121 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 122 | switch(lcd_key){ |
alexandrezf | 3:8e4c26964bd1 | 123 | //Caso acesse posição: |
terhorst | 1:3dbb9b66b990 | 124 | case btnDIREITA: funcaoposicao(); break; |
terhorst | 1:3dbb9b66b990 | 125 | case btnESQUERDA: apeditarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 126 | case btnCIMA: editarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 127 | } |
terhorst | 1:3dbb9b66b990 | 128 | break; |
terhorst | 1:3dbb9b66b990 | 129 | } |
terhorst | 1:3dbb9b66b990 | 130 | } |
alexandrezf | 3:8e4c26964bd1 | 131 | //Função de definição de quantidade: |
terhorst | 1:3dbb9b66b990 | 132 | void funcaoquantidade(){ |
terhorst | 1:3dbb9b66b990 | 133 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 134 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 135 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 136 | |
terhorst | 1:3dbb9b66b990 | 137 | case btnESQUERDA: apeditarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 138 | |
terhorst | 1:3dbb9b66b990 | 139 | case btnBAIXO: |
terhorst | 1:3dbb9b66b990 | 140 | quantidade = quantidade - 1; |
terhorst | 1:3dbb9b66b990 | 141 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 142 | lcd.printf("Por enquanto:"); |
terhorst | 1:3dbb9b66b990 | 143 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 144 | lcd.printf("%d",quantidade); |
terhorst | 1:3dbb9b66b990 | 145 | funcaoquantidade(); |
terhorst | 1:3dbb9b66b990 | 146 | break; |
terhorst | 1:3dbb9b66b990 | 147 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 148 | quantidade = quantidade + 10; |
terhorst | 1:3dbb9b66b990 | 149 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 150 | lcd.printf("Por enquanto:"); |
terhorst | 1:3dbb9b66b990 | 151 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 152 | lcd.printf("%d",quantidade); |
terhorst | 1:3dbb9b66b990 | 153 | funcaoquantidade(); |
terhorst | 1:3dbb9b66b990 | 154 | break; |
terhorst | 1:3dbb9b66b990 | 155 | case btnCIMA: |
terhorst | 1:3dbb9b66b990 | 156 | quantidade = quantidade + 1; |
terhorst | 1:3dbb9b66b990 | 157 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 158 | lcd.printf("Por enquanto:"); |
terhorst | 1:3dbb9b66b990 | 159 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 160 | lcd.printf("%d",quantidade); |
terhorst | 1:3dbb9b66b990 | 161 | funcaoquantidade(); |
terhorst | 1:3dbb9b66b990 | 162 | break; |
terhorst | 1:3dbb9b66b990 | 163 | case btnSELECT: |
terhorst | 1:3dbb9b66b990 | 164 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 165 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 166 | lcd.printf("Quantidade final:"); |
terhorst | 1:3dbb9b66b990 | 167 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 168 | lcd.printf("%d", quantidade); |
terhorst | 1:3dbb9b66b990 | 169 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 170 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 171 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 172 | case btnSELECT: |
alexandrezf | 3:8e4c26964bd1 | 173 | //Condição de retorno para confirmar valor: |
terhorst | 1:3dbb9b66b990 | 174 | exibirMenu(); |
terhorst | 1:3dbb9b66b990 | 175 | break; |
terhorst | 1:3dbb9b66b990 | 176 | } |
terhorst | 1:3dbb9b66b990 | 177 | break; |
terhorst | 1:3dbb9b66b990 | 178 | } |
terhorst | 1:3dbb9b66b990 | 179 | } |
alexandrezf | 3:8e4c26964bd1 | 180 | //função de definição de posição: |
terhorst | 1:3dbb9b66b990 | 181 | void funcaoposicao(){ |
terhorst | 1:3dbb9b66b990 | 182 | while(estado2 == 1) { |
terhorst | 1:3dbb9b66b990 | 183 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 184 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 185 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 186 | case btnSELECT: |
terhorst | 1:3dbb9b66b990 | 187 | estado2 = 0; |
terhorst | 1:3dbb9b66b990 | 188 | break; |
terhorst | 1:3dbb9b66b990 | 189 | } |
alexandrezf | 3:8e4c26964bd1 | 190 | //O acesso à função joystick externa desta biblioteca permite a movimentação dos motores para salvar a posição do usuário, |
alexandrezf | 3:8e4c26964bd1 | 191 | //a qual será retornada como "PosicaoUsuário" e conterá 3 valores, x, y e z respectivamente. (joystick.h) |
terhorst | 1:3dbb9b66b990 | 192 | joystick(); |
terhorst | 1:3dbb9b66b990 | 193 | } |
terhorst | 1:3dbb9b66b990 | 194 | exibirMenu(); |
terhorst | 1:3dbb9b66b990 | 195 | } |
alexandrezf | 3:8e4c26964bd1 | 196 | //Função de apresentação da parte "Iniciar Pipetagem": |
terhorst | 1:3dbb9b66b990 | 197 | void apiniciarpipetagem(){ |
terhorst | 1:3dbb9b66b990 | 198 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 199 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 200 | lcd.printf("Iniciar"); |
terhorst | 1:3dbb9b66b990 | 201 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 202 | lcd.printf("pipetagem"); |
terhorst | 1:3dbb9b66b990 | 203 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 204 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 205 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 206 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 207 | iniciarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 208 | |
terhorst | 1:3dbb9b66b990 | 209 | case btnBAIXO: |
terhorst | 1:3dbb9b66b990 | 210 | apinformacoesdoprocesso(); break; |
terhorst | 1:3dbb9b66b990 | 211 | |
terhorst | 1:3dbb9b66b990 | 212 | case btnCIMA: |
terhorst | 1:3dbb9b66b990 | 213 | apeditarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 214 | |
terhorst | 1:3dbb9b66b990 | 215 | default: apiniciarpipetagem(); |
terhorst | 1:3dbb9b66b990 | 216 | |
terhorst | 1:3dbb9b66b990 | 217 | } |
terhorst | 1:3dbb9b66b990 | 218 | } |
alexandrezf | 3:8e4c26964bd1 | 219 | //Função da parte "Iniciar Pipetagem": |
terhorst | 1:3dbb9b66b990 | 220 | void iniciarpipetagem(){ |
terhorst | 1:3dbb9b66b990 | 221 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 222 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 223 | lcd.printf("Iniciando"); |
terhorst | 1:3dbb9b66b990 | 224 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 225 | lcd.printf("Pipetagem..."); |
terhorst | 1:3dbb9b66b990 | 226 | wait(1); |
terhorst | 1:3dbb9b66b990 | 227 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 228 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 229 | case btnESQUERDA: apiniciarpipetagem(); break; |
alexandrezf | 3:8e4c26964bd1 | 230 | //Execução da função repetir que efetivamente realizará a pipetagem: (LCD.h) |
terhorst | 1:3dbb9b66b990 | 231 | case btnDIREITA: repetir(); break; |
terhorst | 1:3dbb9b66b990 | 232 | } |
terhorst | 1:3dbb9b66b990 | 233 | } |
alexandrezf | 3:8e4c26964bd1 | 234 | //Função de apresentação da parte "Informacoes do processo": |
terhorst | 1:3dbb9b66b990 | 235 | void apinformacoesdoprocesso(){ |
terhorst | 1:3dbb9b66b990 | 236 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 237 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 238 | lcd.printf("Informacoes do"); |
terhorst | 1:3dbb9b66b990 | 239 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 240 | lcd.printf("processo"); |
terhorst | 1:3dbb9b66b990 | 241 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 242 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 243 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 244 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 245 | informacoesdoprocesso(); break; |
terhorst | 1:3dbb9b66b990 | 246 | |
terhorst | 1:3dbb9b66b990 | 247 | case btnBAIXO: |
terhorst | 1:3dbb9b66b990 | 248 | apdesligar(); break; |
terhorst | 1:3dbb9b66b990 | 249 | |
terhorst | 1:3dbb9b66b990 | 250 | case btnCIMA: |
terhorst | 1:3dbb9b66b990 | 251 | apiniciarpipetagem(); break; |
terhorst | 1:3dbb9b66b990 | 252 | |
terhorst | 1:3dbb9b66b990 | 253 | default: apinformacoesdoprocesso(); |
terhorst | 1:3dbb9b66b990 | 254 | |
terhorst | 1:3dbb9b66b990 | 255 | } |
terhorst | 1:3dbb9b66b990 | 256 | } |
alexandrezf | 3:8e4c26964bd1 | 257 | //Função da parte "Informacoes do processo": |
terhorst | 1:3dbb9b66b990 | 258 | void informacoesdoprocesso(){ |
terhorst | 1:3dbb9b66b990 | 259 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 260 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 261 | lcd.printf("Quantidade?"); |
terhorst | 1:3dbb9b66b990 | 262 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 263 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 264 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 265 | case btnESQUERDA: apinformacoesdoprocesso(); break; |
alexandrezf | 3:8e4c26964bd1 | 266 | //Caso queira informação sobre a quantidade: |
terhorst | 1:3dbb9b66b990 | 267 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 268 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 269 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 270 | lcd.printf("Quantidade Final"); |
terhorst | 1:3dbb9b66b990 | 271 | lcd.setAddress(0,1); |
terhorst | 1:3dbb9b66b990 | 272 | lcd.printf("%d",quantidade); |
terhorst | 1:3dbb9b66b990 | 273 | lcd.printf(" ml"); |
terhorst | 1:3dbb9b66b990 | 274 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 275 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 276 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 277 | case btnESQUERDA: |
terhorst | 1:3dbb9b66b990 | 278 | informacoesdoprocesso(); |
terhorst | 1:3dbb9b66b990 | 279 | break; |
terhorst | 1:3dbb9b66b990 | 280 | } |
terhorst | 1:3dbb9b66b990 | 281 | case btnBAIXO: |
terhorst | 1:3dbb9b66b990 | 282 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 283 | lcd.printf("Posicao?"); |
terhorst | 1:3dbb9b66b990 | 284 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 285 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 286 | switch(lcd_key){ |
alexandrezf | 3:8e4c26964bd1 | 287 | //Caso queira informação sobre a posição: |
terhorst | 1:3dbb9b66b990 | 288 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 289 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 290 | lcd.printf("x:"); |
terhorst | 1:3dbb9b66b990 | 291 | lcd.printf("%d", PosicaoUsuario[0]); |
terhorst | 1:3dbb9b66b990 | 292 | lcd.printf(", y:"); |
terhorst | 1:3dbb9b66b990 | 293 | lcd.printf("%d", PosicaoUsuario[1]); |
terhorst | 1:3dbb9b66b990 | 294 | lcd.printf(", z:"); |
terhorst | 1:3dbb9b66b990 | 295 | lcd.printf("%d", PosicaoUsuario[2]); |
terhorst | 1:3dbb9b66b990 | 296 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 297 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 298 | switch(lcd_key){ |
terhorst | 1:3dbb9b66b990 | 299 | case btnESQUERDA: |
terhorst | 1:3dbb9b66b990 | 300 | apinformacoesdoprocesso(); |
terhorst | 1:3dbb9b66b990 | 301 | break; |
terhorst | 1:3dbb9b66b990 | 302 | } |
terhorst | 1:3dbb9b66b990 | 303 | break; |
terhorst | 1:3dbb9b66b990 | 304 | case btnESQUERDA: apinformacoesdoprocesso(); break; |
terhorst | 1:3dbb9b66b990 | 305 | case btnCIMA: |
terhorst | 1:3dbb9b66b990 | 306 | informacoesdoprocesso(); |
terhorst | 1:3dbb9b66b990 | 307 | break; |
terhorst | 1:3dbb9b66b990 | 308 | default: informacoesdoprocesso(); |
terhorst | 1:3dbb9b66b990 | 309 | } |
terhorst | 1:3dbb9b66b990 | 310 | } |
terhorst | 1:3dbb9b66b990 | 311 | } |
alexandrezf | 3:8e4c26964bd1 | 312 | //Função de apresentação da parte "Desligar": |
terhorst | 1:3dbb9b66b990 | 313 | void apdesligar(){ |
terhorst | 1:3dbb9b66b990 | 314 | lcd.cls(); |
terhorst | 1:3dbb9b66b990 | 315 | lcd.setAddress(0,0); |
terhorst | 1:3dbb9b66b990 | 316 | lcd.printf("Desligar"); |
terhorst | 1:3dbb9b66b990 | 317 | wait(0.5); |
terhorst | 1:3dbb9b66b990 | 318 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 319 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 320 | case btnDIREITA: |
terhorst | 1:3dbb9b66b990 | 321 | desligar(); break; |
terhorst | 1:3dbb9b66b990 | 322 | |
terhorst | 1:3dbb9b66b990 | 323 | case btnCIMA: |
terhorst | 1:3dbb9b66b990 | 324 | apinformacoesdoprocesso(); break; |
terhorst | 1:3dbb9b66b990 | 325 | |
terhorst | 1:3dbb9b66b990 | 326 | default: apdesligar(); |
terhorst | 1:3dbb9b66b990 | 327 | |
terhorst | 1:3dbb9b66b990 | 328 | } |
terhorst | 1:3dbb9b66b990 | 329 | } |
alexandrezf | 3:8e4c26964bd1 | 330 | //Função da parte "Desligar": |
terhorst | 1:3dbb9b66b990 | 331 | void desligar(){ |
terhorst | 1:3dbb9b66b990 | 332 | lcd.cls(); |
alexandrezf | 3:8e4c26964bd1 | 333 | //Desligamento do sistema: |
terhorst | 1:3dbb9b66b990 | 334 | Emergencia = 1; |
terhorst | 1:3dbb9b66b990 | 335 | wait(1); |
terhorst | 1:3dbb9b66b990 | 336 | lcd_key = read_LCD_buttons(); |
terhorst | 1:3dbb9b66b990 | 337 | switch (lcd_key){ |
terhorst | 1:3dbb9b66b990 | 338 | case btnESQUERDA: apdesligar(); break; |
terhorst | 1:3dbb9b66b990 | 339 | } |
terhorst | 1:3dbb9b66b990 | 340 | } |
alexandrezf | 3:8e4c26964bd1 | 341 | //Função de Inicialização do sistema, a qual exibirá o Menu. (Executada no programa principal) |
terhorst | 1:3dbb9b66b990 | 342 | void Inicializacao(){ |
terhorst | 1:3dbb9b66b990 | 343 | |
terhorst | 1:3dbb9b66b990 | 344 | exibirMenu(); |
terhorst | 1:3dbb9b66b990 | 345 | |
terhorst | 1:3dbb9b66b990 | 346 | } |
alexandrezf | 3:8e4c26964bd1 | 347 | //Função para controlar baseado no input do usuário quantas vezes a atividade irá se repetir |
alexandrezf | 3:8e4c26964bd1 | 348 | void repetir(){ |
terhorst | 1:3dbb9b66b990 | 349 | int i; |
terhorst | 1:3dbb9b66b990 | 350 | for (i=0 ; i<quantidade ; i++) { |
alexandrezf | 3:8e4c26964bd1 | 351 | //Execução da própria movimentação: (movimentacao.h) |
terhorst | 1:3dbb9b66b990 | 352 | movimentacao(); |
terhorst | 1:3dbb9b66b990 | 353 | printf("Completado\n\r"); |
terhorst | 1:3dbb9b66b990 | 354 | } |
terhorst | 1:3dbb9b66b990 | 355 | } |
terhorst | 1:3dbb9b66b990 | 356 | |
terhorst | 1:3dbb9b66b990 | 357 | |
terhorst | 1:3dbb9b66b990 | 358 | |
terhorst | 1:3dbb9b66b990 | 359 | |
terhorst | 1:3dbb9b66b990 | 360 |