Module lens

Lens functions

Functions

focus(num_steps[, step_size=2[, wait=true[, delay]]]) Moves the focus motor a specified number of steps.
autofocus() Performs autofocus, similar to half-shutter press.

Fields

name Get the name of the lens (reported by the lens).
focal_length Get the focal length of the lens (in mm).
focus_distance Get the current focus distance (in mm).
focus_pos Get the raw relative focus motor position, in steps.
hyperfocal Get the hyperfocal distance of the lens (in mm).
dof_near Get the distance to the DOF near (in mm).
dof_far Get the distance to the DOF far (in mm).
af Get whether or not auto focus is enabled.
af_mode Get the current auto focus mode (may be model-specific, see PROP_AF_MODE in property.h).
autofocusing Get whether the lens is currently autofocusing.


Functions

focus(num_steps[, step_size=2[, wait=true[, delay]]])
Moves the focus motor a specified number of steps.

Only works in LiveView.

Parameters:

  • num_steps int How many steps to move the focus motor (signed).
  • step_size int Allowed values: 1, 2 or 3.

    Step 1 may give finer movements, but may get stuck or may be very slow on some lenses. (default 2)

  • wait bool Wait until each focus command finishes, before queueing others.

    wait=false may give smoother movements, but may no longer return accurate status for each command, and is known to crash on some cameras. The exact behavior may be camera- or lens-dependent.

    Do not disable it without a good reason! (default true)

  • delay int Delay between focus commands (ms)

    With wait=true, the delay is after each focus command is executed (as reported by Canon firmware).

    With wait=false, the delay is after each focus command is started (without waiting for it to finish).

    (default 0 if wait=true, 30ms if wait=false)

    (optional)

Returns:

    bool whether the operation was successful or not.
autofocus()
Performs autofocus, similar to half-shutter press.

Works in both LiveView and in plain photo mode.

Returns:

    bool whether the operation was successful or not.

Fields

name
Get the name of the lens (reported by the lens).
focal_length
Get the focal length of the lens (in mm). Only updated in LiveView.
  • focal_length int readonly
focus_distance
Get the current focus distance (in mm). Only updated in LiveView.
  • focus_distance int readonly
focus_pos
Get the raw relative focus motor position, in steps. This counter is 0 at camera startup, its range depend on the lens, and is updated only when the focus motor moves. It will lose track of the lens position during manual focus, unless you use a focus-by-wire lens. Details: www.magiclantern.fm/forum/index.php?topic=4997.
  • focus_pos int readonly
hyperfocal
Get the hyperfocal distance of the lens (in mm). Only updated in LiveView.

Computed from focal length, focus distance and aperture, see Focus -> DOF Settings menu for options.

  • hyperfocal int readonly
dof_near
Get the distance to the DOF near (in mm). Only updated in LiveView.

Computed from focal length, focus distance and aperture, see Focus -> DOF Settings menu for options.

  • dof_near int readonly
dof_far
Get the distance to the DOF far (in mm). Only updated in LiveView.

Computed from focal length, focus distance and aperture, see Focus -> DOF Settings menu for options.

  • dof_far int readonly
af
Get whether or not auto focus is enabled.
  • af bool readonly
af_mode
Get the current auto focus mode (may be model-specific, see PROP_AF_MODE in property.h).
  • af_mode int readonly
autofocusing
Get whether the lens is currently autofocusing.

This does not include manual lens movements from lens.focus or ML follow focus - only movements from Canon autofocus triggered by half-shutter / AF-ON / * button. It is updated several ms (sometimes hundreds of ms) after the half-shutter event.

On cameras with continuous autofocus, the return value is unknown - please report.

Known not to work on EOS M.

  • autofocusing bool readonly
generated by LDoc 1.4.3 Last updated 2018-12-23 23:12:04