Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / MAVLink / common / mavlink_msg_terrain_data.h
blob8fc0b4322d736c356fa2f4e90e1473a18848c08f
1 // MESSAGE TERRAIN_DATA PACKING
3 #define MAVLINK_MSG_ID_TERRAIN_DATA 134
5 typedef struct __mavlink_terrain_data_t
7 int32_t lat; ///< Latitude of SW corner of first grid (degrees *10^7)
8 int32_t lon; ///< Longitude of SW corner of first grid (in degrees *10^7)
9 uint16_t grid_spacing; ///< Grid spacing in meters
10 int16_t data[16]; ///< Terrain data in meters AMSL
11 uint8_t gridbit; ///< bit within the terrain request mask
12 } mavlink_terrain_data_t;
14 #define MAVLINK_MSG_ID_TERRAIN_DATA_LEN 43
15 #define MAVLINK_MSG_ID_134_LEN 43
17 #define MAVLINK_MSG_ID_TERRAIN_DATA_CRC 229
18 #define MAVLINK_MSG_ID_134_CRC 229
20 #define MAVLINK_MSG_TERRAIN_DATA_FIELD_DATA_LEN 16
22 #define MAVLINK_MESSAGE_INFO_TERRAIN_DATA { \
23 "TERRAIN_DATA", \
24 5, \
25 { { "lat", NULL, MAVLINK_TYPE_INT32_T, 0, 0, offsetof(mavlink_terrain_data_t, lat) }, \
26 { "lon", NULL, MAVLINK_TYPE_INT32_T, 0, 4, offsetof(mavlink_terrain_data_t, lon) }, \
27 { "grid_spacing", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_terrain_data_t, grid_spacing) }, \
28 { "data", NULL, MAVLINK_TYPE_INT16_T, 16, 10, offsetof(mavlink_terrain_data_t, data) }, \
29 { "gridbit", NULL, MAVLINK_TYPE_UINT8_T, 0, 42, offsetof(mavlink_terrain_data_t, gridbit) }, \
30 } \
34 /**
35 * @brief Pack a terrain_data message
36 * @param system_id ID of this system
37 * @param component_id ID of this component (e.g. 200 for IMU)
38 * @param msg The MAVLink message to compress the data into
40 * @param lat Latitude of SW corner of first grid (degrees *10^7)
41 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
42 * @param grid_spacing Grid spacing in meters
43 * @param gridbit bit within the terrain request mask
44 * @param data Terrain data in meters AMSL
45 * @return length of the message in bytes (excluding serial stream start sign)
47 static inline uint16_t mavlink_msg_terrain_data_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
48 int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
50 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
51 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
52 _mav_put_int32_t(buf, 0, lat);
53 _mav_put_int32_t(buf, 4, lon);
54 _mav_put_uint16_t(buf, 8, grid_spacing);
55 _mav_put_uint8_t(buf, 42, gridbit);
56 _mav_put_int16_t_array(buf, 10, data, 16);
57 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
58 #else
59 mavlink_terrain_data_t packet;
60 packet.lat = lat;
61 packet.lon = lon;
62 packet.grid_spacing = grid_spacing;
63 packet.gridbit = gridbit;
64 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
65 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
66 #endif
68 msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
69 #if MAVLINK_CRC_EXTRA
70 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
71 #else
72 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
73 #endif
76 /**
77 * @brief Pack a terrain_data message on a channel
78 * @param system_id ID of this system
79 * @param component_id ID of this component (e.g. 200 for IMU)
80 * @param chan The MAVLink channel this message will be sent over
81 * @param msg The MAVLink message to compress the data into
82 * @param lat Latitude of SW corner of first grid (degrees *10^7)
83 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
84 * @param grid_spacing Grid spacing in meters
85 * @param gridbit bit within the terrain request mask
86 * @param data Terrain data in meters AMSL
87 * @return length of the message in bytes (excluding serial stream start sign)
89 static inline uint16_t mavlink_msg_terrain_data_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
90 mavlink_message_t* msg,
91 int32_t lat,int32_t lon,uint16_t grid_spacing,uint8_t gridbit,const int16_t *data)
93 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
94 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
95 _mav_put_int32_t(buf, 0, lat);
96 _mav_put_int32_t(buf, 4, lon);
97 _mav_put_uint16_t(buf, 8, grid_spacing);
98 _mav_put_uint8_t(buf, 42, gridbit);
99 _mav_put_int16_t_array(buf, 10, data, 16);
100 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
101 #else
102 mavlink_terrain_data_t packet;
103 packet.lat = lat;
104 packet.lon = lon;
105 packet.grid_spacing = grid_spacing;
106 packet.gridbit = gridbit;
107 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
108 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
109 #endif
111 msg->msgid = MAVLINK_MSG_ID_TERRAIN_DATA;
112 #if MAVLINK_CRC_EXTRA
113 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
114 #else
115 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
116 #endif
120 * @brief Encode a terrain_data struct
122 * @param system_id ID of this system
123 * @param component_id ID of this component (e.g. 200 for IMU)
124 * @param msg The MAVLink message to compress the data into
125 * @param terrain_data C-struct to read the message contents from
127 static inline uint16_t mavlink_msg_terrain_data_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data)
129 return mavlink_msg_terrain_data_pack(system_id, component_id, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
133 * @brief Encode a terrain_data struct on a channel
135 * @param system_id ID of this system
136 * @param component_id ID of this component (e.g. 200 for IMU)
137 * @param chan The MAVLink channel this message will be sent over
138 * @param msg The MAVLink message to compress the data into
139 * @param terrain_data C-struct to read the message contents from
141 static inline uint16_t mavlink_msg_terrain_data_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_terrain_data_t* terrain_data)
143 return mavlink_msg_terrain_data_pack_chan(system_id, component_id, chan, msg, terrain_data->lat, terrain_data->lon, terrain_data->grid_spacing, terrain_data->gridbit, terrain_data->data);
147 * @brief Send a terrain_data message
148 * @param chan MAVLink channel to send the message
150 * @param lat Latitude of SW corner of first grid (degrees *10^7)
151 * @param lon Longitude of SW corner of first grid (in degrees *10^7)
152 * @param grid_spacing Grid spacing in meters
153 * @param gridbit bit within the terrain request mask
154 * @param data Terrain data in meters AMSL
156 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
158 static inline void mavlink_msg_terrain_data_send(mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
160 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
161 char buf[MAVLINK_MSG_ID_TERRAIN_DATA_LEN];
162 _mav_put_int32_t(buf, 0, lat);
163 _mav_put_int32_t(buf, 4, lon);
164 _mav_put_uint16_t(buf, 8, grid_spacing);
165 _mav_put_uint8_t(buf, 42, gridbit);
166 _mav_put_int16_t_array(buf, 10, data, 16);
167 #if MAVLINK_CRC_EXTRA
168 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
169 #else
170 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
171 #endif
172 #else
173 mavlink_terrain_data_t packet;
174 packet.lat = lat;
175 packet.lon = lon;
176 packet.grid_spacing = grid_spacing;
177 packet.gridbit = gridbit;
178 mav_array_memcpy(packet.data, data, sizeof(int16_t)*16);
179 #if MAVLINK_CRC_EXTRA
180 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
181 #else
182 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)&packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
183 #endif
184 #endif
187 #if MAVLINK_MSG_ID_TERRAIN_DATA_LEN <= MAVLINK_MAX_PAYLOAD_LEN
189 This varient of _send() can be used to save stack space by re-using
190 memory from the receive buffer. The caller provides a
191 mavlink_message_t which is the size of a full mavlink message. This
192 is usually the receive buffer for the channel, and allows a reply to an
193 incoming message with minimum stack space usage.
195 static inline void mavlink_msg_terrain_data_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, int32_t lat, int32_t lon, uint16_t grid_spacing, uint8_t gridbit, const int16_t *data)
197 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
198 char *buf = (char *)msgbuf;
199 _mav_put_int32_t(buf, 0, lat);
200 _mav_put_int32_t(buf, 4, lon);
201 _mav_put_uint16_t(buf, 8, grid_spacing);
202 _mav_put_uint8_t(buf, 42, gridbit);
203 _mav_put_int16_t_array(buf, 10, data, 16);
204 #if MAVLINK_CRC_EXTRA
205 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
206 #else
207 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, buf, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
208 #endif
209 #else
210 mavlink_terrain_data_t *packet = (mavlink_terrain_data_t *)msgbuf;
211 packet->lat = lat;
212 packet->lon = lon;
213 packet->grid_spacing = grid_spacing;
214 packet->gridbit = gridbit;
215 mav_array_memcpy(packet->data, data, sizeof(int16_t)*16);
216 #if MAVLINK_CRC_EXTRA
217 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN, MAVLINK_MSG_ID_TERRAIN_DATA_CRC);
218 #else
219 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TERRAIN_DATA, (const char *)packet, MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
220 #endif
221 #endif
223 #endif
225 #endif
227 // MESSAGE TERRAIN_DATA UNPACKING
231 * @brief Get field lat from terrain_data message
233 * @return Latitude of SW corner of first grid (degrees *10^7)
235 static inline int32_t mavlink_msg_terrain_data_get_lat(const mavlink_message_t* msg)
237 return _MAV_RETURN_int32_t(msg, 0);
241 * @brief Get field lon from terrain_data message
243 * @return Longitude of SW corner of first grid (in degrees *10^7)
245 static inline int32_t mavlink_msg_terrain_data_get_lon(const mavlink_message_t* msg)
247 return _MAV_RETURN_int32_t(msg, 4);
251 * @brief Get field grid_spacing from terrain_data message
253 * @return Grid spacing in meters
255 static inline uint16_t mavlink_msg_terrain_data_get_grid_spacing(const mavlink_message_t* msg)
257 return _MAV_RETURN_uint16_t(msg, 8);
261 * @brief Get field gridbit from terrain_data message
263 * @return bit within the terrain request mask
265 static inline uint8_t mavlink_msg_terrain_data_get_gridbit(const mavlink_message_t* msg)
267 return _MAV_RETURN_uint8_t(msg, 42);
271 * @brief Get field data from terrain_data message
273 * @return Terrain data in meters AMSL
275 static inline uint16_t mavlink_msg_terrain_data_get_data(const mavlink_message_t* msg, int16_t *data)
277 return _MAV_RETURN_int16_t_array(msg, data, 16, 10);
281 * @brief Decode a terrain_data message into a struct
283 * @param msg The message to decode
284 * @param terrain_data C-struct to decode the message contents into
286 static inline void mavlink_msg_terrain_data_decode(const mavlink_message_t* msg, mavlink_terrain_data_t* terrain_data)
288 #if MAVLINK_NEED_BYTE_SWAP
289 terrain_data->lat = mavlink_msg_terrain_data_get_lat(msg);
290 terrain_data->lon = mavlink_msg_terrain_data_get_lon(msg);
291 terrain_data->grid_spacing = mavlink_msg_terrain_data_get_grid_spacing(msg);
292 mavlink_msg_terrain_data_get_data(msg, terrain_data->data);
293 terrain_data->gridbit = mavlink_msg_terrain_data_get_gridbit(msg);
294 #else
295 memcpy(terrain_data, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_TERRAIN_DATA_LEN);
296 #endif