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
Fork of el17dg by
Diff: main.cpp
- Revision:
- 2:ec89189860e0
- Parent:
- 1:5aa2312d3e94
diff -r 5aa2312d3e94 -r ec89189860e0 main.cpp
--- a/main.cpp Tue Feb 26 14:24:01 2019 +0000
+++ b/main.cpp Tue Feb 26 16:45:45 2019 +0000
@@ -11,18 +11,23 @@
#include "mbed.h"
#include "N5110.h"
-//#include "Gamepad.h"
+#include "Gamepad.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
AnalogIn pot(PTB2);
-//AnalogIn x_dir(PTB10);
-//AnalogIn y_dir(PTB11);
-//AnalogIn j_button(PTC16);
+AnalogIn x_dir(PTB11);
+AnalogIn y_dir(PTB10);
+
void intro();
-void pointer();
+void pointer(int x, int y);
+void pointer_position(int menu_number);
+
+int menu_number = 0;
+int total_menu_number = 3;
+float time_delay = 100;
int main(){
lcd.init();
@@ -33,10 +38,28 @@
while(1){
lcd.clear();
- pointer();
+
+ pointer_position(menu_number);
+
+ if(y_dir.read() > 0.6){
+ menu_number -= 1;
+ wait_ms(time_delay);
+ }
+ if (y_dir.read() < 0.4){
+ menu_number += 1;
+ wait_ms(time_delay);
+ }
+ if (menu_number < 0) {
+ menu_number += total_menu_number;
+ }
+ if (menu_number >= total_menu_number) {
+ menu_number -= total_menu_number;
+ }
+
lcd.printString(" Start ",1,2);
lcd.printString(" Tutorial",1,3);
lcd.printString(" Settings",1,4);
+
lcd.refresh();
wait_ms(1000/10);
@@ -51,12 +74,12 @@
lcd.clear();
lcd.printString(" StarBarians",1,1);
lcd.refresh();
- wait(2);
+ wait(0.5);
lcd.printString(" And the quest ",1,2);
lcd.printString(" of the Princess Boobeta",1,3);
lcd.printString(" Boobeta",1,4);
lcd.refresh();
- wait(2);
+ wait(0.5);
}
void pointer(int x, int y){
@@ -73,3 +96,15 @@
lcd.drawSprite(x,y,7,12,cursor);
}
+void pointer_position(int menu_number){ //32 for 5th row- 25 for 4th row
+ if (menu_number == 0){
+ pointer(70, 17);
+ }
+ if (menu_number == 1){
+ pointer(70, 25);
+ }
+ if (menu_number == 2){
+ pointer(70, 32);
+ }
+}
+
