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.
Diff: main.cpp
- Revision:
- 3:e4e890a46ff8
- Parent:
- 2:edc5d3177f86
diff -r edc5d3177f86 -r e4e890a46ff8 main.cpp
--- a/main.cpp Wed May 27 15:16:45 2020 +0000
+++ b/main.cpp Tue Jan 18 14:53:25 2022 +0000
@@ -1,61 +1,54 @@
#include "mbed.h"
-#include "LCD_ka.h"
-LCD lcd(D8, D9, D4, D5, D6, D7);
-AnalogIn Buts(A0);
-AnalogIn Ya(A1);
-AnalogIn Xa(A2);
+#include "TextLCD.h"
+#include "Joystick.h"
+#include "Telas.h"
+
+Joystick Joy (A2, A3, USER_BUTTON); // VRX, VRY, SW
+
+
+
-int main(){
- int y = Ya.read()*1000;
- int x = Xa.read()*1000;
- while(1){
- y = Ya.read()*1000;
- x = Xa.read()*1000;
-
- if ((Buts.read()*1000 > 750) && (Buts.read()*1000 < 850)){
- lcd.printf("select");
- wait(0.5);
- }
- if ((Buts.read()*1000 > 400) && (Buts.read()*1000 < 500)){
- lcd.printf("left");
- wait(0.5);
- }
- if ((Buts.read()*1000 > 200) && (Buts.read()*1000 < 300)){
- lcd.printf("down");
- wait(0.5);
- }
- if ((Buts.read()*1000 > 60) && (Buts.read()*1000 < 150)){
- lcd.printf("up");
- wait(0.5);
+int main() {
+ LCD_Init();
+ Tela_0();
+
+ int row = 0;
+ int col = 0;
+ while(1){
+ switch (Joy.ler_x()) // Rotina para movimentar eixo X
+ {
+ case 0:
+ if (row == 0){ row = 0; } else{ row--;}
+ lcd.locate(col,row);
+ wait(0.2);
+ break;
+ case 1:
+ if (row == 3){ row = 3; } else{ row++;}
+ lcd.locate(col,row);
+ wait(0.2);
+ break;
}
- if ((Buts.read()*1000 > 0) && (Buts.read()*1000 < 50)){
- lcd.printf("right");
- wait(0.5);
- }
-
- if((x < 400)||(x > 600)||(y < 400)||(y > 600)){
- y = Ya.read()*1000;
- x = Xa.read()*1000;
-
- if (x > 900){
- lcd.direita();
- wait(0.2);
+ if (Joy.bot_select() == 0){
+ switch (row){
+ case 0: Tela_1(); break;
+ case 1: Tela_2(); break;
+ case 2: Tela_3(); break;
+ case 3: Tela_4(); break;
}
-
- if (x < 100){
- lcd.esquerda();
- wait(0.2);
- }
- if (y > 900){
- lcd.baixo();
- wait(0.2);
- }
- if (y < 100){
- lcd.cima();
- wait(0.2);
- }
}
-
-
+
}
-}
+
+//// Create custom characters
+// const char udc_I1[] = {0x0A, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00};
+//
+//// Set custom char to address 0
+// lcd.setUDC(0, (char *) udc_I1);
+//
+//// Go to col=3 row=0
+// lcd.locate(3,0);
+//
+//// Print the custom char
+// lcd.putc(0);
+
+}
\ No newline at end of file