Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
Revision 57:aba1296e51b1, committed 2018-08-15
- Comitter:
- thomasmorris
- Date:
- Wed Aug 15 21:34:59 2018 +0000
- Parent:
- 56:bc5345bc6650
- Commit message:
- Final Version
Changed in this revision
diff -r bc5345bc6650 -r aba1296e51b1 COLOURS.cpp --- a/COLOURS.cpp Mon Jul 16 10:51:47 2018 +0000 +++ b/COLOURS.cpp Wed Aug 15 21:34:59 2018 +0000 @@ -43,6 +43,19 @@ } return colours_return_value; } + +char Value_convert (Colours value) +{ + char Return_value; + if(value == White){Return_value = 'W';} + else if(value == Orange){Return_value = 'O';} + else if(value == Blue){Return_value = 'B';} + else if(value == Red){Return_value = 'R';} + else if(value == Green){Return_value = 'G';} + else if(value == Yellow){Return_value = 'Y';} + + return Return_value; +} void Store_Cubelet_data() { if((8 >= colour_data) && (colour_data <= 15))
diff -r bc5345bc6650 -r aba1296e51b1 COLOURS.hpp --- a/COLOURS.hpp Mon Jul 16 10:51:47 2018 +0000 +++ b/COLOURS.hpp Wed Aug 15 21:34:59 2018 +0000 @@ -12,6 +12,7 @@ enum Colours; static int colour_data = 0; Colours convert (int Colour); +char Value_convert (Colours value); void Store_Cubelet_data(); #endif \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 MOVES.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MOVES.cpp Wed Aug 15 21:34:59 2018 +0000 @@ -0,0 +1,84 @@ +//This is where the algorithms movements will be defined +#include "MOVES.hpp" + +int side = 0; //Sides +void List_Execution() +{ + pc.printf("Move point value is : %d\n",Move_list_pointer); + for(int i = 0; i<= Move_list_pointer; i += 1) + { + if(Move_list[i] == 0){pc.printf("Move List Finished\n");} + else if (Move_list[i] == 1){STEPPER_MOTOR_1.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 2){STEPPER_MOTOR_1.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 3){STEPPER_MOTOR_2.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 4){STEPPER_MOTOR_2.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 5){STEPPER_MOTOR_3.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 6){STEPPER_MOTOR_3.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 7){STEPPER_MOTOR_4.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 8){STEPPER_MOTOR_4.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 9){STEPPER_MOTOR_5.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 10){STEPPER_MOTOR_5.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 11){STEPPER_MOTOR_6.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 12){STEPPER_MOTOR_6.Rotate_Steps(50 ,0);} + else pc.printf("Finished\n"); + } + pc.printf("List Run sucessful\n"); +} +void White_Cross() +{ + +} + + +void White_Cross_Position() +{ + if(CubeMap[1][0][1] == White )//Top middle + { + //rotate 180 + } + if(CubeMap[1][1][0] == White )//Middle Left + { + //rotate 90 + } + if(CubeMap[1][1][2] == White )//Middle Right + { + //rotate 0 + } + if(CubeMap[1][2][1] == White )//Bottom Middle + { + //rotate 270 + } +} +void White_Cross_Orientate() +{ + +} +void White_Centre_Swap() +{ + +} + +void White_Corners() +{ + +} +void Middle_Layer() +{ + +} +void Top_Cross() +{ + +} +void Top_Layer() +{ + +} +void Corner_Positioning() +{ + +} +void Edge_Orientation() +{ + +} \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 MOVES.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MOVES.hpp Wed Aug 15 21:34:59 2018 +0000 @@ -0,0 +1,36 @@ +//This is where the algorithms movements will be defined +#ifndef MOVES_HPP//Header Guards Prevents Multiple includes +#define MOVES_HPP +#include "ALGORITHM.hpp" +#include "STEPPER_MOTOR.hpp" +static STEPPER_MOTOR STEPPER_MOTOR_1(D0,D1);//step then direction +static STEPPER_MOTOR STEPPER_MOTOR_2(D2,D3);//step then direction +static STEPPER_MOTOR STEPPER_MOTOR_3(D4,D5);//step then direction +static STEPPER_MOTOR STEPPER_MOTOR_4(D6,D7);//step then direction +static STEPPER_MOTOR STEPPER_MOTOR_5(D8,D9);//step then direction +static STEPPER_MOTOR STEPPER_MOTOR_6(D10,D11);//step then direction + + +static int Move_list[200]; //Creates a move list of 200 which is defaulted to 0 + +static int Move_list_pointer; + +void White_Cross(); + +//White Cross funcitons +void White_Cross_Position(); +void White_Cross_Orientate(); +void White_Centre_Swap(); + + +void White_Corners(); +// White Corner functions +void Middle_Layer(); +void Top_Cross(); +void Top_Layer(); +void Corner_Positioning(); +void Edge_Orientation(); + +void List_Execution(); + +#endif \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 Moves.cpp --- a/Moves.cpp Mon Jul 16 10:51:47 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -//This is where the algorithms movements will be defined -#include "Moves.hpp" - -int side = 0; //Sides -void White_Cross() -{ - -} - - -void White_Cross_Position() -{ - if(CubeMap[1][0][1] == White )//Top middle - { - //rotate 180 - } - if(CubeMap[1][1][0] == White )//Middle Left - { - //rotate 90 - } - if(CubeMap[1][1][2] == White )//Middle Right - { - //rotate 0 - } - if(CubeMap[1][2][1] == White )//Bottom Middle - { - //rotate 270 - } -} -void White_Cross_Orientate() -{ - -} -void White_Centre_Swap() -{ - -} - -void White_Corners() -{ - -} -void Middle_Layer() -{ - -} -void Top_Cross() -{ - -} -void Top_Layer() -{ - -} -void Corner_Positioning() -{ - -} -void Edge_Orientation() -{ - -} \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 Moves.hpp --- a/Moves.hpp Mon Jul 16 10:51:47 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -//This is where the algorithms movements will be defined -#include "ALGORITHM.hpp" -void White_Cross(); - -//White Cross funcitons -void White_Cross_Position(); -void White_Cross_Orientate(); -void White_Centre_Swap(); - - - -void White_Corners(); -// White Corner functions -void Middle_Layer(); -void Top_Cross(); -void Top_Layer(); -void Corner_Positioning(); -void Edge_Orientation(); \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 SERIAL_COMMANDS.cpp --- a/SERIAL_COMMANDS.cpp Mon Jul 16 10:51:47 2018 +0000 +++ b/SERIAL_COMMANDS.cpp Wed Aug 15 21:34:59 2018 +0000 @@ -5,6 +5,10 @@ int direction = 1; int Motor_To_Select = 1; float angle = 0; +bool move_loop = 0; +bool List_move_loop = 0; + + //Mutex Locks void Serial_Commands_Output() //Used for getting input from the user to determine the opperations to perform @@ -14,18 +18,11 @@ for (int x = 0; x < 100; x++){input[x] = ' ';}; //Fill input with spaces pc.printf("Please type in a command\n"); //Request command in the terminal - cin.getline(input,sizeof(input),'\r'); //Scan into input from the start of the line to the return character - //cout << "Input is : " << input << endl; - - //READ ALL - if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D' & input[4] == ' ' & input[5] == 'A' & input[6] == 'L' & input[7] == 'L') - { - if(Log_Value == 4){pc.printf("READ ALL Confirmed\n");} //If logging is enabled, print debug statement - - } + cin.getline(input,sizeof(input),'\r'); //Scan into input from the start of the line to the return character + //LOGGING - else if(input[0] == 'L' & input[1] == 'O' & input[2] == 'G' & input[3] == 'G' & input[4] == 'I' & input[5] == 'N' & input[6] == 'G' & input[7] == ' ') + if(input[0] == 'L' & input[1] == 'O' & input[2] == 'G' & input[3] == 'G' & input[4] == 'I' & input[5] == 'N' & input[6] == 'G' & input[7] == ' ') { int NumberOfChars = 0; int ArrayAddress = 0; string LoggingNumber; int NumberToLogging; //Declare required variables while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} //Count the number of characters entered into the console @@ -33,12 +30,7 @@ stringstream Number(LoggingNumber); //Convert string to stringstream Number >> NumberToLogging; //Convert stringstream to integer if (NumberToLogging == 0){pc.printf("NOT LOGGING\n");} //Not Logging - else if (NumberToLogging == 1){pc.printf("LOGGING Serial\n");} //Logging LCD - else if (NumberToLogging == 2){pc.printf("LOGGING NETWORKING\n");} //Logging Networking - else if (NumberToLogging == 3){pc.printf("LOGGING SAMPLING\n");} //Logging Sampling - else if (NumberToLogging == 4){pc.printf("LOGGING SERIAL COMMANDS\n");} //Logging serial commands - else if (NumberToLogging == 5){pc.printf("LOGGING SD CARD\n");} //Logging SD card - else if (NumberToLogging >= 6){pc.printf("INVALID LOGGING COMMAND\n");} //Invalud Logging Command + else if (NumberToLogging == 1){pc.printf("LOGGING SPI\n");} //Logging SPI if (NumberToLogging <= 5){Log_Value = NumberToLogging;} //If inputted value is within bounds equate it to the log state } @@ -81,21 +73,236 @@ //MOVE else if(input[0] == 'M' & input[1] == 'O' & input[2] == 'V' & input[3] == 'E') { - pc.printf("Enter the Move\n"); //Request command in the terminal - cin.getline(input,sizeof(input),'\r');; - if(input[0] == 'C' & input[1] == 'L') + move_loop = 1; + pc.printf("Enter the Move\n"); //Request command in the terminal + while(move_loop == 1) + { + cin.getline(input,sizeof(input),'\r'); + + if(input[0] == 'A' & input[1] == 'F'){STEPPER_MOTOR_1.Rotate_Steps(50 ,1);} + else if(input[0] == 'C' & input[1] == 'F'){STEPPER_MOTOR_1.Rotate_Steps(50 ,0);} + else if(input[0] == 'A' & input[1] == 'B'){STEPPER_MOTOR_2.Rotate_Steps(50 ,1);} + else if(input[0] == 'C' & input[1] == 'B'){STEPPER_MOTOR_2.Rotate_Steps(50 ,0);} + else if(input[0] == 'A' & input[1] == 'L'){STEPPER_MOTOR_3.Rotate_Steps(50 ,1);} + else if(input[0] == 'C' & input[1] == 'L'){STEPPER_MOTOR_3.Rotate_Steps(50 ,0);} + else if(input[0] == 'A' & input[1] == 'R'){STEPPER_MOTOR_4.Rotate_Steps(50 ,1);} + else if(input[0] == 'C' & input[1] == 'R'){STEPPER_MOTOR_4.Rotate_Steps(50 ,0);} + else if(input[0] == 'A' & input[1] == 'U'){STEPPER_MOTOR_5.Rotate_Steps(50 ,1);} + else if(input[0] == 'C' & input[1] == 'U'){STEPPER_MOTOR_5.Rotate_Steps(50 ,0);} + else if(input[0] == 'A' & input[1] == 'D'){STEPPER_MOTOR_6.Rotate_Steps(50 ,1);} + else if(input[0] == 'C' & input[1] == 'D'){STEPPER_MOTOR_6.Rotate_Steps(50 ,0);} + else if(input[0] == 'M' & input[1] == 'O' & input[2] == 'V' & input[3] == 'E') + { + move_loop = 0; + pc.printf("Exiting Move loop\n"); + //Exit moves function + } + else + { + pc.printf("Error please enter a allowed move\n"); + //Error case + } + + } + } + //LIST + else if(input[0] == 'L' & input[1] == 'I' & input[2] == 'S' & input[3] == 'T')//This is where the move list shall be added to + { + List_move_loop = 1; + pc.printf("Entered the Move_List Section\n"); //Request command in the terminal + while(List_move_loop == 1) + { + cin.getline(input,sizeof(input),'\r'); + + if(input[0] == 'A' & input[1] == 'F'){Move_list[Move_list_pointer] = 1; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'C' & input[1] == 'F'){Move_list[Move_list_pointer] = 2; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'A' & input[1] == 'B'){Move_list[Move_list_pointer] = 3; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'C' & input[1] == 'B'){Move_list[Move_list_pointer] = 4; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'A' & input[1] == 'L'){Move_list[Move_list_pointer] = 5; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'C' & input[1] == 'L'){Move_list[Move_list_pointer] = 6; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'A' & input[1] == 'R'){Move_list[Move_list_pointer] = 7; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'C' & input[1] == 'R'){Move_list[Move_list_pointer] = 8; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'A' & input[1] == 'U'){Move_list[Move_list_pointer] = 9; Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'C' & input[1] == 'U'){Move_list[Move_list_pointer] = 10;Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'A' & input[1] == 'D'){Move_list[Move_list_pointer] = 11;Move_list_pointer = Move_list_pointer + 1;} + else if(input[0] == 'C' & input[1] == 'D'){Move_list[Move_list_pointer] = 12;Move_list_pointer = Move_list_pointer + 1;} + + + else if(input[0] == 'D' & input[1] == 'E' & input[2] == 'L' & input[3] == 'E' & input[4] =='T' & input[5] == 'E') + { + pc.printf("Delete Clear Test\n"); + memset(Move_list, 0, sizeof(Move_list)); + Move_list_pointer = 0; + pc.printf("Move List array and pointer reset\n"); + List_move_loop = 0; + pc.printf("Exiting Move List loop\n"); + } + else if(input[0] == 'L' & input[1] == 'I' & input[2] == 'S' & input[3] == 'T') + { + List_move_loop = 0; + pc.printf("Exiting Move List loop\n"); + //Exit moves function + } + else if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D') + { + pc.printf("Printing out the move list\n"); + for(int i=0;i <= Move_list_pointer; i+=1) + { + pc.printf("Value %d is %d\n",i,Move_list[i]); + } + pc.printf("Move List test passed\n"); + List_move_loop = 0; + pc.printf("Exiting Move List loop\n"); + //Exit moves function + } + else if(input[0] == 'R' & input[1] == 'U' & input[2] == 'N') + { + List_move_loop = 0; + { + pc.printf("Move point value is : %d\n",Move_list_pointer); + for(int i = 0; i<= Move_list_pointer; i += 1) + { + if(Move_list[i] == 0){pc.printf("Move List Finished\n");} + else if (Move_list[i] == 1){STEPPER_MOTOR_1.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 2){STEPPER_MOTOR_1.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 3){STEPPER_MOTOR_2.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 4){STEPPER_MOTOR_2.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 5){STEPPER_MOTOR_3.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 6){STEPPER_MOTOR_3.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 7){STEPPER_MOTOR_4.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 8){STEPPER_MOTOR_4.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 9){STEPPER_MOTOR_5.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 10){STEPPER_MOTOR_5.Rotate_Steps(50 ,0);} + else if (Move_list[i] == 11){STEPPER_MOTOR_6.Rotate_Steps(50 ,1);} + else if (Move_list[i] == 12){STEPPER_MOTOR_6.Rotate_Steps(50 ,0);} + else pc.printf("Finished\n"); + } + pc.printf("List Run sucessful\n"); + } + pc.printf("List execution finished\n"); + } + //TEST RUN + else if(input[0] == 'T' & input[1] == 'E' & input[2] == 'S' & input[3] == 'T' & input[4] == '_' & input[5] == 'R' & input[6] == 'U' & input[7] == 'N')//This is the test run code + { + memset(Move_list, 0, sizeof(Move_list)); + Move_list_pointer = 0; + Move_list[Move_list_pointer] = 1 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 2 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 3 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 4 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 5 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 6 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 7 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 8 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 9 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 10 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 11 ;Move_list_pointer = Move_list_pointer + 1; + Move_list[Move_list_pointer] = 12 ;Move_list_pointer = Move_list_pointer + 1; + + pc.printf("Array filled for test\n"); + List_move_loop = 0; + pc.printf("Exiting Move List loop\n"); + } + else + { + pc.printf("Error please enter a allowed move\n"); + //Error case + } + + } + } + //Colours + if(input[0] == 'C' & input[1] == 'O' & input[2] == 'L' & input[3] == 'O' & input[4] == 'U' & input[5] == 'R' & input[6] == 'S' & input[7] == ' ') { - pc.printf("Test Successful\n"); + int NumberOfChars = 0; int ArrayAddress = 0; string COLOURSNUBMER; int NUMBERTOCOLOUR; //Declare required variables + while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} //Count the number of characters entered into the console + for(int x=8; x < NumberOfChars; x++){COLOURSNUBMER += input[x];} //Concatenate the characters between the space and the end + stringstream Number(COLOURSNUBMER); //Convert string to stringstream + Number >> NUMBERTOCOLOUR; + int n = NUMBERTOCOLOUR -1 ; //Convert stringstream to integer + pc.printf("Showing side %D\n",NUMBERTOCOLOUR); + + + pc.printf("%c,%c,%c\n%c,%c,%c\n%c,%c,%c\n", + Value_convert(CubeMap[n][0][0]),Value_convert(CubeMap[n][0][1]),Value_convert(CubeMap[n][0][2]) + ,Value_convert(CubeMap[n][1][0]),Value_convert(CubeMap[n][1][1]),Value_convert(CubeMap[n][1][2]) + ,Value_convert(CubeMap[n][2][0]),Value_convert(CubeMap[n][2][1]),Value_convert(CubeMap[n][2][2]));;//Side n + + + } + //SIDE_ADD + if(input[0] == 'S' & input[1] == 'I' & input[2] == 'D' & input[3] == 'E' & input[4] == '_' & input[5] == 'A' & input[6] == 'D' & input[7] == 'D' & input[8] == ' ') + { + int NumberOfChars = 0; int ArrayAddress = 0; string SIDENUMBER; int NUMBERTOSIDE; //Declare required variables + while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;} //Count the number of characters entered into the console + for(int x=9; x < NumberOfChars; x++){SIDENUMBER += input[x];} //Concatenate the characters between the space and the end + stringstream Number(SIDENUMBER); //Convert string to stringstream + Number >> NUMBERTOSIDE; + pc.printf("Please enter in the colour of segment 1:\n"); + int Colour_value; + cin >>Colour_value; + NUMBERTOSIDE = NUMBERTOSIDE - 1; + + CubeMap[NUMBERTOSIDE][0][0] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 2:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][0][1] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 3:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][0][2] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 4:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][1][0] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 5:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][1][1] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 6:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][1][2] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 7:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][2][0] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 8:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][2][1] = convert(Colour_value); + pc.printf("Please enter in the colour of segment 9:\n"); + cin >>Colour_value; + CubeMap[NUMBERTOSIDE][2][2] = convert(Colour_value); + pc.printf("Side filled\n"); + cin.getline(input,sizeof(input),'\r'); + } + //SIDE_CLEAR + if(input[0] == 'S' & input[1] == 'I' & input[2] == 'D' & input[3] == 'E' & input[4] == '_' & input[5] == 'C' & input[6] == 'L' & input[7] == 'E' & input[8] == 'A' & input[9] == 'R') + { + + for(int i =0; i<=6;i++) + { + CubeMap[i][0][0] = convert(0); + CubeMap[i][0][1] = convert(0); + CubeMap[i][0][2] = convert(0); + CubeMap[i][1][0] = convert(0); + CubeMap[i][1][1] = convert(0); + CubeMap[i][1][2] = convert(0); + CubeMap[i][2][0] = convert(0); + CubeMap[i][2][1] = convert(0); + CubeMap[i][2][2] = convert(0); + } + pc.printf("All sides cleared of data\n"); } //HELP else if(input[0] == 'H' & input[1] == 'E' & input[2] == 'L' & input[3] == 'P') { - pc.printf("Avalible Commands are: \n"); //Print introduction line - pc.printf("Motor x selects a motor in the range of 1-6\n"); //Print list of commands + pc.printf("Please specify the function you would like help in\nMOTOR , LOGGING , MOVE \n"); //Print introduction line + cin.getline(input,sizeof(input),'\r'); + if(input[0] == 'M' & input[1] == 'O' & input[2] == 'T' & input[3] == 'O' & input[4] == 'R'){pc.printf("Motor x selects a motor in the range of 1-6\nThen you issue the angle which is a number either positive or negative\n");} + else if(input[0] == 'L' & input[1] == 'O' & input[2] == 'G' & input[3] == 'G' & input[4] == 'I' & input[5] == 'N' & input[6] == 'G'){pc.printf("Logging enables to user to get more information from the specific area which is logged\n");} + else if(input[0] == 'M' & input[1] == 'O' & input[2] == 'V' & input[3] == 'E'){pc.printf("Allows the user to enter in a movement\n");} + else if(input[0] == 'L' & input[1] == 'I' & input[2] == 'S' & input[3] == 'T'){pc.printf("Allows the user to to view / set a list of movements that can be performed\n");} + else if(input[0] == 'C' & input[1] == 'O' & input[2] == 'L' & input[3] == 'O' & input[4] == 'U' & input[5] == 'R' & input[6] == 'S'){pc.printf("Allows the user to view and set the information upon the cubemap\n");} + else{pc.printf("Enter the specific help area for more information\n");} } else { pc.printf("Please enter an acceptable command\n"); } -} } \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 SERIAL_COMMANDS.hpp --- a/SERIAL_COMMANDS.hpp Mon Jul 16 10:51:47 2018 +0000 +++ b/SERIAL_COMMANDS.hpp Wed Aug 15 21:34:59 2018 +0000 @@ -8,6 +8,7 @@ #include "TIME.hpp" #include "SERIAL.hpp" #include "LED_LOGGING.hpp" +#include "MOVES.hpp" extern float Sample_Rate; void Serial_Commands_Output();
diff -r bc5345bc6650 -r aba1296e51b1 SETUP.hpp --- a/SETUP.hpp Mon Jul 16 10:51:47 2018 +0000 +++ b/SETUP.hpp Wed Aug 15 21:34:59 2018 +0000 @@ -34,13 +34,6 @@ void Console_Output_ISR(); void Rotate_Steps(); -//Object creations -static STEPPER_MOTOR STEPPER_MOTOR_1(D0,D1);//step then direction -static STEPPER_MOTOR STEPPER_MOTOR_2(D2,D3);//step then direction -static STEPPER_MOTOR STEPPER_MOTOR_3(D4,D5);//step then direction -static STEPPER_MOTOR STEPPER_MOTOR_4(D6,D7);//step then direction -static STEPPER_MOTOR STEPPER_MOTOR_5(D8,D9);//step then direction -static STEPPER_MOTOR STEPPER_MOTOR_6(D10,D11);//step then direction //Sets up the sides of the cube static SIDE SIDE1();
diff -r bc5345bc6650 -r aba1296e51b1 SPI.cpp --- a/SPI.cpp Mon Jul 16 10:51:47 2018 +0000 +++ b/SPI.cpp Wed Aug 15 21:34:59 2018 +0000 @@ -1,7 +1,7 @@ #include "SPI.hpp" //File for SPI communication -int SPI_RX_DATA = 0; +//int SPI_RX_DATA = 0; void SPI_INIT() { @@ -40,6 +40,7 @@ void SPI_INTERFACE_SERIAL() { + /* //pc.printf("SPI Test \n"); Thread::wait(1000); cs= 0; @@ -48,5 +49,7 @@ cs= 1; colour_data = SPI_RX_DATA; if(Log_Value == 1){pc.printf("Received data = %d\n", SPI_RX_DATA);} + pc.printf("Received data = %d\n", SPI_RX_DATA); Thread::wait(1000); + */ } \ No newline at end of file
diff -r bc5345bc6650 -r aba1296e51b1 STEPPER_MOTOR.hpp --- a/STEPPER_MOTOR.hpp Mon Jul 16 10:51:47 2018 +0000 +++ b/STEPPER_MOTOR.hpp Wed Aug 15 21:34:59 2018 +0000 @@ -27,4 +27,6 @@ }; #endif//STEPPER_MOTOR_HPP +//Object creations +
diff -r bc5345bc6650 -r aba1296e51b1 main.cpp --- a/main.cpp Mon Jul 16 10:51:47 2018 +0000 +++ b/main.cpp Wed Aug 15 21:34:59 2018 +0000 @@ -12,14 +12,28 @@ 5 = Green 6 = Yellow */ - -//Colours Cubelet_Colours_string[]; +int SPI_RX_DATA = 0; void Serial_Commands(){while(1){Serial_Commands_Output();}}//Enable Serial Commands void LED_Logging(){while(1){Log_Leds();}} //Flashes the yellow led to indicate the logging mode -void SPI_INTERFACE(){while(1){SPI_INTERFACE_SERIAL();}} //Outputs SPI data to serial - +//void SPI_INTERFACE(){while(1){SPI_INTERFACE_SERIAL();}} //Outputs SPI data to serial +void SPI_INTERFACE() +{ + //pc.printf("SPI Test \n"); + Thread::wait(1000); + while(1) + { + cs= 0; + SPI_RX_DATA = spi.write(0xF0); + wait_us(3); + cs= 1; + colour_data = SPI_RX_DATA; + if(Log_Value == 1){pc.printf("Received data = %d\n", SPI_RX_DATA);} + + Thread::wait(1000); + } +} void Motor_Control() { while(1) @@ -72,7 +86,8 @@ spi.format(16,1); // 8 Data bits phase 0 polarity 0 //CHECK THIS spi.frequency(1000000);//Output clock frequency 1Mhz //post(); //Power on Self Test - + memset(Move_list, 0, sizeof(Move_list)); + Move_list_pointer = 0; //Start Threads t1.start(Motor_Control); t2.start(SPI_INTERFACE);