Class: LGPIO::Infrared

Inherits:
HardwarePWM show all
Defined in:
lib/lgpio/infrared.rb

Constant Summary collapse

FREQUENCY =
38_000
DUTY =
33.333

Constants inherited from HardwarePWM

HardwarePWM::NS_PER_S, HardwarePWM::NS_PER_US, HardwarePWM::SYS_FS_PWM_PATH

Instance Attribute Summary

Attributes inherited from HardwarePWM

#duty, #enabled, #period, #polarity

Instance Method Summary collapse

Methods inherited from HardwarePWM

#disable, #duty_path, #duty_percent, #duty_percent=, #duty_us=, #enable, #enable_path, #frequency, #frequency=, #path, #period_path, #polarity_path, #tx_wave_ook

Constructor Details

#initialize(*args, **kwargs) ⇒ Infrared

Returns a new instance of Infrared.



6
7
8
9
10
11
# File 'lib/lgpio/infrared.rb', line 6

def initialize(*args, **kwargs)
  new_kwargs = {frequency: FREQUENCY}.merge(kwargs)
  super(*args, **new_kwargs)
  # Avoid needing to call #enable and #disable, before and after each #transmit call.
  # disable
end

Instance Method Details

#transmit(pulses, duty: DUTY) ⇒ Object



13
14
15
16
# File 'lib/lgpio/infrared.rb', line 13

def transmit(pulses, duty: DUTY)
  self.duty_percent = duty
  tx_wave_ook(duty_path, @duty.to_s, pulses)
end