2 // MESSAGE BUTTON_CHANGE PACKING
4 #define MAVLINK_MSG_ID_BUTTON_CHANGE 257
7 typedef struct __mavlink_button_change_t
{
8 uint32_t time_boot_ms
; /*< [ms] Timestamp (time since system boot).*/
9 uint32_t last_change_ms
; /*< [ms] Time of last change of button state.*/
10 uint8_t state
; /*< Bitmap for state of buttons.*/
11 } mavlink_button_change_t
;
13 #define MAVLINK_MSG_ID_BUTTON_CHANGE_LEN 9
14 #define MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN 9
15 #define MAVLINK_MSG_ID_257_LEN 9
16 #define MAVLINK_MSG_ID_257_MIN_LEN 9
18 #define MAVLINK_MSG_ID_BUTTON_CHANGE_CRC 131
19 #define MAVLINK_MSG_ID_257_CRC 131
23 #if MAVLINK_COMMAND_24BIT
24 #define MAVLINK_MESSAGE_INFO_BUTTON_CHANGE { \
28 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_button_change_t, time_boot_ms) }, \
29 { "last_change_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_button_change_t, last_change_ms) }, \
30 { "state", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_button_change_t, state) }, \
34 #define MAVLINK_MESSAGE_INFO_BUTTON_CHANGE { \
37 { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_button_change_t, time_boot_ms) }, \
38 { "last_change_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_button_change_t, last_change_ms) }, \
39 { "state", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_button_change_t, state) }, \
45 * @brief Pack a button_change message
46 * @param system_id ID of this system
47 * @param component_id ID of this component (e.g. 200 for IMU)
48 * @param msg The MAVLink message to compress the data into
50 * @param time_boot_ms [ms] Timestamp (time since system boot).
51 * @param last_change_ms [ms] Time of last change of button state.
52 * @param state Bitmap for state of buttons.
53 * @return length of the message in bytes (excluding serial stream start sign)
55 static inline uint16_t mavlink_msg_button_change_pack(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
,
56 uint32_t time_boot_ms
, uint32_t last_change_ms
, uint8_t state
)
58 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
59 char buf
[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
];
60 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
61 _mav_put_uint32_t(buf
, 4, last_change_ms
);
62 _mav_put_uint8_t(buf
, 8, state
);
64 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
);
66 mavlink_button_change_t packet
;
67 packet
.time_boot_ms
= time_boot_ms
;
68 packet
.last_change_ms
= last_change_ms
;
71 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
);
74 msg
->msgid
= MAVLINK_MSG_ID_BUTTON_CHANGE
;
75 return mavlink_finalize_message(msg
, system_id
, component_id
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
79 * @brief Pack a button_change message on a channel
80 * @param system_id ID of this system
81 * @param component_id ID of this component (e.g. 200 for IMU)
82 * @param chan The MAVLink channel this message will be sent over
83 * @param msg The MAVLink message to compress the data into
84 * @param time_boot_ms [ms] Timestamp (time since system boot).
85 * @param last_change_ms [ms] Time of last change of button state.
86 * @param state Bitmap for state of buttons.
87 * @return length of the message in bytes (excluding serial stream start sign)
89 static inline uint16_t mavlink_msg_button_change_pack_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
,
90 mavlink_message_t
* msg
,
91 uint32_t time_boot_ms
,uint32_t last_change_ms
,uint8_t state
)
93 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
94 char buf
[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
];
95 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
96 _mav_put_uint32_t(buf
, 4, last_change_ms
);
97 _mav_put_uint8_t(buf
, 8, state
);
99 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), buf
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
);
101 mavlink_button_change_t packet
;
102 packet
.time_boot_ms
= time_boot_ms
;
103 packet
.last_change_ms
= last_change_ms
;
104 packet
.state
= state
;
106 memcpy(_MAV_PAYLOAD_NON_CONST(msg
), &packet
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
);
109 msg
->msgid
= MAVLINK_MSG_ID_BUTTON_CHANGE
;
110 return mavlink_finalize_message_chan(msg
, system_id
, component_id
, chan
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
114 * @brief Encode a button_change struct
116 * @param system_id ID of this system
117 * @param component_id ID of this component (e.g. 200 for IMU)
118 * @param msg The MAVLink message to compress the data into
119 * @param button_change C-struct to read the message contents from
121 static inline uint16_t mavlink_msg_button_change_encode(uint8_t system_id
, uint8_t component_id
, mavlink_message_t
* msg
, const mavlink_button_change_t
* button_change
)
123 return mavlink_msg_button_change_pack(system_id
, component_id
, msg
, button_change
->time_boot_ms
, button_change
->last_change_ms
, button_change
->state
);
127 * @brief Encode a button_change struct on a channel
129 * @param system_id ID of this system
130 * @param component_id ID of this component (e.g. 200 for IMU)
131 * @param chan The MAVLink channel this message will be sent over
132 * @param msg The MAVLink message to compress the data into
133 * @param button_change C-struct to read the message contents from
135 static inline uint16_t mavlink_msg_button_change_encode_chan(uint8_t system_id
, uint8_t component_id
, uint8_t chan
, mavlink_message_t
* msg
, const mavlink_button_change_t
* button_change
)
137 return mavlink_msg_button_change_pack_chan(system_id
, component_id
, chan
, msg
, button_change
->time_boot_ms
, button_change
->last_change_ms
, button_change
->state
);
141 * @brief Send a button_change message
142 * @param chan MAVLink channel to send the message
144 * @param time_boot_ms [ms] Timestamp (time since system boot).
145 * @param last_change_ms [ms] Time of last change of button state.
146 * @param state Bitmap for state of buttons.
148 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
150 static inline void mavlink_msg_button_change_send(mavlink_channel_t chan
, uint32_t time_boot_ms
, uint32_t last_change_ms
, uint8_t state
)
152 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
153 char buf
[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
];
154 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
155 _mav_put_uint32_t(buf
, 4, last_change_ms
);
156 _mav_put_uint8_t(buf
, 8, state
);
158 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_BUTTON_CHANGE
, buf
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
160 mavlink_button_change_t packet
;
161 packet
.time_boot_ms
= time_boot_ms
;
162 packet
.last_change_ms
= last_change_ms
;
163 packet
.state
= state
;
165 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_BUTTON_CHANGE
, (const char *)&packet
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
170 * @brief Send a button_change message
171 * @param chan MAVLink channel to send the message
172 * @param struct The MAVLink struct to serialize
174 static inline void mavlink_msg_button_change_send_struct(mavlink_channel_t chan
, const mavlink_button_change_t
* button_change
)
176 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
177 mavlink_msg_button_change_send(chan
, button_change
->time_boot_ms
, button_change
->last_change_ms
, button_change
->state
);
179 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_BUTTON_CHANGE
, (const char *)button_change
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
183 #if MAVLINK_MSG_ID_BUTTON_CHANGE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
185 This varient of _send() can be used to save stack space by re-using
186 memory from the receive buffer. The caller provides a
187 mavlink_message_t which is the size of a full mavlink message. This
188 is usually the receive buffer for the channel, and allows a reply to an
189 incoming message with minimum stack space usage.
191 static inline void mavlink_msg_button_change_send_buf(mavlink_message_t
*msgbuf
, mavlink_channel_t chan
, uint32_t time_boot_ms
, uint32_t last_change_ms
, uint8_t state
)
193 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
194 char *buf
= (char *)msgbuf
;
195 _mav_put_uint32_t(buf
, 0, time_boot_ms
);
196 _mav_put_uint32_t(buf
, 4, last_change_ms
);
197 _mav_put_uint8_t(buf
, 8, state
);
199 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_BUTTON_CHANGE
, buf
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
201 mavlink_button_change_t
*packet
= (mavlink_button_change_t
*)msgbuf
;
202 packet
->time_boot_ms
= time_boot_ms
;
203 packet
->last_change_ms
= last_change_ms
;
204 packet
->state
= state
;
206 _mav_finalize_message_chan_send(chan
, MAVLINK_MSG_ID_BUTTON_CHANGE
, (const char *)packet
, MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
, MAVLINK_MSG_ID_BUTTON_CHANGE_CRC
);
213 // MESSAGE BUTTON_CHANGE UNPACKING
217 * @brief Get field time_boot_ms from button_change message
219 * @return [ms] Timestamp (time since system boot).
221 static inline uint32_t mavlink_msg_button_change_get_time_boot_ms(const mavlink_message_t
* msg
)
223 return _MAV_RETURN_uint32_t(msg
, 0);
227 * @brief Get field last_change_ms from button_change message
229 * @return [ms] Time of last change of button state.
231 static inline uint32_t mavlink_msg_button_change_get_last_change_ms(const mavlink_message_t
* msg
)
233 return _MAV_RETURN_uint32_t(msg
, 4);
237 * @brief Get field state from button_change message
239 * @return Bitmap for state of buttons.
241 static inline uint8_t mavlink_msg_button_change_get_state(const mavlink_message_t
* msg
)
243 return _MAV_RETURN_uint8_t(msg
, 8);
247 * @brief Decode a button_change message into a struct
249 * @param msg The message to decode
250 * @param button_change C-struct to decode the message contents into
252 static inline void mavlink_msg_button_change_decode(const mavlink_message_t
* msg
, mavlink_button_change_t
* button_change
)
254 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
255 button_change
->time_boot_ms
= mavlink_msg_button_change_get_time_boot_ms(msg
);
256 button_change
->last_change_ms
= mavlink_msg_button_change_get_last_change_ms(msg
);
257 button_change
->state
= mavlink_msg_button_change_get_state(msg
);
259 uint8_t len
= msg
->len
< MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
? msg
->len
: MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
;
260 memset(button_change
, 0, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN
);
261 memcpy(button_change
, _MAV_PAYLOAD(msg
), len
);