![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
Diff: Interface/Interface.cpp
- Revision:
- 24:728de4bf961e
- Parent:
- 23:07a368f2cdb1
- Child:
- 25:9751619fa030
--- a/Interface/Interface.cpp Sat Feb 16 15:19:21 2019 +0000 +++ b/Interface/Interface.cpp Mon Feb 18 12:02:34 2019 +0000 @@ -10,6 +10,14 @@ //Interrupt run functions void INTERFACE::Interface_Init()//Set all values to 0 bar the default turns { + Led_Select_Left_mutex.lock(); + Led_Select_Left = 0; + Led_Select_Left_mutex.unlock(); + + Led_Select_Right_mutex.lock(); + Led_Select_Right= 0; + Led_Select_Right_mutex.unlock(); + _Function_mutex.lock(); _Function =0; _Function_mutex.unlock(); @@ -69,6 +77,15 @@ _System_Running_mutex.lock(); _System_Running =0; _System_Running_mutex.unlock(); + + + Led_Select_Left_mutex.lock(); + Led_Select_Left = 0; + Led_Select_Left_mutex.unlock(); + + Led_Select_Right_mutex.lock(); + Led_Select_Right= 1; + Led_Select_Right_mutex.unlock(); } void INTERFACE::Up()//Up Routine { @@ -103,12 +120,12 @@ _Duty_Cycle = _Duty_Cycle + 10; //Increases Testing Duty Cycle _Duty_Cycle_mutex.unlock(); } - else if (_Select == true)//Select = 1 - { - _Power_Time_mutex.lock(); - _Power_Time = _Power_Time + 1; //Increases time on - _Power_Time_mutex.unlock(); - } + } + else if (_Select == true)//Select = 1 + { + _Power_Time_mutex.lock(); + _Power_Time = _Power_Time + 1; //Increases time on + _Power_Time_mutex.unlock(); } } } @@ -131,14 +148,14 @@ _Loop = _Loop - 1; _Loop_mutex.unlock(); } - else if (_Select == true)//Select = 1 + } + else if (_Select == true)//Select = 1 + { + if (_Wait_Time > 0) { - if (_Wait_Time > 0) - { - _Wait_Time_mutex.lock(); - _Wait_Time = _Wait_Time - 1; - _Wait_Time_mutex.unlock(); - } + _Wait_Time_mutex.lock(); + _Wait_Time = _Wait_Time - 1; + _Wait_Time_mutex.unlock(); } } } @@ -152,39 +169,70 @@ _Duty_Cycle = _Duty_Cycle - 10; //Decreases duty _Duty_Cycle_mutex.unlock(); } - else if (_Select == true)//Select = 1 + } + else if (_Select == true)//Select = 1 + { + if (_Power_Time > 0) { - if (_Power_Time > 0) - { - _Power_Time_mutex.lock(); - _Power_Time = _Power_Time - 1; //Decreases Time on - _Power_Time_mutex.unlock(); - } + _Power_Time_mutex.lock(); + _Power_Time = _Power_Time - 1; //Decreases Time on + _Power_Time_mutex.unlock(); } } + } } void INTERFACE::Start_Stop()//Start / Stop Routine { - _System_Running = !_System_Running; + + if(_System_Running != 2) + { + _System_Running = !_System_Running; + } //System not running cases (START) - if (_Function == 0 & _System_Running == 0)//Twist selected + printf("Function is: %d, System is: %d\n",_Function,_System_Running); + + //System Running cases (Unpause) + if (_Function == 0 & _System_Running == 2)//Twist selected to be unpasued { + printf("Twisting Code unpaused\n"); + _Twist_Stop_mutex.lock(); + _Twist_Stop = false; + _Twist_Stop_mutex.unlock(); + _Twist_Go_mutex.lock(); _Twist_Go = true;//toggle used for coiling and twisting and Running the code _Twist_Go_mutex.unlock(); + + STEPPER_MOTOR_1.Unpause_Code(); + + printf("Twisting Code unpaused\n"); + _System_Running = 0; + } - else if (_Function == 1 & _System_Running == 0) //Annealing selected + else if (_Function == 1 & _System_Running == 2) //Annealing selected to be unpaused { + _Anneal_Stop_mutex.lock(); + _Anneal_Stop = false; + _Anneal_Stop_mutex.unlock(); + printf("Annealing Code unpaused\n"); + _Anneal_Go_mutex.lock(); _Anneal_Go = true;//toggle and Run the code _Anneal_Go_mutex.unlock(); + _System_Running = 0; } - else if (_Function == 2 & _System_Running == 0) //Testing selected + else if (_Function == 2 & _System_Running == 2) //Testing selected to be re run { + _Test_Stop_mutex.lock(); + _Test_Stop = false; + _Test_Stop_mutex.unlock(); + printf("Testing Code unpaused\n"); _Test_Go_mutex.lock(); _Test_Go = true;//toggle and run the code _Test_Go_mutex.unlock(); + _System_Running = 0; + } //System Running cases (STOP) else if (_Function == 0 & _System_Running == 1)//Twist selected to be stopped @@ -213,7 +261,9 @@ _Test_Stop_mutex.lock(); _Test_Stop = true; _Test_Stop_mutex.unlock(); + printf("Testing Code Paused\n"); + _Tendon_mutex.lock(); Tendon_Power=0; _Tendon_mutex.unlock(); @@ -222,44 +272,24 @@ _System_Running = 2; _System_Running_mutex.unlock(); } - //System Running cases (Unpause) - else if (_Function == 0 & _System_Running == 2)//Twist selected to be unpasued + //Start Cases + else if (_Function == 0 & _System_Running == 0)//Twist selected { - _Twist_Stop_mutex.lock(); - _Twist_Stop = false; - _Twist_Stop_mutex.unlock(); - _Twist_Go_mutex.lock(); _Twist_Go = true;//toggle used for coiling and twisting and Running the code _Twist_Go_mutex.unlock(); - - STEPPER_MOTOR_1.Unpause_Code(); - - printf("Twisting Code unpaused\n"); - } - else if (_Function == 1 & _System_Running == 2) //Annealing selected to be unpaused + else if (_Function == 1 & _System_Running == 0) //Annealing selected { - _Anneal_Stop_mutex.lock(); - _Anneal_Stop = false; - _Anneal_Stop_mutex.unlock(); - printf("Annealing Code unpaused\n"); - _Anneal_Go_mutex.lock(); _Anneal_Go = true;//toggle and Run the code _Anneal_Go_mutex.unlock(); } - else if (_Function == 2 & _System_Running == 2) //Testing selected to be re run + else if (_Function == 2 & _System_Running == 0) //Testing selected { - _Test_Stop_mutex.lock(); - _Test_Stop = false; - _Test_Stop_mutex.unlock(); - printf("Testing Code unpaused\n"); _Test_Go_mutex.lock(); _Test_Go = true;//toggle and run the code _Test_Go_mutex.unlock(); - - } } void INTERFACE::Function()//Function Routine used to increment through the three functions