mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Mount: set_focus replaces set_manual/auto_focus
This commit is contained in:
parent
2ff89498c5
commit
020a505d78
@ -143,13 +143,15 @@ bool AP_Mission::start_command_camera(const AP_Mission::Mission_Command& cmd)
|
|||||||
if ((cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_AUTO) ||
|
if ((cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_AUTO) ||
|
||||||
(cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_AUTO_SINGLE) ||
|
(cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_AUTO_SINGLE) ||
|
||||||
(cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_AUTO_CONTINUOUS)) {
|
(cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_AUTO_CONTINUOUS)) {
|
||||||
camera->set_auto_focus();
|
return camera->set_focus(FocusType::AUTO, 0);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
// accept step or continuous manual focus
|
// accept continuous manual focus
|
||||||
if (cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_CONTINUOUS) {
|
if (cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_CONTINUOUS) {
|
||||||
camera->set_manual_focus_step(cmd.content.set_camera_focus.focus_value);
|
return camera->set_focus(FocusType::RATE, cmd.content.set_camera_focus.focus_value);
|
||||||
return true;
|
}
|
||||||
|
// accept range manual focus
|
||||||
|
if (cmd.content.set_camera_focus.focus_type == FOCUS_TYPE_RANGE) {
|
||||||
|
return camera->set_focus(FocusType::PCT, cmd.content.set_camera_focus.focus_value);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -639,28 +639,17 @@ bool AP_Mount::set_zoom(uint8_t instance, ZoomType zoom_type, float zoom_value)
|
|||||||
return backend->set_zoom(zoom_type, zoom_value);
|
return backend->set_zoom(zoom_type, zoom_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set focus in, out or hold. returns true on success
|
// set focus specified as rate, percentage or auto
|
||||||
// focus in = -1, focus hold = 0, focus out = 1
|
// focus in = -1, focus hold = 0, focus out = 1
|
||||||
bool AP_Mount::set_manual_focus_step(uint8_t instance, int8_t focus_step)
|
bool AP_Mount::set_focus(uint8_t instance, FocusType focus_type, float focus_value)
|
||||||
{
|
{
|
||||||
auto *backend = get_instance(instance);
|
auto *backend = get_instance(instance);
|
||||||
if (backend == nullptr) {
|
if (backend == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return backend->set_manual_focus_step(focus_step);
|
return backend->set_focus(focus_type, focus_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto focus. returns true on success
|
|
||||||
bool AP_Mount::set_auto_focus(uint8_t instance)
|
|
||||||
{
|
|
||||||
auto *backend = get_instance(instance);
|
|
||||||
if (backend == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return backend->set_auto_focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AP_Mount_Backend *AP_Mount::get_primary() const
|
AP_Mount_Backend *AP_Mount::get_primary() const
|
||||||
{
|
{
|
||||||
return get_instance(_primary);
|
return get_instance(_primary);
|
||||||
|
@ -187,12 +187,9 @@ public:
|
|||||||
// set zoom specified as a rate or percentage
|
// set zoom specified as a rate or percentage
|
||||||
bool set_zoom(uint8_t instance, ZoomType zoom_type, float zoom_value);
|
bool set_zoom(uint8_t instance, ZoomType zoom_type, float zoom_value);
|
||||||
|
|
||||||
// set focus in, out or hold
|
// set focus specified as rate, percentage or auto
|
||||||
// focus in = -1, focus hold = 0, focus out = 1
|
// focus in = -1, focus hold = 0, focus out = 1
|
||||||
bool set_manual_focus_step(uint8_t instance, int8_t focus_step);
|
bool set_focus(uint8_t instance, FocusType focus_type, float focus_value);
|
||||||
|
|
||||||
// auto focus
|
|
||||||
bool set_auto_focus(uint8_t instance);
|
|
||||||
|
|
||||||
// parameter var table
|
// parameter var table
|
||||||
static const struct AP_Param::GroupInfo var_info[];
|
static const struct AP_Param::GroupInfo var_info[];
|
||||||
|
@ -137,12 +137,9 @@ public:
|
|||||||
// set zoom specified as a rate or percentage
|
// set zoom specified as a rate or percentage
|
||||||
virtual bool set_zoom(ZoomType zoom_type, float zoom_value) { return false; }
|
virtual bool set_zoom(ZoomType zoom_type, float zoom_value) { return false; }
|
||||||
|
|
||||||
// set focus in, out or hold. returns true on success
|
// set focus specified as rate, percentage or auto
|
||||||
// focus in = -1, focus hold = 0, focus out = 1
|
// focus in = -1, focus hold = 0, focus out = 1
|
||||||
virtual bool set_manual_focus_step(int8_t focus_step) { return false; }
|
virtual bool set_focus(FocusType focus_type, float focus_value) { return false; }
|
||||||
|
|
||||||
// auto focus. returns true on success
|
|
||||||
virtual bool set_auto_focus() { return false; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -644,17 +644,30 @@ bool AP_Mount_Siyi::set_zoom(ZoomType zoom_type, float zoom_value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set focus in, out or hold. returns true on success
|
// set focus specified as rate, percentage or auto
|
||||||
// focus in = -1, focus hold = 0, focus out = 1
|
// focus in = -1, focus hold = 0, focus out = 1
|
||||||
bool AP_Mount_Siyi::set_manual_focus_step(int8_t focus_step)
|
bool AP_Mount_Siyi::set_focus(FocusType focus_type, float focus_value)
|
||||||
{
|
{
|
||||||
|
switch (focus_type) {
|
||||||
|
case FocusType::RATE: {
|
||||||
|
uint8_t focus_step = 0;
|
||||||
|
if (focus_value > 0) {
|
||||||
|
focus_step = 1;
|
||||||
|
} else if (focus_value < 0) {
|
||||||
|
// Siyi API specifies -1 should be sent as 255
|
||||||
|
focus_step = UINT8_MAX;
|
||||||
|
}
|
||||||
return send_1byte_packet(SiyiCommandId::MANUAL_FOCUS, (uint8_t)focus_step);
|
return send_1byte_packet(SiyiCommandId::MANUAL_FOCUS, (uint8_t)focus_step);
|
||||||
}
|
}
|
||||||
|
case FocusType::PCT:
|
||||||
// auto focus. returns true on success
|
// not supported
|
||||||
bool AP_Mount_Siyi::set_auto_focus()
|
return false;
|
||||||
{
|
case FocusType::AUTO:
|
||||||
return send_1byte_packet(SiyiCommandId::AUTO_FOCUS, 1);
|
return send_1byte_packet(SiyiCommandId::AUTO_FOCUS, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unsupported focus type
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // HAL_MOUNT_SIYI_ENABLED
|
#endif // HAL_MOUNT_SIYI_ENABLED
|
||||||
|
@ -68,12 +68,9 @@ public:
|
|||||||
// set zoom specified as a rate or percentage
|
// set zoom specified as a rate or percentage
|
||||||
bool set_zoom(ZoomType zoom_type, float zoom_value) override;
|
bool set_zoom(ZoomType zoom_type, float zoom_value) override;
|
||||||
|
|
||||||
// set focus in, out or hold. returns true on success
|
// set focus specified as rate, percentage or auto
|
||||||
// focus in = -1, focus hold = 0, focus out = 1
|
// focus in = -1, focus hold = 0, focus out = 1
|
||||||
bool set_manual_focus_step(int8_t focus_step) override;
|
bool set_focus(FocusType focus_type, float focus_value) override;
|
||||||
|
|
||||||
// auto focus. returns true on success
|
|
||||||
bool set_auto_focus() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user