Class: Rubycam::Control
- Inherits:
-
Object
- Object
- Rubycam::Control
- Defined in:
- lib/rubycam/controls.rb
Overview
A single camera control (brightness, zoom_absolute, ...) discovered via VIDIOC_QUERYCTRL. Reading and writing goes through the owning device.
Constant Summary collapse
- TYPES =
{ 1 => :integer, 2 => :boolean, 3 => :menu, 4 => :button, 5 => :integer64, 6 => :ctrl_class, 7 => :string, 8 => :bitmask, 9 => :integer_menu }.freeze
- FLAG_DISABLED =
0x0001- FLAG_GRABBED =
0x0002- FLAG_READ_ONLY =
0x0004- FLAG_INACTIVE =
0x0010
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #inactive? ⇒ Boolean
-
#initialize(device, id:, type:, name:, min:, max:, step:, default:, flags:) ⇒ Control
constructor
A new instance of Control.
-
#key ⇒ Object
Symbol key derived from the control name, e.g.
- #read_only? ⇒ Boolean
- #to_s ⇒ Object
- #value ⇒ Object
- #value=(v) ⇒ Object
Constructor Details
#initialize(device, id:, type:, name:, min:, max:, step:, default:, flags:) ⇒ Control
Returns a new instance of Control.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubycam/controls.rb', line 16 def initialize(device, id:, type:, name:, min:, max:, step:, default:, flags:) @device = device @id = id @type = TYPES.fetch(type, type) @name = name @min = min @max = max @step = step @default = default @flags = flags end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def default @default end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def flags @flags end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def id @id end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def min @min end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def name @name end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def step @step end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/rubycam/controls.rb', line 14 def type @type end |
Instance Method Details
#inactive? ⇒ Boolean
38 |
# File 'lib/rubycam/controls.rb', line 38 def inactive? = flags & FLAG_INACTIVE != 0 |
#key ⇒ Object
Symbol key derived from the control name, e.g. "Zoom, Absolute" => :zoom_absolute
29 |
# File 'lib/rubycam/controls.rb', line 29 def key = @key ||= name.downcase.gsub(/[^a-z0-9]+/, '_').gsub(/^_|_$/, '').to_sym |
#read_only? ⇒ Boolean
39 |
# File 'lib/rubycam/controls.rb', line 39 def read_only? = flags & FLAG_READ_ONLY != 0 |
#to_s ⇒ Object
41 42 43 |
# File 'lib/rubycam/controls.rb', line 41 def to_s "#{key} (#{type}) min=#{min} max=#{max} step=#{step} default=#{default} value=#{value}" end |
#value ⇒ Object
31 |
# File 'lib/rubycam/controls.rb', line 31 def value = @device.get_control(id) |
#value=(v) ⇒ Object
33 34 35 36 |
# File 'lib/rubycam/controls.rb', line 33 def value=(v) clamped = v.clamp(min, max) @device.set_control(id, clamped) end |