Coursework

Revision:
41:16cd48d6e834
Parent:
40:0d55297c8b34
Child:
42:960c132136d9
--- a/main.cpp	Thu Feb 03 22:03:36 2022 +0000
+++ b/main.cpp	Fri Feb 04 13:30:01 2022 +0000
@@ -6,6 +6,10 @@
 */
 /**
 * Section of code to bring in the #includes
+* TO DO : 
+* Debounce Issue 
+* Second Button Press B menu take from switch of A to own switch 
+
 */
 #include "mbed.h"
 //#include "Joystick.h" Not used in project
@@ -102,6 +106,9 @@
 void inputScan4();
 void inputScan5();
 void inputScan6();
+void wallDecision();
+void boxDecision();
+void cartonDecision();
 int NoContinueExit();
 int buttonCountA();
 int buttonCountB();
@@ -1137,10 +1144,11 @@
     g_buttonStart_flag = 1;   // set flag in ISR
        lcd.clear(); 
          /////////////////////////////////////////////////        
-    int arr1[5] ;
+   
     /*
     * For loop required to assign array values to that of the scan value
     */ /* not required due to repeatablity issues
+     int arr1[5] ;
     for(int i=0;  i<5; i++){
     arr1[i] =Scan1[i];}    
     int arr2[] = { 90, 90, 90, 90, 90 };
@@ -1182,6 +1190,9 @@
        lcd.printString("Button Right Pressed",0,0);
          lcd.refresh(); // set flag in ISR
          }
+             /**
+*..Void for 1st scan
+**/
 void inputScan1()
 {
       lcd.clear();        
@@ -1202,7 +1213,9 @@
         wait_ms(5); */
          lcd.printString("Scan 1 Done",0,0); lcd.refresh();
          }
-         
+     /**
+*..Void for 2nd scan
+**/        
 void inputScan2()
 {
          lcd.clear();
@@ -1222,6 +1235,9 @@
          lcd.printString("Scan 2 Done",0,0); lcd.refresh();
 
     }
+        /**
+*..Void for 3rd scan
+**/
 void inputScan3()
 {
          lcd.clear();
@@ -1241,6 +1257,9 @@
          Buzzer.play(200,120);  lcd.printString("X",30,5);lcd.refresh();         Scan3[4] = sensor.distance(); */
          lcd.printString("Scan 3 Done",0,0); lcd.refresh(); 
     }
+/**
+*..Void for 4th scan
+**/
 void inputScan4()
 {
          lcd.clear();
@@ -1261,6 +1280,9 @@
          Buzzer.play(200,120);  lcd.printString("X",45,5);lcd.refresh();         Scan4[4] = sensor.distance(); */
          lcd.printString("Scan 4 Done",0,0); lcd.refresh();
     }
+    /**
+*..Void for 5th scan
+**/
 void inputScan5()
 {
               lcd.clear();
@@ -1282,15 +1304,17 @@
          Buzzer.play(200,120);  lcd.printString("X",60,5);lcd.refresh();         Scan5[4] = sensor.distance(); */
          lcd.printString("Scan 5 Done",0,0); lcd.refresh();
     }
-    
+/**
+*..Second Menu after B object decision if the value is plus or minus 5 of the model value on the scan a value of 1 is atributated, a match is a 0 total.
+**/    
 void inputScan6()
 {
                   lcd.clear();
         lcd.printString("Decide",0,0);
         lcd.refresh();
            NoContinueExitScan6();
-         int box[5]= {90,10,10,90,90};// compared to the wall if the box is present this sequence should be recorded
- int carton[5] = {10,10,10,10,10}; // compared to the carton if the box is present this sequence should be recorded
+ int box[5]= {90,19,19,90,90};// compared to the wall if the box is present this sequence should be recorded
+ int carton[5] = {19,19,19,19,19}; // compared to the carton if the box is present this sequence should be recorded
  int wall [5] = {90,90,90,90,90}; // compared to the carton if the box is present this sequence should be recorded
  int isBox[5];
  int isCarton[5];
@@ -1330,20 +1354,47 @@
 printf("DEBUGGING Wall total %i\n", wallTotal);
 
 ;}
-printf("Im Free of the For Debug WallTotoal::  %i\n", wallTotal);
-printf("Im Free of the For Debug BoxTotoal::  %i\n", boxTotal);
-printf("Im Free of the For Debug cartonTotoal::  %i\n", cartonTotal);
+
 printShape();
      
         }
+/**
+*..Void for Deciding and printing shape
+**/
 void printShape(){
+    
     if(wallTotal == 0){
-     printf("We Have a wall\n");
+ wallDecision();}
+     else if(boxTotal == 0){
+ boxDecision();}
+         else if (cartonTotal == 0){
+cartonDecision();}
+    /*     else;           
+             
+         printf("Not in the Database \n");
+                  lcd.printString("Decide",0,0);
+         lcd.printString("Not in Database",0,2);
+          lcd.refresh(); */
+          
+printf("Im Free of the For Debug WallTotoal::  %i\n", wallTotal);
+printf("Im Free of the For Debug BoxTotoal::  %i\n", boxTotal);
+printf("Im Free of the For Debug cartonTotoal::  %i\n", cartonTotal);
+         }
+ void wallDecision(){
+                 printf("We Have a wall\n");
                    lcd.clear();
+        lcd.printString("Decide",0,0);
         lcd.printString("Wall",0,2);
-        lcd.drawLine(20,0,20,5,1);
-        lcd.refresh();;}
-     else if(boxTotal=0){
-         printf("We Have Box\n");}
-         else;
-         printf("Not in the Database \n");}
\ No newline at end of file
+        lcd.refresh();}
+void boxDecision(){
+                     printf("We Have Box\n");
+         lcd.printString("Decide",0,0);
+         lcd.printString("Box",0,2);
+          lcd.refresh();}
+          
+void cartonDecision(){
+             printf("We Have Carton\n");
+         lcd.printString("Decide",0,0);
+         lcd.printString("Carton",0,2);
+          lcd.refresh();}
+            
\ No newline at end of file