module GPhoto2::Camera::Configuration

Overview

Provides access to camera configuration.

Direct including types

Defined in:

gphoto2/camera/configuration.cr

Instance Method Summary

Instance Method Detail

def <<(widget : CameraWidget::Base) : self #
iso = camera[:iso].as_radio
iso.value = iso.choices.first
camera << iso

[View source]
def [](key : String | Symbol) : CameraWidget::Base #

Returns the attribute identified by key.

See: #config

camera[:whitebalance].to_s  # => "Automatic"
camera["whitebalance"].to_s # => "Automatic"

[View source]
def []=(key : String | Symbol, value) #

Updates the attribute identified by key with the specified value.

This marks the configuration as "dirty", meaning a call to #save is needed to actually update the configuration on the camera.

camera["iso"] = 800
camera["f-number"] = "f/2.8"
camera["shutterspeed2"] = "1/60"

[View source]
def []?(key : String | Symbol) : CameraWidget::Base | Nil #

Returns the attribute identified by key.

See: #config

camera[:whitebalance].to_s  # => "Automatic"
camera["whitebalance"].to_s # => "Automatic"

[View source]
def config : Hash(String, CameraWidget::Base) #

Returns flattened Hash of camera attributes.

# List camera configuration keys.
camera.config.keys # => ["autofocusdrive", "manualfocusdrive", "controlmode", ...]

See also: #[] and #[]=


[View source]
def dirty? #

Returns true if any attributes have unsaved changes.

camera.dirty? # => false
camera[:iso] = 400
camera.dirty? # => true

[View source]
def preserving_config(keys : Enumerable(String | Symbol) | Nil = nil, &) : Nil #

Preserves config for a block call.

# Original values
camera[:aperture] # => 4
camera[:iso]      # => 400

# Capture photo with different settings,
# while preserving original values
camera.preserving_config do
  1.upto(3) do |i|
    camera.update({
      aperture: 8,
      iso:      200 * i,
    })
    file = camera.capture
    file.save
  end
end

# Original values are being preserved
camera[:aperture] # => 4
camera[:iso]      # => 400

[View source]
def reload : Nil #

Reloads camera configuration.

All unsaved changes will be lost.

camera[:iso] # => 800
camera[:iso] = 200
camera.reload
camera[:iso] # => 800

[View source]
def save : Bool #

Updates the configuration on the camera.

camera[:iso] = 800
camera.save # => true
camera.save # => false (nothing to update)

[View source]
def update(attributes) : Bool #

Updates camera attributes from the given Hash, NamedTuple or keyword arguments (**kwargs) and saves the configuration.

camera[:iso]           # => 800
camera[:shutterspeed2] # => "1/30"

# **kwargs
camera.update(iso: 400, shutterspeed2: "1/60")
# NamedTuple
camera.update({iso: 400, shutterspeed2: "1/60"})
# Hash
camera.update({"iso" => 400, "shutterspeed2" => "1/60"})

camera[:iso]           # => 400
camera[:shutterspeed2] # => "1/60"

[View source]
def window : CameraWidget::Window #

Returns camera root configuration widget.


[View source]