diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index d66f17f531..7fd4995b54 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -977,8 +977,10 @@ namespace librealsense // Auto exposure and gain limit if (_fw_version >= firmware_version("5.12.10.11")) { - depth_sensor.register_option(RS2_OPTION_AUTO_EXPOSURE_LIMIT, std::make_shared(*_hw_monitor, &depth_sensor)); - depth_sensor.register_option(RS2_OPTION_AUTO_GAIN_LIMIT, std::make_shared(*_hw_monitor, &depth_sensor)); + auto exposure_range = depth_sensor.get_option(RS2_OPTION_EXPOSURE).get_range(); + auto gain_range = depth_sensor.get_option(RS2_OPTION_GAIN).get_range(); + depth_sensor.register_option(RS2_OPTION_AUTO_EXPOSURE_LIMIT, std::make_shared(*_hw_monitor, &depth_sensor, exposure_range)); + depth_sensor.register_option(RS2_OPTION_AUTO_GAIN_LIMIT, std::make_shared(*_hw_monitor, &depth_sensor, gain_range)); } // attributes of md_capture_timing diff --git a/src/ds5/ds5-options.cpp b/src/ds5/ds5-options.cpp index 73b5869352..18c9256e63 100644 --- a/src/ds5/ds5-options.cpp +++ b/src/ds5/ds5-options.cpp @@ -658,17 +658,20 @@ namespace librealsense return _uvc_option->is_enabled(); } - auto_exposure_limit_option::auto_exposure_limit_option(hw_monitor& hwm, sensor_base* ep) - : _hwm(hwm), _sensor(ep) + auto_exposure_limit_option::auto_exposure_limit_option(hw_monitor& hwm, sensor_base* ep, option_range range) + : option_base(range), _hwm(hwm), _sensor(ep) { - _range = [this]() + _range = [range]() { - return option_range{ 0, 165000, 1, 0 }; + return range; }; } void auto_exposure_limit_option::set(float value) { + if (!is_valid(value)) + throw invalid_value_exception("set(enable_auto_exposure) failed! Invalid Auto-Exposure mode request " + std::to_string(value)); + command cmd_get(ds::AUTO_CALIB); cmd_get.param1 = 5; std::vector ret = _hwm.send(cmd_get); @@ -700,17 +703,20 @@ namespace librealsense return *_range; } - auto_gain_limit_option::auto_gain_limit_option(hw_monitor& hwm, sensor_base* ep) - : _hwm(hwm), _sensor(ep) + auto_gain_limit_option::auto_gain_limit_option(hw_monitor& hwm, sensor_base* ep, option_range range) + : option_base(range), _hwm(hwm), _sensor(ep) { - _range = [this]() + _range = [range]() { - return option_range{ 0, 248, 1, 0 }; + return range; }; } void auto_gain_limit_option::set(float value) { + if (!is_valid(value)) + throw invalid_value_exception("set(enable_auto_gain) failed! Invalid Auto-Gain mode request " + std::to_string(value)); + command cmd_get(ds::AUTO_CALIB); cmd_get.param1 = 5; std::vector ret = _hwm.send(cmd_get); diff --git a/src/ds5/ds5-options.h b/src/ds5/ds5-options.h index 4532f0f160..46b3b2c754 100644 --- a/src/ds5/ds5-options.h +++ b/src/ds5/ds5-options.h @@ -354,10 +354,10 @@ namespace librealsense std::shared_ptr