mavlink_msg_set_cam_shutter.h 8.19 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2 3
// MESSAGE SET_CAM_SHUTTER PACKING

#define MAVLINK_MSG_ID_SET_CAM_SHUTTER 100
lm's avatar
lm committed
4 5
#define MAVLINK_MSG_ID_SET_CAM_SHUTTER_LEN 11
#define MAVLINK_MSG_100_LEN 11
lm's avatar
lm committed
6 7
#define MAVLINK_MSG_ID_SET_CAM_SHUTTER_KEY 0x24
#define MAVLINK_MSG_100_KEY 0x24
James Goppert's avatar
James Goppert committed
8 9 10

typedef struct __mavlink_set_cam_shutter_t 
{
lm's avatar
lm committed
11 12 13 14 15 16
	float gain;	///< Camera gain
	uint16_t interval;	///< Shutter interval, in microseconds
	uint16_t exposure;	///< Exposure time, in microseconds
	uint8_t cam_no;	///< Camera id
	uint8_t cam_mode;	///< Camera mode: 0 = auto, 1 = manual
	uint8_t trigger_pin;	///< Trigger pin, 0-3 for PtGrey FireFly
James Goppert's avatar
James Goppert committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

} mavlink_set_cam_shutter_t;

/**
 * @brief Pack a set_cam_shutter message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param cam_no Camera id
 * @param cam_mode Camera mode: 0 = auto, 1 = manual
 * @param trigger_pin Trigger pin, 0-3 for PtGrey FireFly
 * @param interval Shutter interval, in microseconds
 * @param exposure Exposure time, in microseconds
 * @param gain Camera gain
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_set_cam_shutter_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, uint8_t cam_no, uint8_t cam_mode, uint8_t trigger_pin, uint16_t interval, uint16_t exposure, float gain)
{
lm's avatar
lm committed
36
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
James Goppert's avatar
James Goppert committed
37 38
	msg->msgid = MAVLINK_MSG_ID_SET_CAM_SHUTTER;

lm's avatar
lm committed
39 40 41 42 43 44
	p->cam_no = cam_no;	// uint8_t:Camera id
	p->cam_mode = cam_mode;	// uint8_t:Camera mode: 0 = auto, 1 = manual
	p->trigger_pin = trigger_pin;	// uint8_t:Trigger pin, 0-3 for PtGrey FireFly
	p->interval = interval;	// uint16_t:Shutter interval, in microseconds
	p->exposure = exposure;	// uint16_t:Exposure time, in microseconds
	p->gain = gain;	// float:Camera gain
James Goppert's avatar
James Goppert committed
45

lm's avatar
lm committed
46
	return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SET_CAM_SHUTTER_LEN);
James Goppert's avatar
James Goppert committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
}

/**
 * @brief Pack a set_cam_shutter message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param cam_no Camera id
 * @param cam_mode Camera mode: 0 = auto, 1 = manual
 * @param trigger_pin Trigger pin, 0-3 for PtGrey FireFly
 * @param interval Shutter interval, in microseconds
 * @param exposure Exposure time, in microseconds
 * @param gain Camera gain
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_set_cam_shutter_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, uint8_t cam_no, uint8_t cam_mode, uint8_t trigger_pin, uint16_t interval, uint16_t exposure, float gain)
{
lm's avatar
lm committed
65
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
James Goppert's avatar
James Goppert committed
66 67
	msg->msgid = MAVLINK_MSG_ID_SET_CAM_SHUTTER;

lm's avatar
lm committed
68 69 70 71 72 73
	p->cam_no = cam_no;	// uint8_t:Camera id
	p->cam_mode = cam_mode;	// uint8_t:Camera mode: 0 = auto, 1 = manual
	p->trigger_pin = trigger_pin;	// uint8_t:Trigger pin, 0-3 for PtGrey FireFly
	p->interval = interval;	// uint16_t:Shutter interval, in microseconds
	p->exposure = exposure;	// uint16_t:Exposure time, in microseconds
	p->gain = gain;	// float:Camera gain
James Goppert's avatar
James Goppert committed
74

lm's avatar
lm committed
75
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SET_CAM_SHUTTER_LEN);
James Goppert's avatar
James Goppert committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
}

/**
 * @brief Encode a set_cam_shutter struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param set_cam_shutter C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_set_cam_shutter_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_cam_shutter_t* set_cam_shutter)
{
	return mavlink_msg_set_cam_shutter_pack(system_id, component_id, msg, set_cam_shutter->cam_no, set_cam_shutter->cam_mode, set_cam_shutter->trigger_pin, set_cam_shutter->interval, set_cam_shutter->exposure, set_cam_shutter->gain);
}

lm's avatar
lm committed
91 92

#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
James Goppert's avatar
James Goppert committed
93 94 95 96 97 98 99 100 101 102 103
/**
 * @brief Send a set_cam_shutter message
 * @param chan MAVLink channel to send the message
 *
 * @param cam_no Camera id
 * @param cam_mode Camera mode: 0 = auto, 1 = manual
 * @param trigger_pin Trigger pin, 0-3 for PtGrey FireFly
 * @param interval Shutter interval, in microseconds
 * @param exposure Exposure time, in microseconds
 * @param gain Camera gain
 */
