Rev 1.6 - Sample Period Work in progress

Dependencies:   mbed Bitmap N5110 TMP102 Joystick

Revision:
14:fa5f83f26ed7
Parent:
13:70f02d5e56f5
Child:
15:73383333229d
Child:
16:648f9012c47a
diff -r 70f02d5e56f5 -r fa5f83f26ed7 main.cpp
--- a/main.cpp	Sun Jan 16 15:29:11 2022 +0000
+++ b/main.cpp	Sun Jan 16 17:29:18 2022 +0000
@@ -56,7 +56,7 @@
 void Y_isr();
 void info();
 void temp_SP();
-void Menu();
+void MenuNav();
 void Page1();
 void Page2();
 
@@ -91,7 +91,7 @@
         // read temperature and print over serial port
         
         
-        Menu();                                         // Call the info function                                              
+        MenuNav();                                         // Call the info function                                              
         Page1();
         Page2();
         temp_SP();
@@ -145,9 +145,7 @@
 }
 void info()
 {
-        if (g_R_flag){                               // Condition to change over into new loop
-            g_R_flag = 0;                                   // When the R Flag has been pressed
-            R.rise(&R_isr);
+
         serial.printf(" Information Page Selected ");  // Debugging Print
         lcd.clear();                                   // Clear Screen
         lcd.printString("Info Page",0,0);              // Print Information Screen
@@ -155,62 +153,46 @@
         lcd.printString("Louis M",0,2);
         lcd.printString("18689006",0,3);
         lcd.printString("Version 1.9.1",0,4);   
-    }
+        lcd.refresh();
+        wait(1);
 } 
 void Page1()
 {
-                if (g_Y_flag){                                  // Condition to change over into new loop
-                g_Y_flag = 0;       
-                Y.fall(&Y_isr);{
-               
         serial.printf(" Page 1 ");  // Debugging Print
         lcd.clear();                                   // Clear Screen
-        lcd.printString("    Page 1    ",0,0);              // Print Information Screen
+        lcd.printString("<   Page 1   >",0,0);              // Print Information Screen
         lcd.printString("Temperature",0,1);
         lcd.printString("Logging",0,2);
-        lcd.printString("Press L",0,3);
-        lcd.printString("Page Down A",0,5);   
+        lcd.printString("Press A",0,3);
+           
         lcd.refresh();
-                wait(1);
-    }
-}
+        wait(1);
 }
 void Page2()
-{
-     if (g_A_flag){                               // Condition to change over into new loop
-        g_A_flag = 0;                                   // When the R Flag has been pressed
-        A.rise(&A_isr);
-        
-        
+{        
         serial.printf(" Page 2 ");  // Debugging Print
         lcd.clear();                                   // Clear Screen
-        lcd.printString("    Page 2    ",0,1);              // Print Information Screen
-        lcd.printString("Blood Pressure",0,2);
-        lcd.printString("Logging",0,3);
-        lcd.printString("Press A",0,5);
-        lcd.printString("Page Up Y",0,0);   
+        lcd.printString("<   Page 2    ",0,0);              // Print Information Screen
+        lcd.printString("Blood Pressure",0,1);
+        lcd.printString("Logging",0,2);
+        lcd.printString("Press A",0,3);
+           
         lcd.refresh();
-                wait(1);}
-    
-}  
+        wait(1);
+}
 void temp_SP()
 {
         
         float T = tmp102.get_temperature();             // Reading Temperature as a floating variable
         float Set = SP * 100;                           // Reading Potentiometer as a floating variable. Multiplied by 100 to give larger range        
         
-        //serial.printf("%2.2fs: %3.1f deg C\n\r", timer.read(), T);
-        if (g_L_flag){                                  // Condition to change over into new loop
-            g_L_flag = 0;       
-            L.fall(&L_isr);
-        //if (T > Set){
         lcd.clear();                                    // clearing the LCD buffer at the begining of the loop        
         lcd.printString("Temperature",0,0);             // Can also pre-determine the co-ordinates of the ',0,0' (must be less than 84 pixels to fit on display)            
         char buffer[14];                                // each character is 6 pixels wide, screen is 84 pixels (84/6 = 14 Max amound of Characters)
         Direction d = Joystick.get_direction();
         float B = 0;
         if (1){
-        float BP = B + 1;
+        float BP = d + 1;
             serial.printf("BP = i%",BP);
             }                                                // Therefor strings csn not exceed the 14 Character Limit
                                                                   
@@ -232,88 +214,107 @@
         lcd.refresh();
                 wait(1);
         }
-        }
+        
 }    
