You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

338 lines
13 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE VFR_HUD PACKING
  3. #define MAVLINK_MSG_ID_VFR_HUD 74
  4. MAVPACKED(
  5. typedef struct __mavlink_vfr_hud_t {
  6. float airspeed; /*< [m/s] Current indicated airspeed (IAS).*/
  7. float groundspeed; /*< [m/s] Current ground speed.*/
  8. float alt; /*< [m] Current altitude (MSL).*/
  9. float climb; /*< [m/s] Current climb rate.*/
  10. int16_t heading; /*< [deg] Current heading in compass units (0-360, 0=north).*/
  11. uint16_t throttle; /*< [%] Current throttle setting (0 to 100).*/
  12. }) mavlink_vfr_hud_t;
  13. #define MAVLINK_MSG_ID_VFR_HUD_LEN 20
  14. #define MAVLINK_MSG_ID_VFR_HUD_MIN_LEN 20
  15. #define MAVLINK_MSG_ID_74_LEN 20
  16. #define MAVLINK_MSG_ID_74_MIN_LEN 20
  17. #define MAVLINK_MSG_ID_VFR_HUD_CRC 20
  18. #define MAVLINK_MSG_ID_74_CRC 20
  19. #if MAVLINK_COMMAND_24BIT
  20. #define MAVLINK_MESSAGE_INFO_VFR_HUD { \
  21. 74, \
  22. "VFR_HUD", \
  23. 6, \
  24. { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
  25. { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
  26. { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
  27. { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
  28. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
  29. { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
  30. } \
  31. }
  32. #else
  33. #define MAVLINK_MESSAGE_INFO_VFR_HUD { \
  34. "VFR_HUD", \
  35. 6, \
  36. { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
  37. { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
  38. { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
  39. { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
  40. { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) }, \
  41. { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) }, \
  42. } \
  43. }
  44. #endif
  45. /**
  46. * @brief Pack a vfr_hud message
  47. * @param system_id ID of this system
  48. * @param component_id ID of this component (e.g. 200 for IMU)
  49. * @param msg The MAVLink message to compress the data into
  50. *
  51. * @param airspeed [m/s] Current indicated airspeed (IAS).
  52. * @param groundspeed [m/s] Current ground speed.
  53. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  54. * @param throttle [%] Current throttle setting (0 to 100).
  55. * @param alt [m] Current altitude (MSL).
  56. * @param climb [m/s] Current climb rate.
  57. * @return length of the message in bytes (excluding serial stream start sign)
  58. */
  59. static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  60. float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  61. {
  62. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  63. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  64. _mav_put_float(buf, 0, airspeed);
  65. _mav_put_float(buf, 4, groundspeed);
  66. _mav_put_float(buf, 8, alt);
  67. _mav_put_float(buf, 12, climb);
  68. _mav_put_int16_t(buf, 16, heading);
  69. _mav_put_uint16_t(buf, 18, throttle);
  70. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
  71. #else
  72. mavlink_vfr_hud_t packet;
  73. packet.airspeed = airspeed;
  74. packet.groundspeed = groundspeed;
  75. packet.alt = alt;
  76. packet.climb = climb;
  77. packet.heading = heading;
  78. packet.throttle = throttle;
  79. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
  80. #endif
  81. msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
  82. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  83. }
  84. /**
  85. * @brief Pack a vfr_hud message on a channel
  86. * @param system_id ID of this system
  87. * @param component_id ID of this component (e.g. 200 for IMU)
  88. * @param chan The MAVLink channel this message will be sent over
  89. * @param msg The MAVLink message to compress the data into
  90. * @param airspeed [m/s] Current indicated airspeed (IAS).
  91. * @param groundspeed [m/s] Current ground speed.
  92. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  93. * @param throttle [%] Current throttle setting (0 to 100).
  94. * @param alt [m] Current altitude (MSL).
  95. * @param climb [m/s] Current climb rate.
  96. * @return length of the message in bytes (excluding serial stream start sign)
  97. */
  98. static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  99. mavlink_message_t* msg,
  100. float airspeed,float groundspeed,int16_t heading,uint16_t throttle,float alt,float climb)
  101. {
  102. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  103. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  104. _mav_put_float(buf, 0, airspeed);
  105. _mav_put_float(buf, 4, groundspeed);
  106. _mav_put_float(buf, 8, alt);
  107. _mav_put_float(buf, 12, climb);
  108. _mav_put_int16_t(buf, 16, heading);
  109. _mav_put_uint16_t(buf, 18, throttle);
  110. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
  111. #else
  112. mavlink_vfr_hud_t packet;
  113. packet.airspeed = airspeed;
  114. packet.groundspeed = groundspeed;
  115. packet.alt = alt;
  116. packet.climb = climb;
  117. packet.heading = heading;
  118. packet.throttle = throttle;
  119. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
  120. #endif
  121. msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
  122. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  123. }
  124. /**
  125. * @brief Encode a vfr_hud struct
  126. *
  127. * @param system_id ID of this system
  128. * @param component_id ID of this component (e.g. 200 for IMU)
  129. * @param msg The MAVLink message to compress the data into
  130. * @param vfr_hud C-struct to read the message contents from
  131. */
  132. static inline uint16_t mavlink_msg_vfr_hud_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
  133. {
  134. return mavlink_msg_vfr_hud_pack(system_id, component_id, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  135. }
  136. /**
  137. * @brief Encode a vfr_hud struct on a channel
  138. *
  139. * @param system_id ID of this system
  140. * @param component_id ID of this component (e.g. 200 for IMU)
  141. * @param chan The MAVLink channel this message will be sent over
  142. * @param msg The MAVLink message to compress the data into
  143. * @param vfr_hud C-struct to read the message contents from
  144. */
  145. static inline uint16_t mavlink_msg_vfr_hud_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
  146. {
  147. return mavlink_msg_vfr_hud_pack_chan(system_id, component_id, chan, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  148. }
  149. /**
  150. * @brief Send a vfr_hud message
  151. * @param chan MAVLink channel to send the message
  152. *
  153. * @param airspeed [m/s] Current indicated airspeed (IAS).
  154. * @param groundspeed [m/s] Current ground speed.
  155. * @param heading [deg] Current heading in compass units (0-360, 0=north).
  156. * @param throttle [%] Current throttle setting (0 to 100).
  157. * @param alt [m] Current altitude (MSL).
  158. * @param climb [m/s] Current climb rate.
  159. */
  160. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  161. static inline void mavlink_msg_vfr_hud_send(mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  162. {
  163. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  164. char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
  165. _mav_put_float(buf, 0, airspeed);
  166. _mav_put_float(buf, 4, groundspeed);
  167. _mav_put_float(buf, 8, alt);
  168. _mav_put_float(buf, 12, climb);
  169. _mav_put_int16_t(buf, 16, heading);
  170. _mav_put_uint16_t(buf, 18, throttle);
  171. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  172. #else
  173. mavlink_vfr_hud_t packet;
  174. packet.airspeed = airspeed;
  175. packet.groundspeed = groundspeed;
  176. packet.alt = alt;
  177. packet.climb = climb;
  178. packet.heading = heading;
  179. packet.throttle = throttle;
  180. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)&packet, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  181. #endif
  182. }
  183. /**
  184. * @brief Send a vfr_hud message
  185. * @param chan MAVLink channel to send the message
  186. * @param struct The MAVLink struct to serialize
  187. */
  188. static inline void mavlink_msg_vfr_hud_send_struct(mavlink_channel_t chan, const mavlink_vfr_hud_t* vfr_hud)
  189. {
  190. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  191. mavlink_msg_vfr_hud_send(chan, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
  192. #else
  193. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)vfr_hud, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  194. #endif
  195. }
  196. #if MAVLINK_MSG_ID_VFR_HUD_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  197. /*
  198. This varient of _send() can be used to save stack space by re-using
  199. memory from the receive buffer. The caller provides a
  200. mavlink_message_t which is the size of a full mavlink message. This
  201. is usually the receive buffer for the channel, and allows a reply to an
  202. incoming message with minimum stack space usage.
  203. */
  204. static inline void mavlink_msg_vfr_hud_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
  205. {
  206. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  207. char *buf = (char *)msgbuf;
  208. _mav_put_float(buf, 0, airspeed);
  209. _mav_put_float(buf, 4, groundspeed);
  210. _mav_put_float(buf, 8, alt);
  211. _mav_put_float(buf, 12, climb);
  212. _mav_put_int16_t(buf, 16, heading);
  213. _mav_put_uint16_t(buf, 18, throttle);
  214. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  215. #else
  216. mavlink_vfr_hud_t *packet = (mavlink_vfr_hud_t *)msgbuf;
  217. packet->airspeed = airspeed;
  218. packet->groundspeed = groundspeed;
  219. packet->alt = alt;
  220. packet->climb = climb;
  221. packet->heading = heading;
  222. packet->throttle = throttle;
  223. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)packet, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
  224. #endif
  225. }
  226. #endif
  227. #endif
  228. // MESSAGE VFR_HUD UNPACKING
  229. /**
  230. * @brief Get field airspeed from vfr_hud message
  231. *
  232. * @return [m/s] Current indicated airspeed (IAS).
  233. */
  234. static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t* msg)
  235. {
  236. return _MAV_RETURN_float(msg, 0);
  237. }
  238. /**
  239. * @brief Get field groundspeed from vfr_hud message
  240. *
  241. * @return [m/s] Current ground speed.
  242. */
  243. static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t* msg)
  244. {
  245. return _MAV_RETURN_float(msg, 4);
  246. }
  247. /**
  248. * @brief Get field heading from vfr_hud message
  249. *
  250. * @return [deg] Current heading in compass units (0-360, 0=north).
  251. */
  252. static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t* msg)
  253. {
  254. return _MAV_RETURN_int16_t(msg, 16);
  255. }
  256. /**
  257. * @brief Get field throttle from vfr_hud message
  258. *
  259. * @return [%] Current throttle setting (0 to 100).
  260. */
  261. static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t* msg)
  262. {
  263. return _MAV_RETURN_uint16_t(msg, 18);
  264. }
  265. /**
  266. * @brief Get field alt from vfr_hud message
  267. *
  268. * @return [m] Current altitude (MSL).
  269. */
  270. static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t* msg)
  271. {
  272. return _MAV_RETURN_float(msg, 8);
  273. }
  274. /**
  275. * @brief Get field climb from vfr_hud message
  276. *
  277. * @return [m/s] Current climb rate.
  278. */
  279. static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t* msg)
  280. {
  281. return _MAV_RETURN_float(msg, 12);
  282. }
  283. /**
  284. * @brief Decode a vfr_hud message into a struct
  285. *
  286. * @param msg The message to decode
  287. * @param vfr_hud C-struct to decode the message contents into
  288. */
  289. static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t* msg, mavlink_vfr_hud_t* vfr_hud)
  290. {
  291. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  292. vfr_hud->airspeed = mavlink_msg_vfr_hud_get_airspeed(msg);
  293. vfr_hud->groundspeed = mavlink_msg_vfr_hud_get_groundspeed(msg);
  294. vfr_hud->alt = mavlink_msg_vfr_hud_get_alt(msg);
  295. vfr_hud->climb = mavlink_msg_vfr_hud_get_climb(msg);
  296. vfr_hud->heading = mavlink_msg_vfr_hud_get_heading(msg);
  297. vfr_hud->throttle = mavlink_msg_vfr_hud_get_throttle(msg);
  298. #else
  299. uint8_t len = msg->len < MAVLINK_MSG_ID_VFR_HUD_LEN? msg->len : MAVLINK_MSG_ID_VFR_HUD_LEN;
  300. memset(vfr_hud, 0, MAVLINK_MSG_ID_VFR_HUD_LEN);
  301. memcpy(vfr_hud, _MAV_PAYLOAD(msg), len);
  302. #endif
  303. }