LCD
Revision 6:0320c521b9e0, committed 2021-05-20
- Comitter:
- diogonac
- Date:
- Thu May 20 12:18:23 2021 +0000
- Parent:
- 5:5e0059e59cb2
- Commit message:
- Logica da deteccao de fonte externa
Changed in this revision
| IHM.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/IHM.cpp Wed May 19 17:02:04 2021 +0000
+++ b/IHM.cpp Thu May 20 12:18:23 2021 +0000
@@ -4,6 +4,7 @@
TextLCD lcd(D8, D9, D4, D5, D6, D7); // rs, e, d4-d7
Serial pc (USBTX, USBRX);
AnalogIn eixo_Z(PC_2);
+AnalogIn botao_SELECT(A0);
InterruptIn posicao_salva(PA_15);
InterruptIn botao_emergencia(PC_4);
DigitalIn botao_indicador_fonte_externa(PC_10);
@@ -20,13 +21,14 @@
int pegaZ;
int posicao_salva_estado, botao_emergencia_estado;
int fonte_externa;
+int SELECT, valor_SELECT;
void rotina_posicao_salva(void);
void rotina_emergencia(void);
void rotida_velocidade_eixo_Z(void);
void rotida_deslocamento_eixo_Z (void);
void rotida_aciona_motor (void);
-
+void rotida_botoes_IHM (void);
int main()
@@ -36,9 +38,9 @@
motor_z = 0x00;
posicao_salva.rise(&rotina_posicao_salva);
botao_emergencia.rise(&rotina_emergencia);
- fonte_externa = botao_indicador_fonte_externa.read();
lcd.locate(0,0);
- lcd.printf("Posicao Z:");
+ lcd.printf("PosicaoZ:");
+
while(1) {
@@ -46,13 +48,16 @@
botao_emergencia_estado = botao_emergencia.read();
J_Z = eixo_Z.read_u16();
fonte_externa = botao_indicador_fonte_externa.read();
-
+ SELECT = botao_SELECT.read_u16();
+ rotida_botoes_IHM();
+
+ pc.printf("Select=%d\r\n", valor_SELECT);
//pc.printf("Z=%4d, PegaZ=%4d, Posicao_salva_estado=%d, Botao_emergencia_estado=%d, Tempo1=%4f, Tempo2=%4f, Pulsos=%d, Deslocamento_Z=%f, Velocidade_Z=%f\r\n", J_Z, pegaZ, posicao_salva_estado, botao_emergencia_estado, tempo_horario, tempo_anti_horario, pulsos_anti_horario, deslocamento_total_Z, velocidade_Z);
- if(fonte_externa == 1) {
+ if(fonte_externa == 0) {
lcd.locate(0,1);
lcd.printf("%4fmm",deslocamento_total_Z);
- pc.printf("Fonte=%d\r\n", fonte_externa);
+// pc.printf("Fonte=%d\r\n", fonte_externa);
rotida_aciona_motor();
}
@@ -84,6 +89,16 @@
deslocamento_total_Z = deslocamento_anti_horario_Z - deslocamento_horario_Z;
}
+void rotida_botoes_IHM()
+{
+
+ if(SELECT > 60000 & SELECT < 65000) valor_SELECT = 1;
+ else valor_SELECT = 0;
+
+
+}
+
+
void rotida_aciona_motor()
{