Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_vfr_hud.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE VFR_HUD PACKING
3
4#define MAVLINK_MSG_ID_VFR_HUD 74
5
6
7typedef struct __mavlink_vfr_hud_t {
8 float airspeed; /*< [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.*/
9 float groundspeed; /*< [m/s] Current ground speed.*/
10 float alt; /*< [m] Current altitude (MSL).*/
11 float climb; /*< [m/s] Current climb rate.*/
12 int16_t heading; /*< [deg] Current heading in compass units (0-360, 0=north).*/
13 uint16_t throttle; /*< [%] Current throttle setting (0 to 100).*/
14} mavlink_vfr_hud_t;
15
16#define MAVLINK_MSG_ID_VFR_HUD_LEN 20
17#define MAVLINK_MSG_ID_VFR_HUD_MIN_LEN 20
18#define MAVLINK_MSG_ID_74_LEN 20
19#define MAVLINK_MSG_ID_74_MIN_LEN 20
20
21#define MAVLINK_MSG_ID_VFR_HUD_CRC 20
22#define MAVLINK_MSG_ID_74_CRC 20
23
24
25
26#if MAVLINK_COMMAND_24BIT
27#define MAVLINK_MESSAGE_INFO_VFR_HUD {
28 74,
29 "VFR_HUD",
30 6,
31 { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) },
32 { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) },
33 { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) },
34 { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) },
35 { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) },
36 { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) },
37 } \
38}
39#else
40#define MAVLINK_MESSAGE_INFO_VFR_HUD {
41 "VFR_HUD",
42 6,
43 { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) },
44 { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) },
45 { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) },
46 { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) },
47 { "alt", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_vfr_hud_t, alt) },
48 { "climb", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_vfr_hud_t, climb) },
49 } \
50}
51#endif
52
53/**
54 * @brief Pack a vfr_hud message
55 * @param system_id ID of this system
56 * @param component_id ID of this component (e.g. 200 for IMU)
57 * @param msg The MAVLink message to compress the data into
58 *
59 * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
60 * @param groundspeed [m/s] Current ground speed.
61 * @param heading [deg] Current heading in compass units (0-360, 0=north).
62 * @param throttle [%] Current throttle setting (0 to 100).
63 * @param alt [m] Current altitude (MSL).
64 * @param climb [m/s] Current climb rate.
65 * @return length of the message in bytes (excluding serial stream start sign)
66 */
67static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
68 float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
69{
70#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
72 _mav_put_float(buf, 0, airspeed);
73 _mav_put_float(buf, 4, groundspeed);
74 _mav_put_float(buf, 8, alt);
75 _mav_put_float(buf, 12, climb);
76 _mav_put_int16_t(buf, 16, heading);
77 _mav_put_uint16_t(buf, 18, throttle);
78
79 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
80#else
81 mavlink_vfr_hud_t packet;
82 packet.airspeed = airspeed;
83 packet.groundspeed = groundspeed;
84 packet.alt = alt;
85 packet.climb = climb;
86 packet.heading = heading;
87 packet.throttle = throttle;
88
89 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
90#endif
91
92 msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
93 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);
94}
95
96/**
97 * @brief Pack a vfr_hud message
98 * @param system_id ID of this system
99 * @param component_id ID of this component (e.g. 200 for IMU)
100 * @param status MAVLink status structure
101 * @param msg The MAVLink message to compress the data into
102 *
103 * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
104 * @param groundspeed [m/s] Current ground speed.
105 * @param heading [deg] Current heading in compass units (0-360, 0=north).
106 * @param throttle [%] Current throttle setting (0 to 100).
107 * @param alt [m] Current altitude (MSL).
108 * @param climb [m/s] Current climb rate.
109 * @return length of the message in bytes (excluding serial stream start sign)
110 */
111static inline uint16_t mavlink_msg_vfr_hud_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
112 float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
113{
114#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
116 _mav_put_float(buf, 0, airspeed);
117 _mav_put_float(buf, 4, groundspeed);
118 _mav_put_float(buf, 8, alt);
119 _mav_put_float(buf, 12, climb);
120 _mav_put_int16_t(buf, 16, heading);
121 _mav_put_uint16_t(buf, 18, throttle);
122
123 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
124#else
125 mavlink_vfr_hud_t packet;
126 packet.airspeed = airspeed;
127 packet.groundspeed = groundspeed;
128 packet.alt = alt;
129 packet.climb = climb;
130 packet.heading = heading;
131 packet.throttle = throttle;
132
133 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
134#endif
135
136 msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
137#if MAVLINK_CRC_EXTRA
138 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
139#else
140 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_VFR_HUD_MIN_LEN, MAVLINK_MSG_ID_VFR_HUD_LEN);
141#endif
142}
143
144/**
145 * @brief Pack a vfr_hud message on a channel
146 * @param system_id ID of this system
147 * @param component_id ID of this component (e.g. 200 for IMU)
148 * @param chan The MAVLink channel this message will be sent over
149 * @param msg The MAVLink message to compress the data into
150 * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
151 * @param groundspeed [m/s] Current ground speed.
152 * @param heading [deg] Current heading in compass units (0-360, 0=north).
153 * @param throttle [%] Current throttle setting (0 to 100).
154 * @param alt [m] Current altitude (MSL).
155 * @param climb [m/s] Current climb rate.
156 * @return length of the message in bytes (excluding serial stream start sign)
157 */
158static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
159 mavlink_message_t* msg,
160 float airspeed,float groundspeed,int16_t heading,uint16_t throttle,float alt,float climb)
161{
162#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
164 _mav_put_float(buf, 0, airspeed);
165 _mav_put_float(buf, 4, groundspeed);
166 _mav_put_float(buf, 8, alt);
167 _mav_put_float(buf, 12, climb);
168 _mav_put_int16_t(buf, 16, heading);
169 _mav_put_uint16_t(buf, 18, throttle);
170
171 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
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
181 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
182#endif
183
184 msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
185 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);
186}
187
188/**
189 * @brief Encode a vfr_hud struct
190 *
191 * @param system_id ID of this system
192 * @param component_id ID of this component (e.g. 200 for IMU)
193 * @param msg The MAVLink message to compress the data into
194 * @param vfr_hud C-struct to read the message contents from
195 */
196static 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)
197{
198 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);
199}
200
201/**
202 * @brief Encode a vfr_hud struct on a channel
203 *
204 * @param system_id ID of this system
205 * @param component_id ID of this component (e.g. 200 for IMU)
206 * @param chan The MAVLink channel this message will be sent over
207 * @param msg The MAVLink message to compress the data into
208 * @param vfr_hud C-struct to read the message contents from
209 */
210static 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)
211{
212 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);
213}
214
215/**
216 * @brief Encode a vfr_hud struct with provided status structure
217 *
218 * @param system_id ID of this system
219 * @param component_id ID of this component (e.g. 200 for IMU)
220 * @param status MAVLink status structure
221 * @param msg The MAVLink message to compress the data into
222 * @param vfr_hud C-struct to read the message contents from
223 */
224static inline uint16_t mavlink_msg_vfr_hud_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_vfr_hud_t* vfr_hud)
225{
226 return mavlink_msg_vfr_hud_pack_status(system_id, component_id, _status, msg, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
227}
228
229/**
230 * @brief Send a vfr_hud message
231 * @param chan MAVLink channel to send the message
232 *
233 * @param airspeed [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
234 * @param groundspeed [m/s] Current ground speed.
235 * @param heading [deg] Current heading in compass units (0-360, 0=north).
236 * @param throttle [%] Current throttle setting (0 to 100).
237 * @param alt [m] Current altitude (MSL).
238 * @param climb [m/s] Current climb rate.
239 */
240#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
241
242static 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)
243{
244#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
245 char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
246 _mav_put_float(buf, 0, airspeed);
247 _mav_put_float(buf, 4, groundspeed);
248 _mav_put_float(buf, 8, alt);
249 _mav_put_float(buf, 12, climb);
250 _mav_put_int16_t(buf, 16, heading);
251 _mav_put_uint16_t(buf, 18, throttle);
252
253 _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);
254#else
255 mavlink_vfr_hud_t packet;
256 packet.airspeed = airspeed;
257 packet.groundspeed = groundspeed;
258 packet.alt = alt;
259 packet.climb = climb;
260 packet.heading = heading;
261 packet.throttle = throttle;
262
263 _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);
264#endif
265}
266
267/**
268 * @brief Send a vfr_hud message
269 * @param chan MAVLink channel to send the message
270 * @param struct The MAVLink struct to serialize
271 */
272static inline void mavlink_msg_vfr_hud_send_struct(mavlink_channel_t chan, const mavlink_vfr_hud_t* vfr_hud)
273{
274#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
275 mavlink_msg_vfr_hud_send(chan, vfr_hud->airspeed, vfr_hud->groundspeed, vfr_hud->heading, vfr_hud->throttle, vfr_hud->alt, vfr_hud->climb);
276#else
277 _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);
278#endif
279}
280
281#if MAVLINK_MSG_ID_VFR_HUD_LEN <= MAVLINK_MAX_PAYLOAD_LEN
282/*
283 This variant of _send() can be used to save stack space by reusing
284 memory from the receive buffer. The caller provides a
285 mavlink_message_t which is the size of a full mavlink message. This
286 is usually the receive buffer for the channel, and allows a reply to an
287 incoming message with minimum stack space usage.
288 */
289static 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)
290{
291#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
292 char *buf = (char *)msgbuf;
293 _mav_put_float(buf, 0, airspeed);
294 _mav_put_float(buf, 4, groundspeed);
295 _mav_put_float(buf, 8, alt);
296 _mav_put_float(buf, 12, climb);
297 _mav_put_int16_t(buf, 16, heading);
298 _mav_put_uint16_t(buf, 18, throttle);
299
300 _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);
301#else
302 mavlink_vfr_hud_t *packet = (mavlink_vfr_hud_t *)msgbuf;
303 packet->airspeed = airspeed;
304 packet->groundspeed = groundspeed;
305 packet->alt = alt;
306 packet->climb = climb;
307 packet->heading = heading;
308 packet->throttle = throttle;
309
310 _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);
311#endif
312}
313#endif
314
315#endif
316
317// MESSAGE VFR_HUD UNPACKING
318
319
320/**
321 * @brief Get field airspeed from vfr_hud message
322 *
323 * @return [m/s] Vehicle speed in form appropriate for vehicle type. For standard aircraft this is typically calibrated airspeed (CAS) or indicated airspeed (IAS) - either of which can be used by a pilot to estimate stall speed.
324 */
325static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t* msg)
326{
327 return _MAV_RETURN_float(msg, 0);
328}
329
330/**
331 * @brief Get field groundspeed from vfr_hud message
332 *
333 * @return [m/s] Current ground speed.
334 */
335static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t* msg)
336{
337 return _MAV_RETURN_float(msg, 4);
338}
339
340/**
341 * @brief Get field heading from vfr_hud message
342 *
343 * @return [deg] Current heading in compass units (0-360, 0=north).
344 */
345static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t* msg)
346{
347 return _MAV_RETURN_int16_t(msg, 16);
348}
349
350/**
351 * @brief Get field throttle from vfr_hud message
352 *
353 * @return [%] Current throttle setting (0 to 100).
354 */
355static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t* msg)
356{
357 return _MAV_RETURN_uint16_t(msg, 18);
358}
359
360/**
361 * @brief Get field alt from vfr_hud message
362 *
363 * @return [m] Current altitude (MSL).
364 */
365static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t* msg)
366{
367 return _MAV_RETURN_float(msg, 8);
368}
369
370/**
371 * @brief Get field climb from vfr_hud message
372 *
373 * @return [m/s] Current climb rate.
374 */
375static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t* msg)
376{
377 return _MAV_RETURN_float(msg, 12);
378}
379
380/**
381 * @brief Decode a vfr_hud message into a struct
382 *
383 * @param msg The message to decode
384 * @param vfr_hud C-struct to decode the message contents into
385 */
386static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t* msg, mavlink_vfr_hud_t* vfr_hud)
387{
388#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
389 vfr_hud->airspeed = mavlink_msg_vfr_hud_get_airspeed(msg);
390 vfr_hud->groundspeed = mavlink_msg_vfr_hud_get_groundspeed(msg);
391 vfr_hud->alt = mavlink_msg_vfr_hud_get_alt(msg);
392 vfr_hud->climb = mavlink_msg_vfr_hud_get_climb(msg);
393 vfr_hud->heading = mavlink_msg_vfr_hud_get_heading(msg);
394 vfr_hud->throttle = mavlink_msg_vfr_hud_get_throttle(msg);
395#else
396 uint8_t len = msg->len < MAVLINK_MSG_ID_VFR_HUD_LEN? msg->len : MAVLINK_MSG_ID_VFR_HUD_LEN;
397 memset(vfr_hud, 0, MAVLINK_MSG_ID_VFR_HUD_LEN);
398 memcpy(vfr_hud, _MAV_PAYLOAD(msg), len);
399#endif
400}