main
This commit is contained in:
@ -62,7 +62,8 @@ void onReceiveEvent(int bytes) {
|
||||
static uint8_t last_receive_cnt = 0;
|
||||
void update_sensor_data() {
|
||||
//gps
|
||||
if (millis() > 5000 && gps.charsProcessed() < 10 && digitalRead(GPS_POWER_PIN) == HIGH) {
|
||||
//if (millis() > 5000 && gps.charsProcessed() < 10 && digitalRead(GPS_POWER_PIN) == HIGH)
|
||||
if (millis() > 5000 && gps.charsProcessed() < 10) {
|
||||
sensor_data.gps_sta = 0x00; // 无设备
|
||||
sensor_data.gps_lat = 0.0f;
|
||||
sensor_data.gps_lon = 0.0f;
|
||||
@ -81,7 +82,8 @@ void update_sensor_data() {
|
||||
}
|
||||
|
||||
//测距
|
||||
if (receive_cnt == last_receive_cnt && digitalRead(RANGING_POWER_PIN) == HIGH) {
|
||||
//if (receive_cnt == last_receive_cnt && digitalRead(RANGING_POWER_PIN) == HIGH)
|
||||
if (receive_cnt == last_receive_cnt){
|
||||
sensor_data.height_sta = 0x00; // 无设备
|
||||
sensor_data.height = 0.0f;
|
||||
}else if (digitalRead(RANGING_POWER_PIN) == LOW){
|
||||
|
||||
@ -13,13 +13,14 @@
|
||||
|
||||
// 数据结构定义
|
||||
typedef struct {
|
||||
uint8_t gps_sta; // 0x00 ~ 0x03
|
||||
uint8_t height_sta; // 0x00 ~ 0x01
|
||||
float gps_lat;
|
||||
float gps_lon;
|
||||
float height;
|
||||
uint8_t gps_sta; // 0x00 ~ 0x03 ////0x00没有设备,0x01关机,0x02没有搜到gps,0x03搜到gps
|
||||
uint8_t height_sta; // 0x00 ~ 0x01 ////0x00没有设备,0x01关机
|
||||
float gps_lat; //没有设备返回0
|
||||
float gps_lon; //没有设备返回0
|
||||
float height; //没有设备返回0
|
||||
} hh3_slave_data;
|
||||
|
||||
//03 03 00 00 C4 79 09 42 2E B1 D9 42 E3 A5 9B 3C
|
||||
//00 00 由编译器自动插入的内存对齐填充字节,用于确保后续的 float 类型字段(如 gps_lat)能够正确地按照 4 字节对齐存储在内存中。
|
||||
extern hh3_slave_data sensor_data;
|
||||
|
||||
// 函数声明
|
||||
|
||||
Reference in New Issue
Block a user