获取海拔高度

This commit is contained in:
AIR 2023-06-25 20:59:35 +08:00
parent 3c16559578
commit 8e8ee21a5f

View File

@ -20,11 +20,11 @@ FoodCube fc(ssid, password, mqttServer, mqttPort, mqttName, mqttPassword, mavlin
String topicSub[] = { "questAss", "setPlaneState", "getPlaneState", "resetState", "chan1", "chan2", "chan3", "chan4", "hookConteroller", "cameraController" }; //订阅主题 String topicSub[] = { "questAss", "setPlaneState", "getPlaneState", "resetState", "chan1", "chan2", "chan3", "chan4", "hookConteroller", "cameraController" }; //订阅主题
int topicSubCount = sizeof(topicSub) / sizeof(topicSub[0]); //订阅主题总数 int topicSubCount = sizeof(topicSub) / sizeof(topicSub[0]); //订阅主题总数
/*有更新主动发送 主题*/ /*有更新主动发送 主题*/
//0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:高度信息 5:对地速度 6:卫星数量 7:纬度 8:经度 9:定位状态 10:飞机状态 11:网速测试 12:飞机模式 //0:心跳信息 1:电压信息 2:电流信息 3:电池电量 4:高度信息 5:对地速度 6:卫星数量 7:纬度 8:经度 9:定位状态 10:飞机状态 11:网速测试 12:飞机模式 13:重量 14:钩子状态 15:飞机海拔高度
String topicPub[] = { "heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "latitude", "longitude", "fixType", "planeState", "pingNet", "getPlaneMode" }; String topicPub[] = { "heartBeat", "voltagBattery", "currentBattery", "batteryRemaining", "positionAlt", "groundSpeed", "satCount", "latitude", "longitude", "fixType", "planeState", "pingNet", "getPlaneMode","loadweight","hookstatus","altitude" };
int topicPubCount = sizeof(topicPub) / sizeof(topicPub[0]); //发送主题总数 int topicPubCount = sizeof(topicPub) / sizeof(topicPub[0]);  //发送主题总数
String topicPubMsg[13]; //发送数据存放 对应topicPub String topicPubMsg[16];                                      //发送数据存放 对应topicPub
String oldMsg[13]; //记录旧的数据 用来对比有没有更新 String oldMsg[16];                                           //记录旧的数据 用来对比有没有更新
/*触发发送 主题*/ /*触发发送 主题*/
//0:对频信息 //0:对频信息
String topicHandle[] = { "crosFrequency" }; String topicHandle[] = { "crosFrequency" };
@ -381,6 +381,11 @@ void mavlink_receiveCallback(uint8_t c) {
if (topicPubMsg[4] != buf) { if (topicPubMsg[4] != buf) {
topicPubMsg[4] = buf; topicPubMsg[4] = buf;
} }
//海拔高度
sprintf(buf, "%.2f", (double)global_position_int.alt / 1000);
if (topicPubMsg[15] != buf) {
topicPubMsg[15] = buf;
}
} }
break; break;