![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Coursework
Diff: main.cpp
- Revision:
- 39:a31b49f3e65e
- Parent:
- 38:71cfbdd2076d
- Child:
- 40:0d55297c8b34
--- a/main.cpp Wed Feb 02 21:38:11 2022 +0000 +++ b/main.cpp Thu Feb 03 21:03:27 2022 +0000 @@ -416,31 +416,7 @@ printf("No Object %c/n",Decide[i]);} } */ - for (int i=0; i<5; i++){ - 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 isBox[5]; - int isCarton[5]; - isBox[i] =abs(Scan1[i]-box[i]); - printf("DeBUGGING isBOX : %i\n", isBox[i]); - if (isBox[i]<=5){ - isBox[i]=0;} -else if (isBox[i]>5){ -isBox[i]=1;} -printf("DeBUGGING isBOX : %i\n", isBox[i]); -int boxTotal = accumulate(begin(isBox), end(isBox), 0, plus<int>()); -printf("DEBUGGING BOX total %i\n", boxTotal); - - isCarton[i] =abs(Scan1[i]-carton[i]); - printf("DeBUGGING isCarton : %i\n", isCarton[i]); - if (isCarton[i]<=5){ - isCarton[i]=0;} -else if (isCarton[i]>5){ -isCarton[i]=1;} -printf("DeBUGGING isCarton : %i\n", isCarton[i]); -int cartonTotal = accumulate(begin(isCarton), end(isCarton), 0, plus<int>()); -printf("DEBUGGING CARTON total %i\n", cartonTotal);} /** IF Statement to decide on shape to draw @@ -922,7 +898,66 @@ wait_ms(50); //required to stop Black screen issue*/ inputScan5(); break; + + + ///////////////////////////////////////////////////////////////// + + + case 6: + g_ButtonAPress=6; + + 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 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]; + int isWall[5]; + int wallTotal; + int cartonTotal; + int boxTotal; + for (int i=0; i<5; i++){ + isBox[i] =abs(Scan1[i]-box[i]); + printf("DeBUGGING isBOX : %i\n", isBox[i]); + if (isBox[i]<=5){ + isBox[i]=0;} +else if (isBox[i]>5){ +isBox[i]=1;} +printf("DeBUGGING isBOX : %i\n", isBox[i]); +boxTotal = accumulate(begin(isBox), end(isBox), 0, plus<int>()); +printf("DEBUGGING BOX total %i\n", boxTotal); + + isCarton[i] =abs(Scan1[i]-carton[i]); + printf("DeBUGGING isCarton : %i\n", isCarton[i]); + if (isCarton[i]<=5){ + isCarton[i]=0;} +else if (isCarton[i]>5){ +isCarton[i]=1;} +printf("DeBUGGING isCarton : %i\n", isCarton[i]); +cartonTotal = accumulate(begin(isCarton), end(isCarton), 0, plus<int>()); +printf("DEBUGGING CARTON total %i\n", cartonTotal); + + isWall[i] =abs(Scan1[i]-wall[i]); + printf("DeBUGGING isWall : %i\n", isWall[i]); + if (isWall[i]<=5){ + isWall[i]=0;} +else if (isWall[i]>5){ +isWall[i]=1;} +printf("DeBUGGING isWall : %i\n", isWall[i]); +wallTotal = accumulate(begin(isWall), end(isWall), 0, plus<int>()); +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); +if(wallTotal == 0){ + printf("We Have a wall\n");} + else if(boxTotal=0){ + printf("We Have Box\n");} + else; + printf("Not in the Database \n"); + } /* @@ -1104,7 +1139,9 @@ buttonCountB(); g_buttonB_flag = 1; // set flag in ISR lcd.clear(); + g_ButtonAPress = 6; // This is is a work around due to time constraints lcd.printString("Button B Pressed",0,0); + lcd.refresh(); // set flag in ISR printf("press count = %i\n",g_ButtonBPress); } @@ -1133,13 +1170,13 @@ int arr1[5] ; /* * For loop required to assign array values to that of the scan value - */ + */ /* not required due to repeatablity issues for(int i=0; i<5; i++){ arr1[i] =Scan1[i];} int arr2[] = { 90, 90, 90, 90, 90 }; int n = sizeof(arr1) / sizeof(int); int m = sizeof(arr2) / sizeof(int); - + */ // if(MatchMade(arr1, arr2, n, m)) // printf("You are a wall");