添加485获取特定命令或者命令加参数的形式
This commit is contained in:
parent
f5a936e022
commit
0a85320c68
@ -5,8 +5,8 @@ project(xlsw_3dp_ultrasonic_300K)
|
||||
|
||||
set(POWER_VOLTAGE "12V")
|
||||
set(VERSION_MAJOR 0)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_PATCH 13)
|
||||
set(VERSION_MINOR 1)
|
||||
set(VERSION_PATCH 14)
|
||||
set(VERSION "V${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#endif
|
||||
|
||||
#define ULTRASONIC_CYCLES 0x05U
|
||||
#define ULTRASONIC_TRAN_US 998 // (ms)
|
||||
#define ULTRASONIC_TRAN_US 498 // (ms)
|
||||
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_9
|
||||
|
23
src/main.c
23
src/main.c
@ -14,7 +14,8 @@
|
||||
#include "mlx90614.h"
|
||||
|
||||
extern uint32_t g_capture_value;
|
||||
uint16_t distance_uint16;
|
||||
uint16_t g_distance_uint16;
|
||||
uint16_t g_temperature_uint16;
|
||||
|
||||
/*!
|
||||
\brief main function
|
||||
@ -40,7 +41,7 @@ int main(void)
|
||||
/* ---------- debug end ---------- */
|
||||
|
||||
printf("\r\n");
|
||||
printf("XLSW-3DP-UltraSonic Analog 300K!\r\n");
|
||||
printf("XLSW-3DP-UltraSonic Analog 300K! V0.1.14\r\n");
|
||||
printf("\r\n");
|
||||
|
||||
delay_ms(2000);
|
||||
@ -48,17 +49,19 @@ int main(void)
|
||||
while (1)
|
||||
{
|
||||
delay_ms(ULTRASONIC_TRAN_US);
|
||||
|
||||
UltraSonic_PwmOut_Cycles(ULTRASONIC_CYCLES);
|
||||
|
||||
delay_ms(2);
|
||||
printf("cap_val:%ld\t", g_capture_value);
|
||||
// printf("cap_val:%ld\t", g_capture_value);
|
||||
// const char* result = (g_capture_value <= CAPTURE_VALUE_MAX) ? "Distance: %d\t" : "Over Range\t";
|
||||
if (g_capture_value <= CAPTURE_VALUE_MAX) {
|
||||
g_distance_uint16 = UltraSonic_CalcDistance(g_capture_value);
|
||||
} else {
|
||||
g_distance_uint16 = 0x0000;
|
||||
}
|
||||
// printf(result, distance_uint16);
|
||||
|
||||
const char* result = (g_capture_value <= CAPTURE_VALUE_MAX) ? "Distance: %d\t" : "Over Range\t";
|
||||
distance_uint16 = UltraSonic_CalcDistance(g_capture_value);
|
||||
printf(result, distance_uint16);
|
||||
|
||||
printf("Temp:%d\n", MLX90614_GetObjectTemperature());
|
||||
// printf("Temp:%d\n", MLX90614_GetObjectTemperature());
|
||||
g_temperature_uint16 = MLX90614_GetObjectTemperature();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user