Lidar
Dependencies: TS_DISCO_F746NG mbed BufferedSerial LCD_DISCO_F746NG mbed-rtos Trigo BSP_DISCO_F746NG
Diff: Main.cpp
- Revision:
- 4:0df95765b1b0
- Parent:
- 3:43ab856b5efa
- Child:
- 5:734551a9f4e7
--- a/Main.cpp Thu Nov 24 09:50:36 2016 +0000 +++ b/Main.cpp Thu Nov 24 11:50:42 2016 +0000 @@ -1,4 +1,5 @@ #include "mbed.h" +#include "rtos.h" #include "Serial.h" #include "BufferedSerial.h" #include "Communication.h" @@ -10,8 +11,7 @@ //Dichiarazione oggetti -//DigitalIn myStartButton(USER_BUTTON); -InterruptIn myStopButton(USER_BUTTON); +DigitalIn myStopButton(USER_BUTTON); Motor lid_Motor(PWM_OUT); Communication SendCommands; LCD_DISCO_F746NG lcd; @@ -22,15 +22,23 @@ uint8_t idx; uint8_t start=1; -void pressed() -{ - SendCommands.Stop(); - wait_ms(100); - lid_Motor.StopMotor_Scan(); +void button_thread(void const *args) { + while(true) { + if (myStopButton == 1) { + SendCommands.Stop(); + wait_ms(10); + lid_Motor.StopMotor_Scan(); + wait_ms(10); + SendCommands.Reset(); + } + } } int main() { +// Threads start here + Thread button_th(button_thread); + // Initialize Display lcd.Clear(LCD_COLOR_BLACK); lcd.SetBackColor(LCD_COLOR_BLACK); @@ -86,28 +94,7 @@ } } } - - //while(1) { -// if (myStartButton == 1) { -// SendCommands.Stop(); -// wait_ms(100); -// lid_Motor.StopMotor_Scan(); -// } -// } - - //while(1) { -// myStopButton.rise(&pressed); -// } - - //while(1) { -// // Initialize TFT display -// ts.GetState(&TS_State); -// if (TS_State.touchDetected) { -// SendCommands.Stop(); -// wait_ms(100); -// lid_Motor.StopMotor_Scan(); -// } -// } + }