-/*void Menu()
-{    
+void MenuNav()
+{ 
+        lcd.clear();
+    lcd.refresh();
+
+    int select = 0;
     while (1){
     
-    Direction d = Joystick.get_direction();
+    
     //serial.printf("Direction = %i ",d);
-    joystickDelay.attach(d,0.10);
-    int select = 0;
+    Direction d = Joystick.get_direction();
+        
     //while (1) {
         switch(select) {
             case 0:
                 switch(d) {
-                    case 1:
-                        select = 1;
-                        serial.printf("UP");
+                    case W:
+                        wait(0.5);
+                        select = 0;
+                        serial.printf("LEFT.0");
                         break;
-                    case 5:
-                        select = 2;
-                        serial.printf("DOWN");
+                    case E:
+                        wait(0.5);
+                        select = 1;
+                        serial.printf("RIGHT.0");
                         break;
                 }
-                //break;
+                break;
             case 1:
                 switch(d) {
-                    case 1:
-                        select = 2;
-                        serial.printf("UP");
+                    case W:
+                        wait(0.5);
+                        select = 0;
+                        serial.printf("LEFT.1");                
                         break;
-                    case 5:
-                        select = 0;
-                        serial.printf("DOWN");
+                    case E:
+                        wait(0.5);
+                        select = 2;
+                        serial.printf("RIGHT.1");
                         break;
+                }
+                break;
             case 2:
                 switch(d) {
-                    case 1:
-                        select = 0;
-                        serial.printf("UP");
+                    case W:
+                        wait(0.5);
+                        select = 1;
+                        serial.printf("LEFT.2");
                         break;
-                    case 5:
-                        select = 1;
-                        serial.printf("DOWN");
+                    case E:
+                        wait(0.5);
+                        select = 2;
+                        serial.printf("RIGHT.2");
                         break;
+            }
+            break;
         }
-        wait(1);
+        wait(0.1);
 
             if (select == 0){
                 lcd.clear();                                   // Clear Screen
-                serial.printf("Welcome");
-                lcd.printString("   Welcome   ",0,1);              // Print Information Screen
-                lcd.printString("Main Menu",0,3);
-                lcd.printString("Page Down",0,5);    
+                serial.printf("WelcomeMENU");
+                lcd.printString("   Navigate  >",0,0);
+                lcd.printString("   Welcome   ",0,2);              // Print Information Screen
+                lcd.printString("    Main    ",0,3);
+                lcd.printString("    Menu    ",0,4); 
+                lcd.printString("  Y for Info  ",0,5);   
+                lcd.refresh();
+                wait(1);    
+                }    
+            if (g_Y_flag){                               // Condition to change over into new loop
+                g_Y_flag = 0;                                   // When the R Flag has been pressed
+                Y.rise(&Y_isr);
+                serial.printf("Y Pressed");
+                info();
                 }
-                if (g_A_flag){                               // Condition to change over into new loop
-                g_A_flag = 0;                                   // When the R Flag has been pressed
-                A.rise(&A_isr);
-                serial.printf("A Pressed");
-                }
-            else if (select == 1){
-                serial.printf("Page1");
+            
+            if (select == 1){
                 Page1();
-                if (g_A_flag){                               // Condition to change over into new loop
+            if (g_A_flag){                               // Condition to change over into new loop
                 g_A_flag = 0;                                   // When the R Flag has been pressed
                 A.rise(&A_isr);
                 serial.printf("A Pressed");
+                temp_SP();
                 }
-                
-            else if (select == 2){
-                serial.printf("Page2");
+                }
+            
+            if (select == 2){
                 Page2();
-                if (g_A_flag){                               // Condition to change over into new loop
+            if (g_A_flag){                               // Condition to change over into new loop
                 g_A_flag = 0;                                   // When the R Flag has been pressed
                 A.rise(&A_isr);
-                serial.printf("A Pressed");
+                serial.printf("Y Pressed");
+                info();
+                } 
                 }
-        
 }
-}
-}
-}
-*/
+}      
+
 void Menu()
 {               
             if (g_R_flag){                               // Condition to change over into new loop
@@ -337,4 +338,4 @@
         BP + 1;
         serial.printf("BP = i%",BP);
             }
-  */  
\ No newline at end of file
+  */   
\ No newline at end of file