lm's avatar
lm committed
104 105 106 107 108
static inline void mavlink_msg_set_cam_shutter_send(mavlink_channel_t chan, uint8_t cam_no, uint8_t cam_mode, uint8_t trigger_pin, uint16_t interval, uint16_t exposure, float gain)
{
	mavlink_header_t hdr;
	mavlink_set_cam_shutter_t payload;

lm's avatar
lm committed
109 110 111 112 113 114 115
	MAVLINK_BUFFER_CHECK_START( chan, MAVLINK_MSG_ID_SET_CAM_SHUTTER_LEN )
	payload.cam_no = cam_no;	// uint8_t:Camera id
	payload.cam_mode = cam_mode;	// uint8_t:Camera mode: 0 = auto, 1 = manual
	payload.trigger_pin = trigger_pin;	// uint8_t:Trigger pin, 0-3 for PtGrey FireFly
	payload.interval = interval;	// uint16_t:Shutter interval, in microseconds
	payload.exposure = exposure;	// uint16_t:Exposure time, in microseconds
	payload.gain = gain;	// float:Camera gain
lm's avatar
lm committed
116 117 118 119 120 121 122 123 124

	hdr.STX = MAVLINK_STX;
	hdr.len = MAVLINK_MSG_ID_SET_CAM_SHUTTER_LEN;
	hdr.msgid = MAVLINK_MSG_ID_SET_CAM_SHUTTER;
	hdr.sysid = mavlink_system.sysid;
	hdr.compid = mavlink_system.compid;
	hdr.seq = mavlink_get_channel_status(chan)->current_tx_seq;
	mavlink_get_channel_status(chan)->current_tx_seq = hdr.seq + 1;
	mavlink_send_mem(chan, (uint8_t *)&hdr.STX, MAVLINK_NUM_HEADER_BYTES );
125
	mavlink_send_mem(chan, (uint8_t *)&payload, sizeof(payload) );
lm's avatar
lm committed
126

lm's avatar
lm committed
127 128 129 130 131 132
	crc_init(&hdr.ck);
	crc_calculate_mem((uint8_t *)&hdr.len, &hdr.ck, MAVLINK_CORE_HEADER_LEN);
	crc_calculate_mem((uint8_t *)&payload, &hdr.ck, hdr.len );
	crc_accumulate( 0x24, &hdr.ck); /// include key in X25 checksum
	mavlink_send_mem(chan, (uint8_t *)&hdr.ck, MAVLINK_NUM_CHECKSUM_BYTES);
	MAVLINK_BUFFER_CHECK_END
James Goppert's avatar
James Goppert committed
133 134 135 136 137 138 139 140 141 142 143 144
}

#endif
// MESSAGE SET_CAM_SHUTTER UNPACKING

/**
 * @brief Get field cam_no from set_cam_shutter message
 *
 * @return Camera id
 */
static inline uint8_t mavlink_msg_set_cam_shutter_get_cam_no(const mavlink_message_t* msg)
{
lm's avatar
lm committed
145 146
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
	return (uint8_t)(p->cam_no);
James Goppert's avatar
James Goppert committed
147 148 149 150 151 152 153 154 155
}

/**
 * @brief Get field cam_mode from set_cam_shutter message
 *
 * @return Camera mode: 0 = auto, 1 = manual
 */
static inline uint8_t mavlink_msg_set_cam_shutter_get_cam_mode(const mavlink_message_t* msg)
{
lm's avatar
lm committed
156 157
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
	return (uint8_t)(p->cam_mode);
James Goppert's avatar
James Goppert committed
158 159 160 161 162 163 164 165 166
}

/**
 * @brief Get field trigger_pin from set_cam_shutter message
 *
 * @return Trigger pin, 0-3 for PtGrey FireFly
 */
static inline uint8_t mavlink_msg_set_cam_shutter_get_trigger_pin(const mavlink_message_t* msg)
{
lm's avatar
lm committed
167 168
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
	return (uint8_t)(p->trigger_pin);
James Goppert's avatar
James Goppert committed
169 170 171 172 173 174 175 176 177
}

/**
 * @brief Get field interval from set_cam_shutter message
 *
 * @return Shutter interval, in microseconds
 */
static inline uint16_t mavlink_msg_set_cam_shutter_get_interval(const mavlink_message_t* msg)
{
lm's avatar
lm committed
178 179
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
	return (uint16_t)(p->interval);
James Goppert's avatar
James Goppert committed
180 181 182 183 184 185 186 187 188
}

/**
 * @brief Get field exposure from set_cam_shutter message
 *
 * @return Exposure time, in microseconds
 */
static inline uint16_t mavlink_msg_set_cam_shutter_get_exposure(const mavlink_message_t* msg)
{
lm's avatar
lm committed
189 190
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
	return (uint16_t)(p->exposure);
James Goppert's avatar
James Goppert committed
191 192 193 194 195 196 197 198 199
}

/**
 * @brief Get field gain from set_cam_shutter message
 *
 * @return Camera gain
 */
static inline float mavlink_msg_set_cam_shutter_get_gain(const mavlink_message_t* msg)
{
lm's avatar
lm committed
200 201
	mavlink_set_cam_shutter_t *p = (mavlink_set_cam_shutter_t *)&msg->payload[0];
	return (float)(p->gain);
James Goppert's avatar
James Goppert committed
202 203 204 205 206 207 208 209 210 211
}

/**
 * @brief Decode a set_cam_shutter message into a struct
 *
 * @param msg The message to decode
 * @param set_cam_shutter C-struct to decode the message contents into
 */
static inline void mavlink_msg_set_cam_shutter_decode(const mavlink_message_t* msg, mavlink_set_cam_shutter_t* set_cam_shutter)
{
lm's avatar
lm committed
212
	memcpy( set_cam_shutter, msg->payload, sizeof(mavlink_set_cam_shutter_t));
James Goppert's avatar
James Goppert committed
213
}