Руслан Бредун
/
stm32-sensor-base2
test
Diff: main.cpp
- Revision:
- 7:2f218add711e
- Parent:
- 6:a760ce6defbe
- Child:
- 8:c3cffab85b0d
--- a/main.cpp Wed Jul 22 08:31:28 2020 +0000 +++ b/main.cpp Thu Jul 23 11:34:08 2020 +0000 @@ -1,9 +1,9 @@ #include <global.h> -Serial pc(UART1_TX, UART1_RX); +//Serial pc(UART1_TX, UART1_RX); RS485 RS485(UART2_TX,UART2_RX,DE_TXD_2); // Tx, Rx , !RE and DE MAX485 pin -//Serial pc(USBTX, USBRX); +Serial pc(USBTX, USBRX); Timer timer; typedef uint8_t byte; @@ -106,35 +106,23 @@ JSN_SR04 sensor1(TIM1_CH2, TRIG_PA8_OUT); E18_D80NK infared1 (IR1_PB12_OUT); E18_D80NK infared2 (IR2_PB13_OUT); + pc.baud(115200); - sensor1.setRanges(30, 200); - //full_value[0] = base_data[0] -// full_value[1] = base_data[1] -// full_value[2] = base_data[2] -// full_value[3] = base_data[3] -// full_value[4] = base_data[4] + sensor1.setRanges(10, 200); while(true) { timer.reset(); timer.start(); sensor1.startMeasurement(); - pc.printf("Distance1: %5.1f mm ----- %d ---- %d \r\n", sensor1.getDistance_cm() , infared1.checkObstacle(),infared2.checkObstacle()); - - //full_value[5] = base_data -// full_value[6] = base_data -// full_value[7] = base_data -// full_value[8] = base_data + //while (sensor1.isNewDataReady() == false && timer.read_ms() < time_to_check_us) { + //pc.printf("Distance1: %5.1f mm -- Distance2: %5.1f mm -- -- Distance3: %5.1f mm \r\n", sensor1.getDistance_cm()), sensor2.getDistance_cm(), sensor3.getDistance_cm()); + pc.printf("%5.1f_%d_%d \r\n", sensor1.getDistance_cm(),infared1.checkObstacle(),infared2.checkObstacle()); - sprintf(test_buffer, "%5.1f_%d_%d ", sensor1.getDistance_cm() , infared1.checkObstacle(),infared2.checkObstacle()); - - select = 1 ; // Enable sending on MAX485 - RS485.sendMsg(data,sizeof(data)); - wait_ms(100); - select = 0 ; // Enable receiving on MAX485 timer.stop(); - wait_ms(2); + wait_ms(20); } + #endif