![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Testing 1 blue pill
Dependencies: mbed mbed-rtos TextLCD
main.cpp@29:f3b1387c81f1, 2019-03-13 (annotated)
- Committer:
- thomasmorris
- Date:
- Wed Mar 13 11:34:39 2019 +0000
- Revision:
- 29:f3b1387c81f1
- Parent:
- 28:3193157ebb0c
- Child:
- 30:a35f0ab97a65
Final Coiling Rig;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 12:d9c133b360b0 | 1 | #include "SETUP.hpp" |
JDickson | 27:22d6fd88828e | 2 | void Polling_thread_function()// Polling thread to look for button press |
thomasmorris | 26:83550fc299aa | 3 | { |
thomasmorris | 26:83550fc299aa | 4 | while(1) |
thomasmorris | 26:83550fc299aa | 5 | { |
JDickson | 27:22d6fd88828e | 6 | if(button_up.read() == 0) //This checks the Up button |
thomasmorris | 26:83550fc299aa | 7 | { |
thomasmorris | 26:83550fc299aa | 8 | printf("Up button read\n"); |
thomasmorris | 29:f3b1387c81f1 | 9 | Thread::wait(Up_Down_Debounce_Time); |
thomasmorris | 29:f3b1387c81f1 | 10 | if(INTERFACE.Get_Function() == 0 || INTERFACE.Get_Function() == 1 || (INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 1 ) |
thomasmorris | 29:f3b1387c81f1 | 11 | { |
thomasmorris | 29:f3b1387c81f1 | 12 | if(button_up.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 13 | { |
thomasmorris | 29:f3b1387c81f1 | 14 | printf("Up button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 15 | up_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 16 | } |
thomasmorris | 29:f3b1387c81f1 | 17 | } |
thomasmorris | 29:f3b1387c81f1 | 18 | else if((INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 0) |
thomasmorris | 29:f3b1387c81f1 | 19 | { |
thomasmorris | 29:f3b1387c81f1 | 20 | if(button_up.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 21 | { |
thomasmorris | 29:f3b1387c81f1 | 22 | printf("Up button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 23 | up_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 24 | } |
thomasmorris | 29:f3b1387c81f1 | 25 | Thread::wait(1000); |
thomasmorris | 29:f3b1387c81f1 | 26 | |
thomasmorris | 29:f3b1387c81f1 | 27 | if(button_up.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 28 | { |
thomasmorris | 29:f3b1387c81f1 | 29 | printf("Up function coiling or twisting select = 0\n"); |
thomasmorris | 29:f3b1387c81f1 | 30 | while(button_up.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 31 | { |
thomasmorris | 29:f3b1387c81f1 | 32 | if(INTERFACE.Get_Turns_To_Do() >0) |
thomasmorris | 29:f3b1387c81f1 | 33 | { |
thomasmorris | 29:f3b1387c81f1 | 34 | INTERFACE.Set_Turns_To_Do(INTERFACE.Get_Turns_To_Do()+1); |
thomasmorris | 29:f3b1387c81f1 | 35 | } |
thomasmorris | 29:f3b1387c81f1 | 36 | Thread::wait(50); |
thomasmorris | 29:f3b1387c81f1 | 37 | } |
thomasmorris | 29:f3b1387c81f1 | 38 | } |
thomasmorris | 29:f3b1387c81f1 | 39 | } |
thomasmorris | 26:83550fc299aa | 40 | } |
JDickson | 27:22d6fd88828e | 41 | if(button_down.read() == 0) //This checks the Down button |
thomasmorris | 26:83550fc299aa | 42 | { |
thomasmorris | 26:83550fc299aa | 43 | printf("Down button read\n"); |
thomasmorris | 29:f3b1387c81f1 | 44 | Thread::wait(Up_Down_Debounce_Time); |
thomasmorris | 29:f3b1387c81f1 | 45 | if(INTERFACE.Get_Function() == 0 || INTERFACE.Get_Function() == 1 || (INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 1 ) |
thomasmorris | 29:f3b1387c81f1 | 46 | { |
thomasmorris | 29:f3b1387c81f1 | 47 | if(button_down.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 48 | { |
thomasmorris | 29:f3b1387c81f1 | 49 | printf("Down button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 50 | down_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 51 | } |
thomasmorris | 29:f3b1387c81f1 | 52 | } |
thomasmorris | 29:f3b1387c81f1 | 53 | else if((INTERFACE.Get_Function() == 2 || INTERFACE.Get_Function() == 3) & INTERFACE.Get_Select() == 0) |
thomasmorris | 26:83550fc299aa | 54 | { |
thomasmorris | 29:f3b1387c81f1 | 55 | if(button_down.read() == 1) |
thomasmorris | 29:f3b1387c81f1 | 56 | { |
thomasmorris | 29:f3b1387c81f1 | 57 | printf("Down button released\n"); |
thomasmorris | 29:f3b1387c81f1 | 58 | down_thread.signal_set(1); |
thomasmorris | 29:f3b1387c81f1 | 59 | } |
thomasmorris | 29:f3b1387c81f1 | 60 | Thread::wait(1000); |
thomasmorris | 29:f3b1387c81f1 | 61 | |
thomasmorris | 29:f3b1387c81f1 | 62 | if(button_down.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 63 | { |
thomasmorris | 29:f3b1387c81f1 | 64 | printf("down function coiling or twisting select = 0\n"); |
thomasmorris | 29:f3b1387c81f1 | 65 | while(button_down.read() == 0) |
thomasmorris | 29:f3b1387c81f1 | 66 | { |
thomasmorris | 29:f3b1387c81f1 | 67 | if(INTERFACE.Get_Turns_To_Do() >0) |
thomasmorris | 29:f3b1387c81f1 | 68 | { |
thomasmorris | 29:f3b1387c81f1 | 69 | INTERFACE.Set_Turns_To_Do(INTERFACE.Get_Turns_To_Do()-1); |
thomasmorris | 29:f3b1387c81f1 | 70 | } |
thomasmorris | 29:f3b1387c81f1 | 71 | Thread::wait(50); |
thomasmorris | 29:f3b1387c81f1 | 72 | } |
thomasmorris | 29:f3b1387c81f1 | 73 | } |
thomasmorris | 29:f3b1387c81f1 | 74 | } |
thomasmorris | 29:f3b1387c81f1 | 75 | } |
JDickson | 27:22d6fd88828e | 76 | if(button_start.read() == 0) //This checks the Start/Stop button |
thomasmorris | 26:83550fc299aa | 77 | { |
thomasmorris | 26:83550fc299aa | 78 | printf("Start/Stop button read\n"); |
thomasmorris | 26:83550fc299aa | 79 | Thread::wait(Debounce_Time); |
thomasmorris | 26:83550fc299aa | 80 | if(button_start.read() == 1) |
thomasmorris | 26:83550fc299aa | 81 | { |
thomasmorris | 26:83550fc299aa | 82 | start_stop_thread.signal_set(1); |
thomasmorris | 26:83550fc299aa | 83 | } |
thomasmorris | 26:83550fc299aa | 84 | } |
JDickson | 27:22d6fd88828e | 85 | if(button_function.read() == 0) //This checks the Function button |
thomasmorris | 26:83550fc299aa | 86 | { |
thomasmorris | 26:83550fc299aa | 87 | printf("Function button read\n"); |
thomasmorris | 26:83550fc299aa | 88 | Thread::wait(Debounce_Time); |
thomasmorris | 26:83550fc299aa | 89 | if(button_function.read() == 1) |
thomasmorris | 26:83550fc299aa | 90 | { |
thomasmorris | 26:83550fc299aa | 91 | function_thread.signal_set(1); |
thomasmorris | 26:83550fc299aa | 92 | } |
thomasmorris | 26:83550fc299aa | 93 | } |
JDickson | 27:22d6fd88828e | 94 | if(button_select.read() == 0) //This checks the Select button |
thomasmorris | 26:83550fc299aa | 95 | { |
thomasmorris | 26:83550fc299aa | 96 | printf("Select button read\n"); |
thomasmorris | 26:83550fc299aa | 97 | Thread::wait(Debounce_Time); |
thomasmorris | 26:83550fc299aa | 98 | if(button_select.read() == 1) |
thomasmorris | 26:83550fc299aa | 99 | { |
thomasmorris | 26:83550fc299aa | 100 | select_thread.signal_set(1); |
thomasmorris | 26:83550fc299aa | 101 | } |
thomasmorris | 26:83550fc299aa | 102 | } |
thomasmorris | 29:f3b1387c81f1 | 103 | Thread::wait(50); |
thomasmorris | 26:83550fc299aa | 104 | } |
thomasmorris | 26:83550fc299aa | 105 | } |
JDickson | 27:22d6fd88828e | 106 | void LCD_thread() //Output data to the LCD for the interface |
JDickson | 27:22d6fd88828e | 107 | /* |
JDickson | 27:22d6fd88828e | 108 | This section of the code decides what data that should be sent to the LCD for each of the modes of the system. |
JDickson | 27:22d6fd88828e | 109 | */ |
thomasmorris | 26:83550fc299aa | 110 | { |
thomasmorris | 16:9f98ec0ededb | 111 | while(1) |
thomasmorris | 16:9f98ec0ededb | 112 | { |
thomasmorris | 17:68b3fdabe4c5 | 113 | lcd.cls();//Clear the LCD screen |
JDickson | 27:22d6fd88828e | 114 | if(INTERFACE.Get_Function() == 0)//Anneal Mode display |
thomasmorris | 25:9751619fa030 | 115 | { |
JDickson | 27:22d6fd88828e | 116 | lcd.printf("Mode: Anneal\n"); //Top LCD line when the device is annealing |
thomasmorris | 25:9751619fa030 | 117 | if(INTERFACE.Get_Select() == 0 || INTERFACE.Get_Select() == 1) |
thomasmorris | 25:9751619fa030 | 118 | { |
JDickson | 27:22d6fd88828e | 119 | lcd.printf("Loop:%d On_t:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_On_Time()); //When the On value is selected |
thomasmorris | 25:9751619fa030 | 120 | } |
thomasmorris | 25:9751619fa030 | 121 | else if(INTERFACE.Get_Select() == 2) |
thomasmorris | 25:9751619fa030 | 122 | { |
JDickson | 27:22d6fd88828e | 123 | lcd.printf("Loop:%d Offt:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); //When the Off value is selected |
thomasmorris | 25:9751619fa030 | 124 | } |
thomasmorris | 25:9751619fa030 | 125 | } |
JDickson | 27:22d6fd88828e | 126 | else if(INTERFACE.Get_Function() == 1)//Testing mode display |
thomasmorris | 25:9751619fa030 | 127 | { |
JDickson | 27:22d6fd88828e | 128 | lcd.printf("Mode: Test\n"); //Top LCD line when the device is Testing |
thomasmorris | 25:9751619fa030 | 129 | lcd.printf("Duty: %dTime: %d\n",INTERFACE.Get_Duty_Cycle(),INTERFACE.Get_Power_Time()); |
thomasmorris | 25:9751619fa030 | 130 | } |
thomasmorris | 25:9751619fa030 | 131 | else if(INTERFACE.Get_Function() == 2)//Coil |
thomasmorris | 16:9f98ec0ededb | 132 | { |
thomasmorris | 29:f3b1387c81f1 | 133 | if(INTERFACE.Get_Select() == 0) |
thomasmorris | 29:f3b1387c81f1 | 134 | { |
thomasmorris | 29:f3b1387c81f1 | 135 | lcd.printf("Mode: Coil\n"); //Top LCD line when the device is Coiling |
thomasmorris | 29:f3b1387c81f1 | 136 | lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do()); |
thomasmorris | 29:f3b1387c81f1 | 137 | } |
thomasmorris | 29:f3b1387c81f1 | 138 | else if(INTERFACE.Get_Select() == 1) |
thomasmorris | 29:f3b1387c81f1 | 139 | { |
thomasmorris | 29:f3b1387c81f1 | 140 | lcd.printf("Mode: Coil\n"); //Top LCD line when the device is Coiling |
thomasmorris | 29:f3b1387c81f1 | 141 | if(INTERFACE.Get_Direction() == 0)//Clockwise |
thomasmorris | 29:f3b1387c81f1 | 142 | { |
thomasmorris | 29:f3b1387c81f1 | 143 | lcd.printf("Dir: Clock\n"); |
thomasmorris | 29:f3b1387c81f1 | 144 | } |
thomasmorris | 29:f3b1387c81f1 | 145 | else if (INTERFACE.Get_Direction() == 1)//AntiClockwise |
thomasmorris | 29:f3b1387c81f1 | 146 | { |
thomasmorris | 29:f3b1387c81f1 | 147 | lcd.printf("Dir: AntiClock\n"); |
thomasmorris | 29:f3b1387c81f1 | 148 | } |
thomasmorris | 29:f3b1387c81f1 | 149 | } |
thomasmorris | 16:9f98ec0ededb | 150 | } |
thomasmorris | 25:9751619fa030 | 151 | else if(INTERFACE.Get_Function() == 3)//Twist |
thomasmorris | 16:9f98ec0ededb | 152 | { |
thomasmorris | 29:f3b1387c81f1 | 153 | if(INTERFACE.Get_Select() == 0) |
thomasmorris | 29:f3b1387c81f1 | 154 | { |
thomasmorris | 29:f3b1387c81f1 | 155 | lcd.printf("Mode: Twist\n"); //Top LCD line when the device is Twisting |
thomasmorris | 29:f3b1387c81f1 | 156 | lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do()); |
thomasmorris | 29:f3b1387c81f1 | 157 | } |
thomasmorris | 29:f3b1387c81f1 | 158 | else if(INTERFACE.Get_Select() == 1) |
thomasmorris | 29:f3b1387c81f1 | 159 | { |
thomasmorris | 29:f3b1387c81f1 | 160 | lcd.printf("Mode: Twist\n"); //Top LCD line when the device is Twisting |
thomasmorris | 29:f3b1387c81f1 | 161 | if(INTERFACE.Get_Direction() == 0)//Clockwise |
thomasmorris | 29:f3b1387c81f1 | 162 | { |
thomasmorris | 29:f3b1387c81f1 | 163 | lcd.printf("Dir: Clock\n"); |
thomasmorris | 29:f3b1387c81f1 | 164 | } |
thomasmorris | 29:f3b1387c81f1 | 165 | else if (INTERFACE.Get_Direction() == 1)//AntiClockwise |
thomasmorris | 29:f3b1387c81f1 | 166 | { |
thomasmorris | 29:f3b1387c81f1 | 167 | lcd.printf("Dir: AntiClock\n"); |
thomasmorris | 29:f3b1387c81f1 | 168 | } |
thomasmorris | 29:f3b1387c81f1 | 169 | } |
thomasmorris | 12:d9c133b360b0 | 170 | } |
thomasmorris | 29:f3b1387c81f1 | 171 | Thread::wait(100);//Refresh rate for Lcd |
thomasmorris | 12:d9c133b360b0 | 172 | } |
thomasmorris | 12:d9c133b360b0 | 173 | } |
thomasmorris | 17:68b3fdabe4c5 | 174 | void LED_thread(){//Led thread to toggle the on board led to show the CPU is running |
thomasmorris | 16:9f98ec0ededb | 175 | while (1) |
thomasmorris | 16:9f98ec0ededb | 176 | { |
thomasmorris | 17:68b3fdabe4c5 | 177 | led2 = !led2; //Toggle the LED |
thomasmorris | 17:68b3fdabe4c5 | 178 | Thread::wait(1000);//Wait 1 second |
emilmont | 1:491820ee784d | 179 | } |
emilmont | 1:491820ee784d | 180 | } |
thomasmorris | 12:d9c133b360b0 | 181 | //Interrupt functions |
thomasmorris | 16:9f98ec0ededb | 182 | void up_thread_function()//Action if the up button is pressed increment |
thomasmorris | 16:9f98ec0ededb | 183 | { |
thomasmorris | 14:63998be3d43c | 184 | while(1) |
thomasmorris | 14:63998be3d43c | 185 | { |
thomasmorris | 29:f3b1387c81f1 | 186 | |
thomasmorris | 25:9751619fa030 | 187 | Thread::signal_wait(1); //Wait to be signaled by the up button interrupt |
thomasmorris | 26:83550fc299aa | 188 | pc.printf("Up Button Pressed in thread function\n");//Output data to the putty terminal |
thomasmorris | 26:83550fc299aa | 189 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runs this debouce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 190 | up_thread.signal_set(0); //Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 191 | pc.printf("Up Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 29:f3b1387c81f1 | 192 | |
thomasmorris | 28:3193157ebb0c | 193 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 194 | { |
thomasmorris | 29:f3b1387c81f1 | 195 | INTERFACE.Up(); //Run the interface up routine |
thomasmorris | 28:3193157ebb0c | 196 | } |
thomasmorris | 14:63998be3d43c | 197 | } |
thomasmorris | 14:63998be3d43c | 198 | } |
thomasmorris | 16:9f98ec0ededb | 199 | void down_thread_function() //Action if the down button is pressed decrement |
thomasmorris | 16:9f98ec0ededb | 200 | { |
thomasmorris | 14:63998be3d43c | 201 | while(1) |
thomasmorris | 14:63998be3d43c | 202 | { |
thomasmorris | 26:83550fc299aa | 203 | Thread::signal_wait(1); //Wait to be signaled by the down button interrupt |
thomasmorris | 26:83550fc299aa | 204 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 205 | down_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 206 | pc.printf("Down Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 28:3193157ebb0c | 207 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 208 | { |
thomasmorris | 29:f3b1387c81f1 | 209 | INTERFACE.Down();//Run the interface down routine |
thomasmorris | 28:3193157ebb0c | 210 | } |
thomasmorris | 12:d9c133b360b0 | 211 | } |
thomasmorris | 12:d9c133b360b0 | 212 | } |
thomasmorris | 16:9f98ec0ededb | 213 | void start_stop_thread_function() //Action if the Start/Stop button is pressed |
thomasmorris | 16:9f98ec0ededb | 214 | { |
thomasmorris | 14:63998be3d43c | 215 | while(1) |
thomasmorris | 14:63998be3d43c | 216 | { |
thomasmorris | 26:83550fc299aa | 217 | Thread::signal_wait(1); //Wait to be signaled by the start / stop button interrupt |
thomasmorris | 26:83550fc299aa | 218 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 219 | start_stop_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 220 | pc.printf("S/S Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 17:68b3fdabe4c5 | 221 | INTERFACE.Start_Stop();//Run the interface start / stop routine |
thomasmorris | 14:63998be3d43c | 222 | } |
thomasmorris | 14:63998be3d43c | 223 | } |
thomasmorris | 16:9f98ec0ededb | 224 | void Function_Selection_thread_function()//Action if the Function button is pressed |
thomasmorris | 16:9f98ec0ededb | 225 | { |
thomasmorris | 14:63998be3d43c | 226 | while(1) |
thomasmorris | 14:63998be3d43c | 227 | { |
thomasmorris | 26:83550fc299aa | 228 | Thread::signal_wait(1); //Wait to be signaled by the function button interrupt |
thomasmorris | 26:83550fc299aa | 229 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 230 | function_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 231 | pc.printf("Function Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 28:3193157ebb0c | 232 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 233 | { |
thomasmorris | 28:3193157ebb0c | 234 | INTERFACE.Function();//Run the interface function routine |
thomasmorris | 28:3193157ebb0c | 235 | } |
emilmont | 1:491820ee784d | 236 | } |
emilmont | 1:491820ee784d | 237 | } |
thomasmorris | 16:9f98ec0ededb | 238 | void Selection_thread_function()//Action if the Select button is pressed |
thomasmorris | 16:9f98ec0ededb | 239 | { |
thomasmorris | 14:63998be3d43c | 240 | while(1) |
thomasmorris | 14:63998be3d43c | 241 | { |
thomasmorris | 26:83550fc299aa | 242 | Thread::signal_wait(1); //Wait to be signaled by the select button interrupt |
thomasmorris | 26:83550fc299aa | 243 | Thread::wait(Debounce_Time); //Button debounce to prevent multiple re-runsn this debounce time might need to be longer |
thomasmorris | 17:68b3fdabe4c5 | 244 | select_thread.signal_set(0);//Set the thread signal low to wait for the interrupt before reaccuring |
thomasmorris | 17:68b3fdabe4c5 | 245 | pc.printf("Select Button Pressed\n");//Output data to the putty terminal |
thomasmorris | 28:3193157ebb0c | 246 | if(INTERFACE.Get_System_Running() == 0) |
thomasmorris | 28:3193157ebb0c | 247 | { |
thomasmorris | 28:3193157ebb0c | 248 | INTERFACE.Select();//Run the interface selection routine |
thomasmorris | 28:3193157ebb0c | 249 | } |
thomasmorris | 14:63998be3d43c | 250 | } |
thomasmorris | 12:d9c133b360b0 | 251 | } |
thomasmorris | 12:d9c133b360b0 | 252 | int main() |
thomasmorris | 28:3193157ebb0c | 253 | { |
thomasmorris | 17:68b3fdabe4c5 | 254 | lcd.printf("Ready Player\n"); |
thomasmorris | 17:68b3fdabe4c5 | 255 | lcd.printf(" One \n"); |
thomasmorris | 17:68b3fdabe4c5 | 256 | Thread::wait(1000); |
thomasmorris | 17:68b3fdabe4c5 | 257 | pc.printf("Program start\n");//Outputs informtation to the putty terminal |
thomasmorris | 14:63998be3d43c | 258 | |
JDickson | 27:22d6fd88828e | 259 | //Thread Initialisation |
thomasmorris | 26:83550fc299aa | 260 | polling_thread.start(Polling_thread_function);//Start the button polling |
thomasmorris | 17:68b3fdabe4c5 | 261 | lcd_thread.start(LCD_thread);//Output data to LCD |
thomasmorris | 17:68b3fdabe4c5 | 262 | led_thread.start(LED_thread);//Blinking led to show CPU running |
thomasmorris | 17:68b3fdabe4c5 | 263 | up_thread.start(up_thread_function);//UP interface thread |
thomasmorris | 17:68b3fdabe4c5 | 264 | down_thread.start(down_thread_function);//Down interface thread |
thomasmorris | 17:68b3fdabe4c5 | 265 | start_stop_thread.start(start_stop_thread_function);//Start / stop interface thread |
thomasmorris | 17:68b3fdabe4c5 | 266 | function_thread.start(Function_Selection_thread_function);//Function interface thread |
thomasmorris | 17:68b3fdabe4c5 | 267 | select_thread.start(Selection_thread_function);//Start interface thread |
mwthewsey | 19:384642f39496 | 268 | |
thomasmorris | 23:07a368f2cdb1 | 269 | 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 |
thomasmorris | 29:f3b1387c81f1 | 270 | INTERFACE.Interface_Init(80,2);//Pass in turns first then the type of rig second 2 for coiling 3 for twisting |
thomasmorris | 17:68b3fdabe4c5 | 271 | while(1)// Main code in a main thread |
thomasmorris | 12:d9c133b360b0 | 272 | { |
thomasmorris | 17:68b3fdabe4c5 | 273 | INTERFACE.Interface_main();//Run main thread code |
mwthewsey | 19:384642f39496 | 274 | Thread::wait(10);//Small delay to save CPU time |
thomasmorris | 16:9f98ec0ededb | 275 | } |
thomasmorris | 12:d9c133b360b0 | 276 | } |