Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
Revision 30:a35f0ab97a65, committed 2019-04-04
- Comitter:
- thomasmorris
- Date:
- Thu Apr 04 10:52:22 2019 +0000
- Parent:
- 29:f3b1387c81f1
- Commit message:
- Testing 1;
Changed in this revision
diff -r f3b1387c81f1 -r a35f0ab97a65 Interface/Interface.cpp --- a/Interface/Interface.cpp Wed Mar 13 11:34:39 2019 +0000 +++ b/Interface/Interface.cpp Thu Apr 04 10:52:22 2019 +0000 @@ -2,7 +2,7 @@ //Constructor INTERFACE::INTERFACE(){}//Set all values to 0 INTERFACE::~INTERFACE(){} //Destructor -void INTERFACE::Interface_Init(int turns, int type_of_rig)//Set all values to 0 bar the default turns +void INTERFACE::Interface_Init(int turns)//Set all values to 0 bar the default turns { Led_Select_Left_mutex.lock(); Led_Select_Left = 0; @@ -36,12 +36,16 @@ _Loop =6; _Loop_mutex.unlock(); + _Loops_done_mutex.lock(); + _Loops_done = 0; + _Loops_done_mutex.unlock(); + _On_Time_mutex.lock(); - _On_Time =6; + _On_Time =4; _On_Time_mutex.unlock(); _Off_Time_mutex.lock(); - _Off_Time =6; + _Off_Time =9; _Off_Time_mutex.unlock(); _Duty_Cycle_mutex.lock(); @@ -80,18 +84,21 @@ _Turns_Todo_mutex.lock(); _Turns_Todo = turns; _Turns_Todo_mutex.unlock(); - - _Type_of_Rig_mutex.lock(); - _Type_of_Rig = type_of_rig; - _Type_of_Rig_mutex.unlock(); + _Function_mutex.lock(); - _Function = type_of_rig; + _Function = 0; _Function_mutex.unlock(); } + +void INTERFACE::Interface_Serial() +{ + printf("Testing\n"); + Thread::wait(1000); +} void INTERFACE::Up()//Up Routine { - if (_Function == 2 || _Function == 3 )//Coiling or twist Function + if (_Function == 2)//Coiling { if(_Select == 0) { @@ -104,6 +111,15 @@ _Direction = !_Direction; } } + else if (_Function == 3)//Run Once + { + if(_On_Time > 0) + { + _On_Time_mutex.lock(); + _On_Time = _On_Time+ 0.5f; //Increments On time + _On_Time_mutex.unlock(); + } + } else if (_Function == 0)//Annealing Function { if (_Select == 0)//Select = 0 @@ -111,7 +127,7 @@ if(_On_Time > 0) { _On_Time_mutex.lock(); - _On_Time = _On_Time+ 1; //Increments On time + _On_Time = _On_Time+ 0.5f; //Increments On time _On_Time_mutex.unlock(); } } @@ -156,7 +172,16 @@ void INTERFACE::Down()//Down Routine { - if (_Function == 2 || _Function == 3)//Coiling or twist Function + if(_Function == 3)//Run Once + { + if(_On_Time > 0) + { + _On_Time_mutex.lock(); + _On_Time = _On_Time - 0.5f; //Decrements On time + _On_Time_mutex.unlock(); + } + } + else if (_Function == 2)//Coiling { if(_Select == 0) { @@ -173,10 +198,10 @@ { if (_Select == 0)//Select = 0 { - if(_On_Time > 1) + if(_On_Time > 0) { _On_Time_mutex.lock(); - _On_Time = _On_Time - 1; //Decrements On time + _On_Time = _On_Time - 0.5f; //Decrements On time _On_Time_mutex.unlock(); } } @@ -233,7 +258,18 @@ printf("Function is: %d, System is: %d\n",_Function,_System_Running);//Used for debugging //Start Cases for when the system is stopped/////////////////////////////////////////////////////////////////////////////////// - if ((_Function == 2 || _Function == 3) & _System_Running == 0)//Twist selected + if((_Function == 3) & _System_Running == 0)//Run Once selected + { + _System_Running_mutex.lock(); + _System_Running = 1;//Code is running + _System_Running_mutex.unlock(); + + _Run_Go_mutex.lock(); + _Run_Go = true;//Run the run once code + _Run_Go_mutex.unlock(); + } + + else if ((_Function == 2) & _System_Running == 0)//Coiling selected { _System_Running_mutex.lock(); _System_Running = 1;//Code is running @@ -253,6 +289,10 @@ _Anneal_Go_mutex.lock(); _Anneal_Go = true;//toggle and Run the code _Anneal_Go_mutex.unlock(); + + _Loops_done_mutex.lock(); + _Loops_done = 0; + _Loops_done_mutex.unlock(); } else if (_Function == 1 & _System_Running == 0) //Testing selected { @@ -267,20 +307,22 @@ /////////////////////////////////////// //System Running cases run to pause the code - else if ((_Function == 2 || _Function == 3) & _System_Running == 1)//Coiling / Twisting selected to be paused + else if((_Function == 3) & _System_Running == 1)//Run once code + { + _Run_Stop_mutex.lock(); + _Run_Stop = true; + _Run_Stop_mutex.unlock(); + _System_Running_mutex.lock(); + _System_Running = 2; + _System_Running_mutex.unlock(); + } + else if ((_Function == 2) & _System_Running == 1)//Coiling { _Twist_Stop_mutex.lock(); _Twist_Stop = true; _Twist_Stop_mutex.unlock(); - - if(_Function == 2) - { - printf("Coiling Code Paused\n"); - } - if(_Function == 3) - { - printf("Twisting Code Paused\n"); - } + + printf("Coiling Code Paused\n"); _System_Running_mutex.lock(); _System_Running = 2; _System_Running_mutex.unlock(); @@ -304,9 +346,7 @@ printf("Testing Code Paused\n"); - _Tendon_mutex.lock(); - Tendon_Power=0; - _Tendon_mutex.unlock(); + _System_Running_mutex.lock(); _System_Running = 2;//Pause code @@ -315,7 +355,23 @@ //////////////// //System Paused cases run to unpause - else if ((_Function == 2 || _Function == 3) & _System_Running == 2)//Coil Twist selected to be unpaused + else if ((_Function == 3) & _System_Running ==2) + { + _Run_Stop_mutex.lock(); + _Run_Stop = false; + _Run_Stop_mutex.unlock(); + + _Run_Go_mutex.lock(); + _Run_Go = true;//toggle used for coiling and twisting and Running the code + _Run_Go_mutex.unlock(); + + + _System_Running_mutex.lock(); + _System_Running = 1;//Code is unpaused + _System_Running_mutex.unlock(); + + } + else if ((_Function == 2) & _System_Running == 2)//Coil to be unpaused { _Twist_Stop_mutex.lock(); _Twist_Stop = false; @@ -327,14 +383,9 @@ STEPPER_MOTOR_1.Unpause_Code(); - if(_Function == 2)//Coiling - { - printf("Coiling Code unpaused\n"); - } - if(_Function == 3)//Twisiting - { - printf("Twisting Code unpaused\n"); - } + + printf("Coiling Code unpaused\n"); + _System_Running_mutex.lock(); _System_Running = 1;//Code is unpaused _System_Running_mutex.unlock(); @@ -373,24 +424,21 @@ Function 0 = Anneal Function 1 = Test Function 2 = Coiling - Function 3 = Twisting + Function 3 = Run Once */ - if(_Type_of_Rig == 3)//Twisting - { - _Function = 3; - } - if(_Type_of_Rig == 2) + _Select_mutex.lock(); + _Select = 0;//Set the select value to 0 whenever the function is changed + _Select_mutex.unlock(); + + if(_Function < 3) { - if(_Function < 2) - { - _Function_mutex.lock(); - _Function = _Function + 1; - _Function_mutex.unlock(); - } - else if(_Function == 2) - { - _Function = 0; - } + _Function_mutex.lock(); + _Function = _Function + 1; + _Function_mutex.unlock(); + } + else if(_Function == 3) + { + _Function = 0; } } void INTERFACE::Select()//Select Routine @@ -465,7 +513,7 @@ Led_Select_Right_mutex.unlock(); } } - else if(_Function == 2 || _Function == 3)//Coiling and Twisting + else if(_Function == 2 )//Coiling { if(_Select == 0)//Toggle code for select { @@ -497,11 +545,64 @@ Led_Select_Right_mutex.unlock(); } } + else if(_Function == 3)//Run once code alway have the led to be on the left + { + 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(); + } _Select_mutex.unlock(); } void INTERFACE::Interface_main()//Main Routine to execute commands when the start button has been pressed { - if (_Function == 2 || _Function == 3) //Turning Code for coiling and twisting + if (_Function == 3) //Run once code Code + { + if (_Run_Go == true) + { + Led_Power_mutex.lock(); + Led_Power = 1; + Led_Power_mutex.unlock(); + + _System_Running_mutex.lock(); + _System_Running = 1; + _System_Running_mutex.unlock(); + + + if(_System_Running == 1) + { + + _Run_Once_On_Time_mutex.lock(); + Thread::wait((_Run_Once_On_Time)*1000);//Variable + _Run_Once_On_Time_mutex.unlock(); + + Thread::wait(9001);//Fixed off time ITS OVER 9000 + _Tendon_mutex.unlock(); + } + while(_System_Running == 2)//Stops the system and just spins in this while loop until system running is not paused + { + _Tendon_mutex.lock(); + + _Tendon_mutex.unlock(); + } + + _System_Running_mutex.lock(); + _System_Running = 0; + _System_Running_mutex.unlock(); + + _Run_Go_mutex.lock(); + _Run_Go = false; + _Run_Go_mutex.unlock(); + + Led_Power_mutex.lock(); + Led_Power = 0; + Led_Power_mutex.unlock(); + } + } + else if (_Function == 2) //Turning Code for coiling { if (_Twist_Go == true) { @@ -541,28 +642,32 @@ _System_Running = 1; _System_Running_mutex.unlock(); + _Loops_done_mutex.lock(); + _Loops_done = 0; + _Loops_done_mutex.unlock(); + for ( int counter = 0; counter < _Loop; counter++) //Loop value, check if works { if(_System_Running == 1) { _Tendon_mutex.lock(); - Tendon_Power.period(0.01); // set PWM period to 10 ms don't use pwm have this just to declare - Tendon_Power=1; // set duty cycle to 100% + _On_Time_mutex.lock(); - wait(_On_Time);//Variable + Thread::wait((_On_Time)*1000);//Variable _On_Time_mutex.unlock(); - Tendon_Power=0; // set duty cycle to 0% + _Off_Time_mutex.lock(); - wait(_Off_Time);//Fixed off time + Thread::wait((_Off_Time)*1000);//Fixed off time _Off_Time_mutex.unlock(); _Tendon_mutex.unlock(); } while(_System_Running == 2)//Stops the system and just spins in this while loop until system running is not paused { - _Tendon_mutex.lock(); - Tendon_Power =0; - _Tendon_mutex.unlock(); + } + _Loops_done_mutex.lock(); + _Loops_done = _Loops_done + 1; + _Loops_done_mutex.unlock(); } _System_Running_mutex.lock(); @@ -591,10 +696,8 @@ _System_Running_mutex.unlock(); _Tendon_mutex.lock(); - Tendon_Power.period(0.01); // set PWM period to 10 ms don't use pwm have this just to declare - Tendon_Power= _Duty_Cycle / 100; // set duty cycle to variable input from buttons between 0-1 (on lcd this is a percentage) also increment by values of 10 - wait(_Power_Time);//Variable on time for power on - Tendon_Power=0; // set duty cycle to 0% and power off + Thread::wait((_Power_Time)*1000);//Variable on time for power on + _Tendon_mutex.unlock(); _System_Running_mutex.lock(); @@ -617,14 +720,18 @@ void INTERFACE::Set_Twist_Go(bool Twist_Go){_Twist_Go_mutex.lock();_Twist_Go = Twist_Go;_Twist_Go_mutex.unlock();} void INTERFACE::Set_Anneal_Go(bool Anneal_Go){_Anneal_Go_mutex.lock();_Anneal_Go = Anneal_Go;_Anneal_Go_mutex.unlock();} void INTERFACE::Set_Test_Go(bool Test_Go){_Test_Go_mutex.lock();_Test_Go = Test_Go;_Test_Go_mutex.unlock();} +void INTERFACE::Set_Run_Go(bool Run_Go){_Run_Go_mutex.lock();_Run_Go = Run_Go;_Run_Go_mutex.unlock();} void INTERFACE::Set_Twist_Stop(bool Twist_Stop){_Twist_Stop_mutex.lock();_Twist_Stop = Twist_Stop;_Twist_Stop_mutex.unlock();} void INTERFACE::Set_Anneal_Stop(bool Anneal_Stop){_Anneal_Stop_mutex.lock();_Anneal_Stop = Anneal_Stop;_Anneal_Stop_mutex.unlock();} void INTERFACE::Set_Test_Stop(bool Test_Stop){_Test_Stop_mutex.lock();_Test_Go = Test_Stop;_Test_Stop_mutex.unlock();} +void INTERFACE::Set_Run_Stop(bool Run_Stop){_Run_Stop_mutex.lock();_Run_Stop = Run_Stop;_Run_Stop_mutex.unlock();} void INTERFACE::Set_Select(int Select){_Select_mutex.lock();_Select = Select;_Select_mutex.unlock();} void INTERFACE::Set_Turns_Done(int Turns_Done){_Turns_Done_mutex.lock();_Turns_Done = Turns_Done;_Turns_Done_mutex.unlock();} void INTERFACE::Set_Turns_To_Do(int Turns_Todo){_Turns_Todo_mutex.lock();_Turns_Todo = Turns_Todo;_Turns_Todo_mutex.unlock();} void INTERFACE::Set_Loop(int Loop){_Loop_mutex.lock();Loop = Loop;_Loop_mutex.unlock();} -void INTERFACE::Set_On_Time(int On_Time){_On_Time_mutex.lock();_On_Time = On_Time;_On_Time_mutex.unlock();} +void INTERFACE::Set_Loops_done(int Loops_done){_Loops_done_mutex.lock();_Loops_done = Loops_done; _Loops_done_mutex.unlock();} +void INTERFACE::Set_On_Time(float On_Time){_On_Time_mutex.lock();_On_Time = On_Time;_On_Time_mutex.unlock();} +void INTERFACE::Set_Run_Once_On_Time(float Run_Once_On_Time){_Run_Once_On_Time_mutex.lock();_Run_Once_On_Time = Run_Once_On_Time;_Run_Once_On_Time_mutex.unlock();} void INTERFACE::Set_Off_Time(int Off_Time){_Off_Time_mutex.lock();_Off_Time = Off_Time;_Off_Time_mutex.unlock();} void INTERFACE::Set_Duty_Cycle(int Duty_Cycle){_Duty_Cycle_mutex.lock();_Duty_Cycle = Duty_Cycle;_Duty_Cycle_mutex.unlock();} void INTERFACE::Set_Power_Time(float Power_Time){_Power_Time_mutex.lock();_Power_Time = Power_Time;_Power_Time_mutex.unlock();} @@ -635,14 +742,18 @@ bool INTERFACE::Get_Twist_Go(){return _Twist_Go;} bool INTERFACE::Get_Anneal_Go(){return _Anneal_Go;} bool INTERFACE::Get_Test_Go(){return _Test_Go;} +bool INTERFACE::Get_Run_Go(){return _Run_Go;} bool INTERFACE::Get_Twist_Stop(){return _Twist_Stop;} bool INTERFACE::Get_Anneal_Stop(){return _Anneal_Stop;} bool INTERFACE::Get_Test_Stop(){return _Test_Stop;} +bool INTERFACE::Get_Run_Stop(){return _Run_Stop;} int INTERFACE::Get_Select(){return _Select;} int INTERFACE::Get_Turns_Done(){_Turns_Done = STEPPER_MOTOR_1.Get_Turns(); return _Turns_Done;} int INTERFACE::Get_Turns_To_Do(){return _Turns_Todo;} +int INTERFACE::Get_Loops_done(){return _Loops_done;} int INTERFACE::Get_Loop(){return _Loop;} -int INTERFACE::Get_On_Time(){return _On_Time;} +float INTERFACE::Get_On_Time(){return _On_Time;} +float INTERFACE::Get_Run_Once_On_Time(){return _Run_Once_On_Time;} int INTERFACE::Get_Off_Time(){return _Off_Time;} int INTERFACE::Get_Duty_Cycle(){return _Duty_Cycle;} int INTERFACE::Get_Power_Time(){return _Power_Time;}
diff -r f3b1387c81f1 -r a35f0ab97a65 Interface/Interface.hpp --- a/Interface/Interface.hpp Wed Mar 13 11:34:39 2019 +0000 +++ b/Interface/Interface.hpp Thu Apr 04 10:52:22 2019 +0000 @@ -18,8 +18,6 @@ static DigitalOut Led_Select_Right(D3); static DigitalOut Led_Power(A0); static STEPPER_MOTOR STEPPER_MOTOR_1(D15,D14,D13,D12); -static PwmOut Tendon_Power(PE_8); - class INTERFACE//This creates a class called Led { @@ -30,7 +28,8 @@ INTERFACE(); //Constructor ~INTERFACE();//Destructor - void Interface_Init(int turns, int type_of_rig);//Set all values to 0 bar the passed in variable + void Interface_Init(int turns);//Set all values to 0 bar the passed in variable + void Interface_Serial(); void Up();//Up Routine void Down();//Down Routine void Start_Stop();//Start / Stop Routine @@ -44,14 +43,18 @@ void Set_Twist_Go(bool Twist_Go); void Set_Anneal_Go(bool Anneal_Go); void Set_Test_Go(bool Test_Go); + void Set_Run_Go(bool Run_Go); void Set_Twist_Stop(bool Twist_Stop); void Set_Anneal_Stop(bool Anneal_Stop); void Set_Test_Stop(bool Test_Stop); + void Set_Run_Stop(bool Run_Stop); void Set_Select(int Select); void Set_Turns_Done(int Turns_Done); void Set_Turns_To_Do(int Turns_To_Do); void Set_Loop(int Loop); - void Set_On_Time(int On_Time); + void Set_Loops_done(int Loops_done); + void Set_On_Time(float On_Time); + void Set_Run_Once_On_Time(float Run_Once_On_Time); void Set_Off_Time(int Off_Time); void Set_Duty_Cycle(int Duty_Cycle); void Set_Power_Time(float Power_Time); @@ -63,14 +66,18 @@ bool Get_Twist_Go(); bool Get_Anneal_Go(); bool Get_Test_Go(); + bool Get_Run_Go(); bool Get_Twist_Stop(); bool Get_Anneal_Stop(); bool Get_Test_Stop(); + bool Get_Run_Stop(); int Get_Select(); int Get_Turns_Done(); int Get_Turns_To_Do(); int Get_Loop(); - int Get_On_Time(); + int Get_Loops_done(); + float Get_On_Time(); + float Get_Run_Once_On_Time(); int Get_Off_Time(); int Get_Duty_Cycle(); int Get_Power_Time(); @@ -86,22 +93,26 @@ bool _Twist_Go; bool _Anneal_Go; bool _Test_Go; + bool _Run_Go; //Stop bool _Twist_Stop; bool _Anneal_Stop; bool _Test_Stop; - + bool _Run_Stop; + int _Select; int _Turns_Done; int _Turns_Todo; + int _Loops_done; int _Loop; - int _On_Time; + float _On_Time; + float _Run_Once_On_Time; int _Off_Time;//IN SECONDS int _Duty_Cycle; int _Power_Time; bool _Direction; - int _Type_of_Rig; + //Mutex Locks Mutex _System_Running_mutex; @@ -110,14 +121,18 @@ Mutex _Twist_Go_mutex; Mutex _Anneal_Go_mutex; Mutex _Test_Go_mutex; + Mutex _Run_Go_mutex; Mutex _Twist_Stop_mutex; Mutex _Anneal_Stop_mutex; Mutex _Test_Stop_mutex; + Mutex _Run_Stop_mutex; Mutex _Select_mutex; Mutex _Turns_Done_mutex; Mutex _Turns_Todo_mutex; Mutex _Loop_mutex; + Mutex _Loops_done_mutex; Mutex _On_Time_mutex;//IN SECONDS + Mutex _Run_Once_On_Time_mutex; Mutex _Off_Time_mutex; Mutex _Duty_Cycle_mutex; Mutex _Power_Time_mutex;
diff -r f3b1387c81f1 -r a35f0ab97a65 README.txt --- a/README.txt Wed Mar 13 11:34:39 2019 +0000 +++ b/README.txt Thu Apr 04 10:52:22 2019 +0000 @@ -23,8 +23,7 @@ Function 0 = Anneal Function 1 = Test Function 2 = Coiling - Function 3 = Twisting - Function 4 = Custom + Function 3 = Run Once Black :Reset : HardWired Red :Up : D8
diff -r f3b1387c81f1 -r a35f0ab97a65 SETUP.hpp --- a/SETUP.hpp Wed Mar 13 11:34:39 2019 +0000 +++ b/SETUP.hpp Thu Apr 04 10:52:22 2019 +0000 @@ -36,6 +36,7 @@ Thread start_stop_thread; Thread function_thread; Thread select_thread; +Thread Interface_Serial_thread; //LCD pin connections TextLCD lcd(D0,D1,D4,D5,D6,D7); // rs, e, d4-d7
diff -r f3b1387c81f1 -r a35f0ab97a65 Stepper_Motor/STEPPER_MOTOR.cpp --- a/Stepper_Motor/STEPPER_MOTOR.cpp Wed Mar 13 11:34:39 2019 +0000 +++ b/Stepper_Motor/STEPPER_MOTOR.cpp Thu Apr 04 10:52:22 2019 +0000 @@ -81,8 +81,7 @@ this->pin1 = 0; this->pin2 = 1; this->pin3 = 0; - this->pin4 = 1; - Thread::wait(loop_wait_time); + this->pin4 = 1; } Thread::wait(loop_wait_time); _Steps_Done = _Steps_Done +1;
diff -r f3b1387c81f1 -r a35f0ab97a65 main.cpp --- a/main.cpp Wed Mar 13 11:34:39 2019 +0000 +++ b/main.cpp Thu Apr 04 10:52:22 2019 +0000 @@ -1,4 +1,12 @@ #include "SETUP.hpp" +void Interface_Serial_thread_function() +{ + while(1) + { + INTERFACE.Interface_Serial(); + } +} + void Polling_thread_function()// Polling thread to look for button press { while(1) @@ -15,7 +23,7 @@ up_thread.signal_set(1); } } - else if((INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 0) + else if((INTERFACE.Get_Function() == 2) & INTERFACE.Get_Select() == 0) { if(button_up.read() == 1) { @@ -50,7 +58,7 @@ down_thread.signal_set(1); } } - else if((INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 0) + else if((INTERFACE.Get_Function() == 2) & INTERFACE.Get_Select() == 0) { if(button_down.read() == 1) { @@ -116,11 +124,13 @@ lcd.printf("Mode: Anneal\n"); //Top LCD line when the device is annealing if(INTERFACE.Get_Select() == 0 || INTERFACE.Get_Select() == 1) { - lcd.printf("Loop:%d On_t:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_On_Time()); //When the On value is selected + lcd.printf("L:%d,%d Ont:%1.1f\n",INTERFACE.Get_Loops_done(),INTERFACE.Get_Loop(),INTERFACE.Get_On_Time()); //When the On value is selected + //lcd.printf("Loop:%d On_t:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_On_Time()); //When the On value is selected } else if(INTERFACE.Get_Select() == 2) { - lcd.printf("Loop:%d Offt:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); //When the Off value is selected + lcd.printf("L:%d,%d Offt:%d\n",INTERFACE.Get_Loops_done(),INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); //When the Off value is selected + //lcd.printf("Loop:%d Offt:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); //When the Off value is selected } } else if(INTERFACE.Get_Function() == 1)//Testing mode display @@ -148,25 +158,10 @@ } } } - else if(INTERFACE.Get_Function() == 3)//Twist + else if(INTERFACE.Get_Function() == 3)//Run Once { - if(INTERFACE.Get_Select() == 0) - { - lcd.printf("Mode: Twist\n"); //Top LCD line when the device is Twisting - lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do()); - } - else if(INTERFACE.Get_Select() == 1) - { - lcd.printf("Mode: Twist\n"); //Top LCD line when the device is Twisting - if(INTERFACE.Get_Direction() == 0)//Clockwise - { - lcd.printf("Dir: Clock\n"); - } - else if (INTERFACE.Get_Direction() == 1)//AntiClockwise - { - lcd.printf("Dir: AntiClock\n"); - } - } + lcd.printf("Mode: RunOnce\n"); //Top LCD line when the device is annealing + lcd.printf("Loops: 1 Ont:%1.1f\n",INTERFACE.Get_Run_Once_On_Time()); //When the On value is selected } Thread::wait(100);//Refresh rate for Lcd } @@ -265,9 +260,10 @@ start_stop_thread.start(start_stop_thread_function);//Start / stop interface thread function_thread.start(Function_Selection_thread_function);//Function interface thread select_thread.start(Selection_thread_function);//Start interface thread + Interface_Serial_thread.start(Interface_Serial_thread_function); osThreadSetPriority(osThreadGetId(), osPriorityHigh);//This is done to make sure the code for the stepper motor is the highest priority to ensure correct rotations of the stepper motor - INTERFACE.Interface_Init(80,2);//Pass in turns first then the type of rig second 2 for coiling 3 for twisting + INTERFACE.Interface_Init(55);//Pass in turns while(1)// Main code in a main thread { INTERFACE.Interface_main();//Run main thread code