NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mavlink_msg_vfr_hud.h
Go to the documentation of this file.
1 // MESSAGE VFR_HUD PACKING
2 
3 #define MAVLINK_MSG_ID_VFR_HUD 74
4 
5 typedef struct __mavlink_vfr_hud_t
6 {
7  float airspeed;
8  float groundspeed;
9  float alt;
10  float climb;
11  int16_t heading;
12  uint16_t throttle;
14 
15 #define MAVLINK_MSG_ID_VFR_HUD_LEN 20
16 #define MAVLINK_MSG_ID_74_LEN 20
17 
18 #define MAVLINK_MSG_ID_VFR_HUD_CRC 20
19 #define MAVLINK_MSG_ID_74_CRC 20
20 
21 
22 
23 #define MAVLINK_MESSAGE_INFO_VFR_HUD { \
24  "VFR_HUD", \
25  6, \
26  { { "airspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_vfr_hud_t, airspeed) }, \
27  { "groundspeed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_vfr_hud_t, groundspeed) }, \
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  { "heading", NULL, MAVLINK_TYPE_INT16_T, 0, 16, offsetof(mavlink_vfr_hud_t, heading) }, \
31  { "throttle", NULL, MAVLINK_TYPE_UINT16_T, 0, 18, offsetof(mavlink_vfr_hud_t, throttle) }, \
32  } \
33 }
34 
35 
50 static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
51  float airspeed, float groundspeed, int16_t heading, uint16_t throttle, float alt, float climb)
52 {
53 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
55  _mav_put_float(buf, 0, airspeed);
56  _mav_put_float(buf, 4, groundspeed);
57  _mav_put_float(buf, 8, alt);
58  _mav_put_float(buf, 12, climb);
59  _mav_put_int16_t(buf, 16, heading);
60  _mav_put_uint16_t(buf, 18, throttle);
61 
63 #else
64  mavlink_vfr_hud_t packet;
65  packet.airspeed = airspeed;
66  packet.groundspeed = groundspeed;
67  packet.alt = alt;
68  packet.climb = climb;
69  packet.heading = heading;
70  packet.throttle = throttle;
71 
73 #endif
74 
75  msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
76 #if MAVLINK_CRC_EXTRA
78 #else
79  return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_VFR_HUD_LEN);
80 #endif
81 }
82 
97 static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
98  mavlink_message_t* msg,
99  float airspeed,float groundspeed,int16_t heading,uint16_t throttle,float alt,float climb)
100 {
101 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
102  char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
103  _mav_put_float(buf, 0, airspeed);
104  _mav_put_float(buf, 4, groundspeed);
105  _mav_put_float(buf, 8, alt);
106  _mav_put_float(buf, 12, climb);
107  _mav_put_int16_t(buf, 16, heading);
108  _mav_put_uint16_t(buf, 18, throttle);
109 
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 
120  memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
121 #endif
122 
123  msg->msgid = MAVLINK_MSG_ID_VFR_HUD;
124 #if MAVLINK_CRC_EXTRA
125  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
126 #else
127  return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_VFR_HUD_LEN);
128 #endif
129 }
130 
139 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)
140 {
141  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);
142 }
143 
153 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)
154 {
155  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);
156 }
157 
169 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
170 
171 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)
172 {
173 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
174  char buf[MAVLINK_MSG_ID_VFR_HUD_LEN];
175  _mav_put_float(buf, 0, airspeed);
176  _mav_put_float(buf, 4, groundspeed);
177  _mav_put_float(buf, 8, alt);
178  _mav_put_float(buf, 12, climb);
179  _mav_put_int16_t(buf, 16, heading);
180  _mav_put_uint16_t(buf, 18, throttle);
181 
182 #if MAVLINK_CRC_EXTRA
183  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
184 #else
185  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
186 #endif
187 #else
188  mavlink_vfr_hud_t packet;
189  packet.airspeed = airspeed;
190  packet.groundspeed = groundspeed;
191  packet.alt = alt;
192  packet.climb = climb;
193  packet.heading = heading;
194  packet.throttle = throttle;
195 
196 #if MAVLINK_CRC_EXTRA
197  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)&packet, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
198 #else
199  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)&packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
200 #endif
201 #endif
202 }
203 
204 #if MAVLINK_MSG_ID_VFR_HUD_LEN <= MAVLINK_MAX_PAYLOAD_LEN
205 /*
206  This varient of _send() can be used to save stack space by re-using
207  memory from the receive buffer. The caller provides a
208  mavlink_message_t which is the size of a full mavlink message. This
209  is usually the receive buffer for the channel, and allows a reply to an
210  incoming message with minimum stack space usage.
211  */
212 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)
213 {
214 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
215  char *buf = (char *)msgbuf;
216  _mav_put_float(buf, 0, airspeed);
217  _mav_put_float(buf, 4, groundspeed);
218  _mav_put_float(buf, 8, alt);
219  _mav_put_float(buf, 12, climb);
220  _mav_put_int16_t(buf, 16, heading);
221  _mav_put_uint16_t(buf, 18, throttle);
222 
223 #if MAVLINK_CRC_EXTRA
224  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
225 #else
226  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, buf, MAVLINK_MSG_ID_VFR_HUD_LEN);
227 #endif
228 #else
229  mavlink_vfr_hud_t *packet = (mavlink_vfr_hud_t *)msgbuf;
230  packet->airspeed = airspeed;
231  packet->groundspeed = groundspeed;
232  packet->alt = alt;
233  packet->climb = climb;
234  packet->heading = heading;
235  packet->throttle = throttle;
236 
237 #if MAVLINK_CRC_EXTRA
238  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)packet, MAVLINK_MSG_ID_VFR_HUD_LEN, MAVLINK_MSG_ID_VFR_HUD_CRC);
239 #else
240  _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_VFR_HUD, (const char *)packet, MAVLINK_MSG_ID_VFR_HUD_LEN);
241 #endif
242 #endif
243 }
244 #endif
245 
246 #endif
247 
248 // MESSAGE VFR_HUD UNPACKING
249 
250 
256 static inline float mavlink_msg_vfr_hud_get_airspeed(const mavlink_message_t* msg)
257 {
258  return _MAV_RETURN_float(msg, 0);
259 }
260 
266 static inline float mavlink_msg_vfr_hud_get_groundspeed(const mavlink_message_t* msg)
267 {
268  return _MAV_RETURN_float(msg, 4);
269 }
270 
276 static inline int16_t mavlink_msg_vfr_hud_get_heading(const mavlink_message_t* msg)
277 {
278  return _MAV_RETURN_int16_t(msg, 16);
279 }
280 
286 static inline uint16_t mavlink_msg_vfr_hud_get_throttle(const mavlink_message_t* msg)
287 {
288  return _MAV_RETURN_uint16_t(msg, 18);
289 }
290 
296 static inline float mavlink_msg_vfr_hud_get_alt(const mavlink_message_t* msg)
297 {
298  return _MAV_RETURN_float(msg, 8);
299 }
300 
306 static inline float mavlink_msg_vfr_hud_get_climb(const mavlink_message_t* msg)
307 {
308  return _MAV_RETURN_float(msg, 12);
309 }
310 
317 static inline void mavlink_msg_vfr_hud_decode(const mavlink_message_t* msg, mavlink_vfr_hud_t* vfr_hud)
318 {
319 #if MAVLINK_NEED_BYTE_SWAP
320  vfr_hud->airspeed = mavlink_msg_vfr_hud_get_airspeed(msg);
321  vfr_hud->groundspeed = mavlink_msg_vfr_hud_get_groundspeed(msg);
322  vfr_hud->alt = mavlink_msg_vfr_hud_get_alt(msg);
323  vfr_hud->climb = mavlink_msg_vfr_hud_get_climb(msg);
324  vfr_hud->heading = mavlink_msg_vfr_hud_get_heading(msg);
325  vfr_hud->throttle = mavlink_msg_vfr_hud_get_throttle(msg);
326 #else
327  memcpy(vfr_hud, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_VFR_HUD_LEN);
328 #endif
329 }
#define _mav_put_float(buf, wire_offset, b)
Definition: protocol.h:145
struct throttle_correction_config throttle
Definition: config.h:98
#define _mav_put_uint16_t(buf, wire_offset, b)
Definition: protocol.h:139
#define _mav_put_int16_t(buf, wire_offset, b)
Definition: protocol.h:140