![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
Diff: main.cpp
- Revision:
- 27:22d6fd88828e
- Parent:
- 26:83550fc299aa
- Child:
- 28:3193157ebb0c
--- a/main.cpp Tue Feb 19 14:40:01 2019 +0000 +++ b/main.cpp Fri Mar 01 21:57:59 2019 +0000 @@ -1,10 +1,9 @@ #include "SETUP.hpp" -void Polling_thread_function()// Polling thread for the buttons +void Polling_thread_function()// Polling thread to look for button press { while(1) { - //printf("In polling\n");//Check the value - if(button_up.read() == 0) + if(button_up.read() == 0) //This checks the Up button { printf("Up button read\n"); Thread::wait(Debounce_Time); @@ -14,7 +13,7 @@ up_thread.signal_set(1); } } - if(button_down.read() == 0) + if(button_down.read() == 0) //This checks the Down button { printf("Down button read\n"); Thread::wait(Debounce_Time); @@ -23,7 +22,7 @@ down_thread.signal_set(1); } } - if(button_start.read() == 0) + if(button_start.read() == 0) //This checks the Start/Stop button { printf("Start/Stop button read\n"); Thread::wait(Debounce_Time); @@ -32,7 +31,7 @@ start_stop_thread.signal_set(1); } } - if(button_function.read() == 0) + if(button_function.read() == 0) //This checks the Function button { printf("Function button read\n"); Thread::wait(Debounce_Time); @@ -41,7 +40,7 @@ function_thread.signal_set(1); } } - if(button_select.read() == 0) + if(button_select.read() == 0) //This checks the Select button { printf("Select button read\n"); Thread::wait(Debounce_Time); @@ -53,36 +52,39 @@ Thread::wait(50); } } -void LCD_thread()//Output data to the LCD for the interface +void LCD_thread() //Output data to the LCD for the interface + /* + This section of the code decides what data that should be sent to the LCD for each of the modes of the system. + */ { while(1) { lcd.cls();//Clear the LCD screen - if(INTERFACE.Get_Function() == 0)//Anneal + if(INTERFACE.Get_Function() == 0)//Anneal Mode display { - lcd.printf("Mode: Anneal\n"); + 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()); + 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()); + 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)//Test + else if(INTERFACE.Get_Function() == 1)//Testing mode display { - lcd.printf("Mode: Test\n"); + lcd.printf("Mode: Test\n"); //Top LCD line when the device is Testing lcd.printf("Duty: %dTime: %d\n",INTERFACE.Get_Duty_Cycle(),INTERFACE.Get_Power_Time()); } else if(INTERFACE.Get_Function() == 2)//Coil { - lcd.printf("Mode: Coil\n"); + lcd.printf("Mode: Coil\n"); //Top LCD line when the device is Coiling lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do()); } else if(INTERFACE.Get_Function() == 3)//Twist { - lcd.printf("Mode: Twist\n"); + 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()); } Thread::wait(250);//Refresh rate for Lcd @@ -177,7 +179,7 @@ Thread::wait(1000); pc.printf("Program start\n");//Outputs informtation to the putty terminal - //Thread Starts + //Thread Initialisation polling_thread.start(Polling_thread_function);//Start the button polling lcd_thread.start(LCD_thread);//Output data to LCD led_thread.start(LED_thread);//Blinking led to show CPU running