本文整理汇总了C++中AP_Int16::set方法的典型用法代码示例。如果您正苦于以下问题:C++ AP_Int16::set方法的具体用法?C++ AP_Int16::set怎么用?C++ AP_Int16::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP_Int16
的用法示例。
在下文中一共展示了AP_Int16::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_request_data_stream
/*
handle a request to change stream rate. Note that copter passes in
save==false, as sending mavlink messages on copter on APM2 costs
enough that it can cause flight issues, so we don't want the save to
happen when the user connects the ground station.
*/
void GCS_MAVLINK::handle_request_data_stream(mavlink_message_t *msg, bool save)
{
mavlink_request_data_stream_t packet;
mavlink_msg_request_data_stream_decode(msg, &packet);
int16_t freq = 0; // packet frequency
if (packet.start_stop == 0)
freq = 0; // stop sending
else if (packet.start_stop == 1)
freq = packet.req_message_rate; // start sending
else
return;
AP_Int16 *rate = NULL;
switch (packet.req_stream_id) {
case MAV_DATA_STREAM_ALL:
// note that we don't set STREAM_PARAMS - that is internal only
for (uint8_t i=0; i<STREAM_PARAMS; i++) {
if (save) {
streamRates[i].set_and_save_ifchanged(freq);
} else {
streamRates[i].set(freq);
}
}
break;
case MAV_DATA_STREAM_RAW_SENSORS:
rate = &streamRates[STREAM_RAW_SENSORS];
break;
case MAV_DATA_STREAM_EXTENDED_STATUS:
rate = &streamRates[STREAM_EXTENDED_STATUS];
break;
case MAV_DATA_STREAM_RC_CHANNELS:
rate = &streamRates[STREAM_RC_CHANNELS];
break;
case MAV_DATA_STREAM_RAW_CONTROLLER:
rate = &streamRates[STREAM_RAW_CONTROLLER];
break;
case MAV_DATA_STREAM_POSITION:
rate = &streamRates[STREAM_POSITION];
break;
case MAV_DATA_STREAM_EXTRA1:
rate = &streamRates[STREAM_EXTRA1];
break;
case MAV_DATA_STREAM_EXTRA2:
rate = &streamRates[STREAM_EXTRA2];
break;
case MAV_DATA_STREAM_EXTRA3:
rate = &streamRates[STREAM_EXTRA3];
break;
}
if (rate != NULL) {
if (save) {
rate->set_and_save_ifchanged(freq);
} else {
rate->set(freq);
}
}
}
示例2:
/*
set a int16 and save if changed
*/
void AP_AutoTune::save_int16_if_changed(AP_Int16 &v, int16_t value, const char *suffix)
{
int16_t old_value = v.get();
v.set(value);
if (old_value != v.get()) {
v.save();
log_param_change(v.get(), suffix);
}
}