Class: Denko::PulseIO::PWMOutput

Inherits:
DigitalIO::Output show all
Defined in:
lib/denko/pulse_io/pwm_output.rb

Direct Known Subclasses

LED::Base, Buzzer

Instance Attribute Summary

Attributes included from Behaviors::Threaded

#interrupts_enabled, #thread

Attributes included from Behaviors::Callbacks

#callback_mutex

Attributes included from Behaviors::SinglePin

#mode, #pin

Attributes included from Behaviors::Component

#board

Instance Method Summary collapse

Methods inherited from DigitalIO::Output

#after_initialize, #digital_write, #high, #high?, #low, #low?, #pre_callback_filter, #toggle

Methods included from Behaviors::Threaded

#enable_interrupts, included, #stop, #stop_thread, #threaded, #threaded_loop

Methods included from Behaviors::Callbacks

#add_callback, #callbacks, #initialize, #pre_callback_filter, #remove_callback, #update

Methods included from Behaviors::State

#initialize, #state

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Method Details

#initialize_pins(options = {}) ⇒ Object



6
7
8
# File 'lib/denko/pulse_io/pwm_output.rb', line 6

def initialize_pins(options={})
  super(options)
end

#pwm_disableObject



29
30
31
# File 'lib/denko/pulse_io/pwm_output.rb', line 29

def pwm_disable
  self.mode = :output
end

#pwm_enableObject



25
26
27
# File 'lib/denko/pulse_io/pwm_output.rb', line 25

def pwm_enable
  self.mode = :output_pwm unless mode == :output_pwm
end

#pwm_write(value) ⇒ Object



20
21
22
23
# File 'lib/denko/pulse_io/pwm_output.rb', line 20

def pwm_write(value)
  pwm_enable
  board.pwm_write(pin, @state = value)
end

#write(value) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/denko/pulse_io/pwm_output.rb', line 10

def write(value)
  if value == board.low
    digital_write(board.low)
  elsif value == board.pwm_high
    digital_write(board.high)
  else
    pwm_write(value)
  end
end