fix(imu): add func for junior api useing.

This commit is contained in:
TinyO 2019-09-27 09:41:44 +08:00
parent 25e5a0bead
commit db4f1908ed
2 changed files with 8 additions and 4 deletions

View File

@ -111,6 +111,7 @@ Channels::Channels(const std::shared_ptr<uvc::device> &device,
: device_(device),
adapter_(adapter),
is_imu_tracking_(false),
is_imu_proto2_(false),
imu_track_stop_(false),
imu_sn_(0),
imu_callback_(nullptr),
@ -378,8 +379,7 @@ void Channels::SetImuCallback(imu_callback_t callback) {
}
void Channels::DoImuTrack() {
if (dev_info_->firmware_version >= Version(2, 0) &&
strstr(dev_info_->name.c_str(), "S2") != nullptr ) {
if (IsImuProc2()) {
return DoImuTrack2();
} else {
return DoImuTrack1();
@ -499,8 +499,7 @@ void Channels::StartImuTracking(imu_callback_t callback) {
<< ", sleep " << (IMU_TRACK_PERIOD - time_elapsed_ms) << " ms";
}
};
if (dev_info_->firmware_version >= Version(2, 0) &&
strstr(dev_info_->name.c_str(), "S2") != nullptr ) {
if (IsImuProc2()) {
while (!imu_track_stop_) {
auto &&time_beg = times::now();
DoImuTrack2();
@ -588,6 +587,9 @@ bool Channels::GetFiles(
<< "The firmware not support getting device info, you could "
"upgrade to latest";
dev_info_ = std::make_shared<DeviceInfo>(*info);
is_imu_proto2_ = dev_info_ &&
dev_info_->firmware_version >= Version(2, 0) &&
strstr(dev_info_->name.c_str(), "S2") != nullptr;
} break;
case FID_IMG_PARAMS: {
if (file_size > 0) {

View File

@ -89,6 +89,7 @@ class MYNTEYE_API Channels {
device_info_t *info, img_params_t *img_params, imu_params_t *imu_params);
bool SetFiles(
device_info_t *info, img_params_t *img_params, imu_params_t *imu_params);
inline bool IsImuProc2() const { return is_imu_proto2_; }
private:
bool PuControlRange(
@ -132,6 +133,7 @@ class MYNTEYE_API Channels {
std::map<Option, control_info_t> control_infos_;
bool is_imu_tracking_;
bool is_imu_proto2_;
std::thread imu_track_thread_;
volatile bool imu_track_stop_;