Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HCSR04new SSH1106-alan
Thread_Handle.cpp
00001 #include "mbed.h" 00002 #include "platform/mbed_thread.h" 00003 #include "Thread_Handle.h" 00004 #include "HCSR04.h" 00005 #include "main.h" 00006 #include "handleTasks.h" 00007 #include "rtc.h" 00008 #include "SSH1106.h" 00009 00010 Thread sensor_thread0; 00011 Thread sensor_thread1; 00012 Thread RTC_thread; 00013 Thread sensor_capture_thread; 00014 Thread oled_thread; 00015 Thread time_thread; 00016 //Thread realTime_thread; 00017 00018 int Q=1; 00019 //void time_record_thread(void) 00020 //{ 00021 // while(true) { 00022 // ssh1106.writeTim_format(10,6, font_5x8,p_tm->tm_hour); 00023 // ssh1106.writeTim_format(60,6, font_5x8,p_tm->tm_min); 00024 // ssh1106.writeTim_format(120,6, font_5x8,p_tm->tm_sec); 00025 // thread_sleep_for(1000); 00026 // } 00027 // 00028 //} 00029 void time_check_thread(void) 00030 { 00031 while(true) { 00032 Q++; 00033 //printf("%d \n\n",Q); 00034 thread_sleep_for(1000); 00035 } 00036 } 00037 00038 //Usensor dist 0-- blue line 00039 void dist0_thread(void) 00040 { 00041 while(true) { 00042 //printf("dist0 = %d \n\n", capteur0.measDist()); 00043 Usensor0.dist = capteur0.measDist(); 00044 thread_sleep_for(10); 00045 } 00046 } 00047 //Usensor dist 1 00048 void dist1_thread(void) 00049 { 00050 while(true) { 00051 //printf("dist1 = %d \n\n", capteur1.measDist()); 00052 Usensor1.dist = capteur1.measDist(); 00053 thread_sleep_for(10); 00054 } 00055 } 00056 //Display car number 00057 00058 void OLED_refresh_thread() 00059 { 00060 int n=1; 00061 char str[40]; 00062 while(true) { 00063 ssh1106.writeText_format(0,1, font_5x8,"Car num:"); 00064 ssh1106.writeDec_format(55,1, font_5x8,carNum ); 00065 n = sprintf(str, "%d",Q); 00066 ssh1106.writeText(0,6, font_5x8,str,n); 00067 00068 00069 oled_carStateDisplay(); 00070 thread_sleep_for(1); 00071 } 00072 } 00073 //display car state 00074 void capture_sensor_thread() 00075 { 00076 while(true) { 00077 carState_check_in(); 00078 display_carState_in(); 00079 //printf("dist1 = %d ",Usensor1.dist); 00080 carState_check_out(); 00081 display_carState_out(); 00082 countCarnum(); 00083 carState = nothing; 00084 usensor_paraClear(); 00085 thread_sleep_for(10); 00086 } 00087 } 00088 //RTC 00089 void RTC_display_thread(void) 00090 { 00091 while(true) { 00092 RTC_display(); 00093 thread_sleep_for(1000); 00094 } 00095 } 00096 00097 void init_thread(void) 00098 { 00099 while(true) { 00100 //clear param 00101 usensor_paraInit(); 00102 00103 //OLED init 00104 ssh1106.init(); 00105 thread_sleep_for(100); 00106 ssh1106.clear(); 00107 oled_thread.start(OLED_refresh_thread); 00108 time_thread.start(time_check_thread); 00109 //realTime_thread.start(time_record_thread); 00110 //RTC 00111 RTC_INIT(); 00112 RTC_thread.start(RTC_display_thread); 00113 00114 //thread0 for Usensor0 00115 sensor_thread0.start(dist0_thread); 00116 sensor_capture_thread.start(capture_sensor_thread); 00117 00118 //thread1 for Usensor1 00119 sensor_thread1.start(dist1_thread); 00120 00121 init_start_thread.terminate();// thread gang up 00122 } 00123 }
Generated on Wed Jul 27 2022 08:19:38 by
