V4
Dependencies: BMP280
Fork of Thread_Communication_V3 by
Diff: main.cpp
- Revision:
- 4:93d6d13d4de3
- Parent:
- 3:73497379c0cb
- Child:
- 5:ea3ec65cbf5f
--- a/main.cpp Thu Dec 14 19:23:45 2017 +0000 +++ b/main.cpp Thu Dec 14 20:02:48 2017 +0000 @@ -1,6 +1,8 @@ #include "mbed.h" #include "main.h" +#define ENTER_KEY 1 + LCD lcd(PD_15, PF_12, PF_13, PE_9, PF_14, PF_15); BMP280 Sensor(D14, D15); @@ -12,7 +14,6 @@ //Serial_CMD volatile int rx_in=0; char rx_line[80]; -int s_cmd = 0; //Time date time_t raw_time = time(NULL); @@ -122,6 +123,7 @@ /*--------------------------------------------------------------------*/ /*------------------------------SERIAL_CMD----------------------------*/ +//Interrupt when recieving from serial port void Rx_interrupt() { while (pc.readable()) { @@ -129,7 +131,7 @@ pc.putc(rx_line[rx_in]); if(rx_line[rx_in] == 0xD){ - s_cmd = 1; + S_CMD.signal_set(ENTER_KEY); } else{ rx_in = (rx_in + 1); @@ -137,10 +139,11 @@ } } +//Check what command what recieved and execute void Serial_CMD(){ while(1){ - if(s_cmd == 1){ + Thread::signal_wait(ENTER_KEY); pc.attach(NULL, Serial::RxIrq); struct tm * s_time; @@ -219,9 +222,6 @@ rx_in = 0; pc.attach(&Rx_interrupt, Serial::RxIrq); - s_cmd = 0; - } - Thread::wait(5); } } /*--------------------------------------------------------------------*/ \ No newline at end of file