Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Committer:
thomasmorris
Date:
Wed Aug 15 21:34:59 2018 +0000
Revision:
57:aba1296e51b1
Parent:
56:bc5345bc6650
Final Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 56:bc5345bc6650 1 /*
thomasmorris 56:bc5345bc6650 2 This is the ALGORITHM class and it will be used tgo determine the move sequence the motors need to enact upon.
thomasmorris 56:bc5345bc6650 3 */
thomasmorris 56:bc5345bc6650 4
thomasmorris 56:bc5345bc6650 5 #ifndef ALGORITHM_HPP//Header Guards Prevents Multiple includes
thomasmorris 56:bc5345bc6650 6 #define ALGORITHM_HPP
thomasmorris 56:bc5345bc6650 7
thomasmorris 56:bc5345bc6650 8 //Libraries and header includes
thomasmorris 56:bc5345bc6650 9 #include "THREADS.hpp"
thomasmorris 56:bc5345bc6650 10 #include "mbed.h"
thomasmorris 56:bc5345bc6650 11 #include "rtos.h"
thomasmorris 56:bc5345bc6650 12 #include "SERIAL.hpp"
thomasmorris 56:bc5345bc6650 13 #include "COLOURS.hpp"
thomasmorris 56:bc5345bc6650 14
thomasmorris 56:bc5345bc6650 15 enum Colours//The posible colours of each point on the cube map
thomasmorris 56:bc5345bc6650 16 {
thomasmorris 56:bc5345bc6650 17 White,//Front
thomasmorris 56:bc5345bc6650 18 Red,//Upper
thomasmorris 56:bc5345bc6650 19 Orange,//Down
thomasmorris 56:bc5345bc6650 20 Blue,//Left
thomasmorris 56:bc5345bc6650 21 Green,//Right
thomasmorris 56:bc5345bc6650 22 Yellow//Back
thomasmorris 56:bc5345bc6650 23 };
thomasmorris 56:bc5345bc6650 24 static Colours CubeMap[6][3][3];//The colours of each section on the cube map
thomasmorris 56:bc5345bc6650 25
thomasmorris 56:bc5345bc6650 26 enum Moves//This is an enumeration of the different tpyes of moves which will be avalible
thomasmorris 56:bc5345bc6650 27 {
thomasmorris 56:bc5345bc6650 28 CL,AL,
thomasmorris 56:bc5345bc6650 29 CF,AF,
thomasmorris 56:bc5345bc6650 30 CR,AR,
thomasmorris 56:bc5345bc6650 31 CB,AB,
thomasmorris 56:bc5345bc6650 32 CU,AU,
thomasmorris 56:bc5345bc6650 33 CD,AD
thomasmorris 56:bc5345bc6650 34
thomasmorris 56:bc5345bc6650 35 };
thomasmorris 56:bc5345bc6650 36 class ALGORITHM //This creates a class called Led
thomasmorris 56:bc5345bc6650 37 {
thomasmorris 56:bc5345bc6650 38 public:
thomasmorris 56:bc5345bc6650 39
thomasmorris 56:bc5345bc6650 40 ALGORITHM(); //Constructor
thomasmorris 56:bc5345bc6650 41 ~ALGORITHM();//Destructor
thomasmorris 56:bc5345bc6650 42 void ALGORITHM_INIT();
thomasmorris 56:bc5345bc6650 43 void Find_edges();//Sets the internal variable to the location of all the pieces and the positions of them
thomasmorris 56:bc5345bc6650 44 void Find_Corners();//Finds the corners with the colour that is passed into them
thomasmorris 56:bc5345bc6650 45 private:
thomasmorris 56:bc5345bc6650 46 //Private member variables to prevent them being accessed externally
thomasmorris 56:bc5345bc6650 47 //Data Pins
thomasmorris 56:bc5345bc6650 48 int _State;
thomasmorris 56:bc5345bc6650 49 //Pointers to the lists elements
thomasmorris 56:bc5345bc6650 50 int _White_Pointer_Edge;
thomasmorris 56:bc5345bc6650 51 int _Orange_Pointer_Edge;
thomasmorris 56:bc5345bc6650 52 int _Blue_Pointer_Edge;
thomasmorris 56:bc5345bc6650 53 int _Red_Pointer_Edge;
thomasmorris 56:bc5345bc6650 54 int _Green_Pointer_Edge;
thomasmorris 56:bc5345bc6650 55 int _Yellow_Pointer_Edge;
thomasmorris 56:bc5345bc6650 56
thomasmorris 56:bc5345bc6650 57 int _White_Pointer_Corner;
thomasmorris 56:bc5345bc6650 58 int _Orange_Pointer_Corner;
thomasmorris 56:bc5345bc6650 59 int _Blue_Pointer_Corner;
thomasmorris 56:bc5345bc6650 60 int _Red_Pointer_Corner;
thomasmorris 56:bc5345bc6650 61 int _Green_Pointer_Corner;
thomasmorris 56:bc5345bc6650 62 int _Yellow_Pointer_Corner;
thomasmorris 56:bc5345bc6650 63 //Lists with the positions of the colours
thomasmorris 56:bc5345bc6650 64 int _White_List_Edge[4];
thomasmorris 56:bc5345bc6650 65 int _Orange_List_Edge[4];
thomasmorris 56:bc5345bc6650 66 int _Blue_List_Edge[4];
thomasmorris 56:bc5345bc6650 67 int _Red_List_Edge[4];
thomasmorris 56:bc5345bc6650 68 int _Green_List_Edge[4];
thomasmorris 56:bc5345bc6650 69 int _Yellow_List_Edge[4];
thomasmorris 56:bc5345bc6650 70
thomasmorris 56:bc5345bc6650 71 int _White_List_Corner[4];
thomasmorris 56:bc5345bc6650 72 int _Orange_List_Corner[4];
thomasmorris 56:bc5345bc6650 73 int _Blue_List_Corner[4];
thomasmorris 56:bc5345bc6650 74 int _Red_List_Corner[4];
thomasmorris 56:bc5345bc6650 75 int _Green_List_Corner[4];
thomasmorris 56:bc5345bc6650 76 int _Yellow_List_Corner[4];
thomasmorris 56:bc5345bc6650 77
thomasmorris 56:bc5345bc6650 78
thomasmorris 56:bc5345bc6650 79 //Private member functions
thomasmorris 56:bc5345bc6650 80 void _Find_edges_White();//Identify White edges
thomasmorris 56:bc5345bc6650 81 void _Find_Corners_White();//Identify White edges
thomasmorris 56:bc5345bc6650 82 void _Find_edges_Orange();//Identify White edges
thomasmorris 56:bc5345bc6650 83 void _Find_Corners_Orange();//Identify White edges
thomasmorris 56:bc5345bc6650 84 void _Find_edges_Blue();//Identify White edges
thomasmorris 56:bc5345bc6650 85 void _Find_Corners_Blue();//Identify White edges
thomasmorris 56:bc5345bc6650 86 void _Find_edges_Red();//Identify White edges
thomasmorris 56:bc5345bc6650 87 void _Find_Corners_Red();//Identify White edges
thomasmorris 56:bc5345bc6650 88 void _Find_edges_Green();//Identify White edges
thomasmorris 56:bc5345bc6650 89 void _Find_Corners_Green();//Identify White edges
thomasmorris 56:bc5345bc6650 90 void _Find_edges_Yellow();//Identify White edges
thomasmorris 56:bc5345bc6650 91 void _Find_Corners_Yellow();//Identify White edges
thomasmorris 56:bc5345bc6650 92 };
thomasmorris 56:bc5345bc6650 93 class SIDE //This creates a class called Led
thomasmorris 56:bc5345bc6650 94 {
thomasmorris 56:bc5345bc6650 95 public:
thomasmorris 56:bc5345bc6650 96
thomasmorris 56:bc5345bc6650 97 SIDE(); //Constructor
thomasmorris 56:bc5345bc6650 98 ~SIDE();//Destructor
thomasmorris 56:bc5345bc6650 99 int SIDE_type();
thomasmorris 56:bc5345bc6650 100
thomasmorris 56:bc5345bc6650 101 void Set_Colours(int CP1,int CP2,int CP3,int CP4,int CP5,int CP6,int CP7,int CP8,int CP9);
thomasmorris 56:bc5345bc6650 102 private:
thomasmorris 56:bc5345bc6650 103 //Private member variables to prevent them being accessed externally
thomasmorris 56:bc5345bc6650 104
thomasmorris 56:bc5345bc6650 105 //Positions of the cubelets
thomasmorris 56:bc5345bc6650 106 int _Cubelet_1_position;
thomasmorris 56:bc5345bc6650 107 int _Cubelet_2_position;
thomasmorris 56:bc5345bc6650 108 int _Cubelet_3_position;
thomasmorris 56:bc5345bc6650 109 int _Cubelet_4_position;
thomasmorris 56:bc5345bc6650 110 int _Cubelet_5_position;
thomasmorris 56:bc5345bc6650 111 int _Cubelet_6_position;
thomasmorris 56:bc5345bc6650 112 int _Cubelet_7_position;
thomasmorris 56:bc5345bc6650 113 int _Cubelet_8_position;
thomasmorris 56:bc5345bc6650 114 int _Cubelet_9_position;
thomasmorris 56:bc5345bc6650 115
thomasmorris 56:bc5345bc6650 116 int _Cubelet_1_colour;
thomasmorris 56:bc5345bc6650 117 int _Cubelet_2_colour;
thomasmorris 56:bc5345bc6650 118 int _Cubelet_3_colour;
thomasmorris 56:bc5345bc6650 119 int _Cubelet_4_colour;
thomasmorris 56:bc5345bc6650 120 int _Cubelet_5_colour;
thomasmorris 56:bc5345bc6650 121 int _Cubelet_6_colour;
thomasmorris 56:bc5345bc6650 122 int _Cubelet_7_colour;
thomasmorris 56:bc5345bc6650 123 int _Cubelet_8_colour;
thomasmorris 56:bc5345bc6650 124 int _Cubelet_9_colour;
thomasmorris 56:bc5345bc6650 125
thomasmorris 56:bc5345bc6650 126 };
thomasmorris 56:bc5345bc6650 127
thomasmorris 56:bc5345bc6650 128
thomasmorris 56:bc5345bc6650 129 #endif//ALGORITHM_HPP