Dr. Davis and Dr. Dyer special studies robotics project

Dependencies:   BSP_DISCO_F469NI LCD_DISCO_F469NI TS_DISCO_F469NI mbed Motordriver

Fork of Configurable_Robots by Christopher Eubanks

Files at this revision

API Documentation at this revision

Comitter:
blu12758
Date:
Thu Feb 09 20:46:26 2017 +0000
Parent:
8:1173b502b316
Child:
10:4dd8b18e07d0
Child:
12:253d73d36745
Commit message:
UI update -- submenus

Changed in this revision

Classes/RobotMVC/RobotController.cpp Show annotated file Show diff for this revision Revisions of this file
Classes/RobotMVC/RobotController.h Show annotated file Show diff for this revision Revisions of this file
Classes/RobotMVC/RobotView.cpp Show annotated file Show diff for this revision Revisions of this file
Classes/RobotMVC/RobotView.h Show annotated file Show diff for this revision Revisions of this file
--- a/Classes/RobotMVC/RobotController.cpp	Wed Feb 08 20:31:20 2017 +0000
+++ b/Classes/RobotMVC/RobotController.cpp	Thu Feb 09 20:46:26 2017 +0000
@@ -18,9 +18,42 @@
 
 //Handles choices made by the user on the robot interface
 //input: selection value
-void RobotController::UserSelection(int s)
+void RobotController::userSelection(int s)
 {
-    //#TODO handle user selections
+    if(s < 0)
+        return;
+    switch(view->getPage())
+    {
+        default:
+            if(s == 0)
+                view->setPage(1);
+                return;
+        case 0:
+            return;
+        case 1:
+            switch(s)
+            {
+                case 0:
+                    view->setPage(2);
+                    return;
+                case 1:
+                    view->setPage(3);
+                    return;
+                case 2:
+                    view->setPage(4);
+                    return;
+                case 3:
+                    view->setPage(5);
+                    return;
+                case 4:
+                    view->setPage(6);
+                    return;
+                case 5:
+                    view->setPage(7);
+                    return;
+            }
+        
+    }
 }
 
 //Go to main menu
@@ -28,16 +61,10 @@
 {
     model->setMode(0);
     view->setPage(1);
-    view->update();
 }
 
 //Listens for inputs
 void RobotController::listen()
 {
-    if(view->listen())
-    {
-        view->clear();
-        wait(1);
-        view->update();
-    }
+    userSelection(view->listen());
 }
\ No newline at end of file
--- a/Classes/RobotMVC/RobotController.h	Wed Feb 08 20:31:20 2017 +0000
+++ b/Classes/RobotMVC/RobotController.h	Thu Feb 09 20:46:26 2017 +0000
@@ -24,7 +24,7 @@
     
     //Handles choices made by the user on the robot interface
     //input: selection value
-    void UserSelection(int s);
+    void userSelection(int s);
     
     //Go to main menu
     void main();
--- a/Classes/RobotMVC/RobotView.cpp	Wed Feb 08 20:31:20 2017 +0000
+++ b/Classes/RobotMVC/RobotView.cpp	Thu Feb 09 20:46:26 2017 +0000
@@ -43,6 +43,7 @@
     //Clear Screen
     clear();
     
+    //Write current page
     switch(_page)
     {
         case 0://Welcome Screen
@@ -62,6 +63,12 @@
             break;
     }
     
+    //display back button
+    if(_page > 1)
+    {
+        _lcd.DisplayStringAt(0, LINE(21), (uint8_t *)"<- Back", RIGHT_MODE);
+    }
+    
     //#TODO Display supply voltage
 }
 
@@ -74,14 +81,40 @@
 }
 
 //Check for touches on the screen
-bool RobotView::listen()
+int RobotView::listen()
 {
     _ts.GetState(&TS_State);
     if (TS_State.touchDetected)
     { 
       ts_x = TS_State.touchX[0];
       ts_y = TS_State.touchY[0];
-      return true;
+      return checkSelection();
     }
-    return false;
+    return -1;
+}
+
+//Check which selection the user made based on the current page
+int RobotView::checkSelection()
+{
+    if(_page > 1 && ts_y <=(20))
+        return 0;
+    switch(_page)
+    {
+        case 0:
+        default:
+            return -1;
+        case 1:
+            if(ts_y <= LINE(6))
+                return 0;
+            else if(ts_y <= LINE(9))
+                return 1;
+            else if(ts_y <= LINE(12))
+                return 2;
+            else if(ts_y <= LINE(15))
+                return 3;
+            else if(ts_y <= LINE(18))
+                return 4;
+            else
+                return 5;
+    }
 }
\ No newline at end of file
--- a/Classes/RobotMVC/RobotView.h	Wed Feb 08 20:31:20 2017 +0000
+++ b/Classes/RobotMVC/RobotView.h	Thu Feb 09 20:46:26 2017 +0000
@@ -26,7 +26,7 @@
     
     //Accessors/Mutators
     int getPage() const {return _page;}
-    void setPage(int p) {_page = p;}
+    void setPage(int p) {_page = p; update();}
     
     //Initialize the screen to display the robot menu
     void init();
@@ -35,5 +35,7 @@
     //Clear the screen
     void clear();
     //Check for touches on the screen
-    bool listen();
+    int listen();
+    //Check which selection the user made based on the current page
+    int checkSelection();
 };
\ No newline at end of file