Class: Denko::PulseIO::IROutput
- Inherits:
-
Object
- Object
- Denko::PulseIO::IROutput
- Includes:
- Behaviors::Lifecycle, Behaviors::SinglePin
- Defined in:
- lib/denko/pulse_io/ir_output.rb
Constant Summary
Constants included from Behaviors::Lifecycle
Behaviors::Lifecycle::CALLBACK_METHODS
Instance Attribute Summary
Attributes included from Behaviors::SinglePin
Attributes included from Behaviors::Component
Attributes included from Behaviors::State
Instance Method Summary collapse
Methods included from Behaviors::Lifecycle
Methods included from Behaviors::SinglePin
#convert_pins, #initialize_pins
Methods included from Behaviors::Component
Methods included from Behaviors::State
Instance Method Details
#write(pulses = [], frequency: 38) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/denko/pulse_io/ir_output.rb', line 7 def write(pulses=[], frequency: 38) if pulses.length > 255 || pulses.length < 1 raise ArgumentError, 'wrong number of IR pulses (expected 1 to 255)' end pulses.each_with_index do |pulse, index| raise ArgumentError, 'non Numeric data in IR signal' unless pulse.is_a? Numeric pulses[index] = pulse.round unless pulse.is_a? Integer raise ArgumentError, 'pulse too long (max 65535 ms)' if pulse > 65535 end board.infrared_emit(pin, frequency, pulses) end |