Thread and State machine
Posted: Wed Feb 02, 2011 10:18 am
Hi,
I have some question
My application is Displayed OBD Data, On my board I have LCD, Switch, and communicate with OBD Reader via UART
So I have create 3 thread + main thread
1st thread is scan for 4 switches
2nd thread handle UART Communication
3rd thread is Display data on LCD 16x2
and in main thread I put state machine
in my state machine has 3 main state
1 Display OBD Data State
2 Menu State
3 Init State
problem is when I press OK switch in Display OBD Data State I want to go to Menu state
Thread switch get switch but in main thread I have to wait for display state to finish and then I can go to Menu State this take sometime and user feel that switch is slow response.
I have no idea at the moment how to solve this
I think about Create and Terminate thread instead of state machine for example
When Program Start I create Init thread
when Init finish terminate Init Thread and create Display OBD Data Thread
when Switch Ok (Go for menu) press -> terminate Display thread Create Menu Thread
when return from menu -> terminate Menu thread and create Display Thread
is this will work or should I use another method?
Thank you
Saran
I have some question
My application is Displayed OBD Data, On my board I have LCD, Switch, and communicate with OBD Reader via UART
So I have create 3 thread + main thread
1st thread is scan for 4 switches
2nd thread handle UART Communication
3rd thread is Display data on LCD 16x2
and in main thread I put state machine
in my state machine has 3 main state
1 Display OBD Data State
2 Menu State
3 Init State
problem is when I press OK switch in Display OBD Data State I want to go to Menu state
Thread switch get switch but in main thread I have to wait for display state to finish and then I can go to Menu State this take sometime and user feel that switch is slow response.
I have no idea at the moment how to solve this
I think about Create and Terminate thread instead of state machine for example
When Program Start I create Init thread
when Init finish terminate Init Thread and create Display OBD Data Thread
when Switch Ok (Go for menu) press -> terminate Display thread Create Menu Thread
when return from menu -> terminate Menu thread and create Display Thread
is this will work or should I use another method?
Thank you
Saran