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.

263 lines
11 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE BUTTON_CHANGE PACKING
  3. #define MAVLINK_MSG_ID_BUTTON_CHANGE 257
  4. MAVPACKED(
  5. typedef struct __mavlink_button_change_t {
  6. uint32_t time_boot_ms; /*< [ms] Timestamp (time since system boot).*/
  7. uint32_t last_change_ms; /*< [ms] Time of last change of button state.*/
  8. uint8_t state; /*< Bitmap for state of buttons.*/
  9. }) mavlink_button_change_t;
  10. #define MAVLINK_MSG_ID_BUTTON_CHANGE_LEN 9
  11. #define MAVLINK_MSG_ID_BUTTON_CHANGE_MIN_LEN 9
  12. #define MAVLINK_MSG_ID_257_LEN 9
  13. #define MAVLINK_MSG_ID_257_MIN_LEN 9
  14. #define MAVLINK_MSG_ID_BUTTON_CHANGE_CRC 131
  15. #define MAVLINK_MSG_ID_257_CRC 131
  16. #if MAVLINK_COMMAND_24BIT
  17. #define MAVLINK_MESSAGE_INFO_BUTTON_CHANGE { \
  18. 257, \
  19. "BUTTON_CHANGE", \
  20. 3, \
  21. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_button_change_t, time_boot_ms) }, \
  22. { "last_change_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_button_change_t, last_change_ms) }, \
  23. { "state", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_button_change_t, state) }, \
  24. } \
  25. }
  26. #else
  27. #define MAVLINK_MESSAGE_INFO_BUTTON_CHANGE { \
  28. "BUTTON_CHANGE", \
  29. 3, \
  30. { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_button_change_t, time_boot_ms) }, \
  31. { "last_change_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_button_change_t, last_change_ms) }, \
  32. { "state", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_button_change_t, state) }, \
  33. } \
  34. }
  35. #endif
  36. /**
  37. * @brief Pack a button_change message
  38. * @param system_id ID of this system
  39. * @param component_id ID of this component (e.g. 200 for IMU)
  40. * @param msg The MAVLink message to compress the data into
  41. *
  42. * @param time_boot_ms [ms] Timestamp (time since system boot).
  43. * @param last_change_ms [ms] Time of last change of button state.
  44. * @param state Bitmap for state of buttons.
  45. * @return length of the message in bytes (excluding serial stream start sign)
  46. */
  47. static inline uint16_t mavlink_msg_button_change_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  48. uint32_t time_boot_ms, uint32_t last_change_ms, uint8_t state)
  49. {
  50. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  51. char buf[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN];
  52. _mav_put_uint32_t(buf, 0, time_boot_ms);
  53. _mav_put_uint32_t(buf, 4, last_change_ms);
  54. _mav_put_uint8_t(buf, 8, state);
  55. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN);
  56. #else
  57. mavlink_button_change_t packet;
  58. packet.time_boot_ms = time_boot_ms;
  59. packet.last_change_ms = last_change_ms;
  60. packet.state = state;
  61. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN);
  62. #endif
  63. msg->msgid = MAVLINK_MSG_ID_BUTTON_CHANGE;
  64. 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);
  65. }
  66. /**
  67. * @brief Pack a button_change message on a channel
  68. * @param system_id ID of this system
  69. * @param component_id ID of this component (e.g. 200 for IMU)
  70. * @param chan The MAVLink channel this message will be sent over
  71. * @param msg The MAVLink message to compress the data into
  72. * @param time_boot_ms [ms] Timestamp (time since system boot).
  73. * @param last_change_ms [ms] Time of last change of button state.
  74. * @param state Bitmap for state of buttons.
  75. * @return length of the message in bytes (excluding serial stream start sign)
  76. */
  77. static inline uint16_t mavlink_msg_button_change_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  78. mavlink_message_t* msg,
  79. uint32_t time_boot_ms,uint32_t last_change_ms,uint8_t state)
  80. {
  81. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  82. char buf[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN];
  83. _mav_put_uint32_t(buf, 0, time_boot_ms);
  84. _mav_put_uint32_t(buf, 4, last_change_ms);
  85. _mav_put_uint8_t(buf, 8, state);
  86. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN);
  87. #else
  88. mavlink_button_change_t packet;
  89. packet.time_boot_ms = time_boot_ms;
  90. packet.last_change_ms = last_change_ms;
  91. packet.state = state;
  92. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN);
  93. #endif
  94. msg->msgid = MAVLINK_MSG_ID_BUTTON_CHANGE;
  95. 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);
  96. }
  97. /**
  98. * @brief Encode a button_change struct
  99. *
  100. * @param system_id ID of this system
  101. * @param component_id ID of this component (e.g. 200 for IMU)
  102. * @param msg The MAVLink message to compress the data into
  103. * @param button_change C-struct to read the message contents from
  104. */
  105. 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)
  106. {
  107. return mavlink_msg_button_change_pack(system_id, component_id, msg, button_change->time_boot_ms, button_change->last_change_ms, button_change->state);
  108. }
  109. /**
  110. * @brief Encode a button_change struct on a channel
  111. *
  112. * @param system_id ID of this system
  113. * @param component_id ID of this component (e.g. 200 for IMU)
  114. * @param chan The MAVLink channel this message will be sent over
  115. * @param msg The MAVLink message to compress the data into
  116. * @param button_change C-struct to read the message contents from
  117. */
  118. 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)
  119. {
  120. 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);
  121. }
  122. /**
  123. * @brief Send a button_change message
  124. * @param chan MAVLink channel to send the message
  125. *
  126. * @param time_boot_ms [ms] Timestamp (time since system boot).
  127. * @param last_change_ms [ms] Time of last change of button state.
  128. * @param state Bitmap for state of buttons.
  129. */
  130. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  131. 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)
  132. {
  133. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  134. char buf[MAVLINK_MSG_ID_BUTTON_CHANGE_LEN];
  135. _mav_put_uint32_t(buf, 0, time_boot_ms);
  136. _mav_put_uint32_t(buf, 4, last_change_ms);
  137. _mav_put_uint8_t(buf, 8, state);
  138. _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);
  139. #else
  140. mavlink_button_change_t packet;
  141. packet.time_boot_ms = time_boot_ms;
  142. packet.last_change_ms = last_change_ms;
  143. packet.state = state;
  144. _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);
  145. #endif
  146. }
  147. /**
  148. * @brief Send a button_change message
  149. * @param chan MAVLink channel to send the message
  150. * @param struct The MAVLink struct to serialize
  151. */
  152. static inline void mavlink_msg_button_change_send_struct(mavlink_channel_t chan, const mavlink_button_change_t* button_change)
  153. {
  154. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  155. mavlink_msg_button_change_send(chan, button_change->time_boot_ms, button_change->last_change_ms, button_change->state);
  156. #else
  157. _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);
  158. #endif
  159. }
  160. #if MAVLINK_MSG_ID_BUTTON_CHANGE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  161. /*
  162. This varient of _send() can be used to save stack space by re-using
  163. memory from the receive buffer. The caller provides a
  164. mavlink_message_t which is the size of a full mavlink message. This
  165. is usually the receive buffer for the channel, and allows a reply to an
  166. incoming message with minimum stack space usage.
  167. */
  168. 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)
  169. {
  170. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  171. char *buf = (char *)msgbuf;
  172. _mav_put_uint32_t(buf, 0, time_boot_ms);
  173. _mav_put_uint32_t(buf, 4, last_change_ms);
  174. _mav_put_uint8_t(buf, 8, state);
  175. _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);
  176. #else
  177. mavlink_button_change_t *packet = (mavlink_button_change_t *)msgbuf;
  178. packet->time_boot_ms = time_boot_ms;
  179. packet->last_change_ms = last_change_ms;
  180. packet->state = state;
  181. _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);
  182. #endif
  183. }
  184. #endif
  185. #endif
  186. // MESSAGE BUTTON_CHANGE UNPACKING
  187. /**
  188. * @brief Get field time_boot_ms from button_change message
  189. *
  190. * @return [ms] Timestamp (time since system boot).
  191. */
  192. static inline uint32_t mavlink_msg_button_change_get_time_boot_ms(const mavlink_message_t* msg)
  193. {
  194. return _MAV_RETURN_uint32_t(msg, 0);
  195. }
  196. /**
  197. * @brief Get field last_change_ms from button_change message
  198. *
  199. * @return [ms] Time of last change of button state.
  200. */
  201. static inline uint32_t mavlink_msg_button_change_get_last_change_ms(const mavlink_message_t* msg)
  202. {
  203. return _MAV_RETURN_uint32_t(msg, 4);
  204. }
  205. /**
  206. * @brief Get field state from button_change message
  207. *
  208. * @return Bitmap for state of buttons.
  209. */
  210. static inline uint8_t mavlink_msg_button_change_get_state(const mavlink_message_t* msg)
  211. {
  212. return _MAV_RETURN_uint8_t(msg, 8);
  213. }
  214. /**
  215. * @brief Decode a button_change message into a struct
  216. *
  217. * @param msg The message to decode
  218. * @param button_change C-struct to decode the message contents into
  219. */
  220. static inline void mavlink_msg_button_change_decode(const mavlink_message_t* msg, mavlink_button_change_t* button_change)
  221. {
  222. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  223. button_change->time_boot_ms = mavlink_msg_button_change_get_time_boot_ms(msg);
  224. button_change->last_change_ms = mavlink_msg_button_change_get_last_change_ms(msg);
  225. button_change->state = mavlink_msg_button_change_get_state(msg);
  226. #else
  227. uint8_t len = msg->len < MAVLINK_MSG_ID_BUTTON_CHANGE_LEN? msg->len : MAVLINK_MSG_ID_BUTTON_CHANGE_LEN;
  228. memset(button_change, 0, MAVLINK_MSG_ID_BUTTON_CHANGE_LEN);
  229. memcpy(button_change, _MAV_PAYLOAD(msg), len);
  230. #endif
  231. }