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/Thread_Handle.cpp
- Committer:
- alanchip
- Date:
- 2021-03-08
- Revision:
- 2:1baa0bd2fde0
- Child:
- 3:17acfeba3730
File content as of revision 2:1baa0bd2fde0:
#include "mbed.h"
#include "platform/mbed_thread.h"
#include "Thread_Handle.h"
#include "HCSR04.h"
#include "main.h"
#include "handleTasks.h"
#include "rtc.h"
#include "SSH1106.h"
Thread sensor_thread0;
Thread sensor_thread1;
Thread RTC_thread;
Thread sensor_capture_thread;
Thread oled_thread;
//Usensor dist 0-- blue line
void dist0_thread(void)
{
while(true) {
//printf("dist0 = %d \n\n", capteur0.measDist());
Usensor0.dist = capteur0.measDist();
thread_sleep_for(10);
}
}
//Usensor dist 1
void dist1_thread(void)
{
while(true) {
//printf("dist1 = %d \n\n", capteur1.measDist());
Usensor1.dist = capteur1.measDist();
thread_sleep_for(10);
}
}
//Display car number
void OLED_refresh_thread()
{
while(true) {
ssh1106.writeText_format(0,1, font_5x8,"Car num:");
ssh1106.writeDec_format(55,1, font_5x8,carNum );
oled_carStateDisplay();
thread_sleep_for(1);
}
}
//display car state
void capture_sensor_thread()
{
while(true) {
carState_check_in();
display_carState_in();
//printf("dist1 = %d ",Usensor1.dist);
carState_check_out();
display_carState_out();
countCarnum();
carState = nothing;
usensor_paraClear();
thread_sleep_for(10);
}
}
//RTC
void RTC_display_thread(void)
{
while(true) {
RTC_display();
thread_sleep_for(1000);
}
}
void init_thread(void)
{
while(true) {
//clear param
usensor_paraInit();
//OLED init
ssh1106.init();
thread_sleep_for(100);
ssh1106.clear();
oled_thread.start(OLED_refresh_thread);
//RTC
RTC_INIT();
RTC_thread.start(RTC_display_thread);
//thread0 for Usensor0
sensor_thread0.start(dist0_thread);
sensor_capture_thread.start(capture_sensor_thread);
//thread1 for Usensor1
sensor_thread1.start(dist1_thread);
init_start_thread.terminate();// thread gang up
}
}