class Artoo::Drivers::Led
The LED driver behaviors
Constants
- COMMANDS
Public Class Methods
new(params = {})
click to toggle source
Calls superclass method
# File lib/artoo/drivers/led.rb, line 12 def initialize(params = {}) @is_on = false super end
Public Instance Methods
brightness(level=0)
click to toggle source
Change brightness level @param [Integer] level
# File lib/artoo/drivers/led.rb, line 49 def brightness(level=0) connection.pwm_write(pin, level) end
off()
click to toggle source
Sets led to level LOW
# File lib/artoo/drivers/led.rb, line 35 def off change_state(pin, :low) @is_on = false true end
off?()
click to toggle source
@return [Boolean] True if off
# File lib/artoo/drivers/led.rb, line 23 def off? (not on?) end
on()
click to toggle source
Sets led to level HIGH
# File lib/artoo/drivers/led.rb, line 28 def on change_state(pin, :high) @is_on = true true end
on?()
click to toggle source
@return [Boolean] True if on
# File lib/artoo/drivers/led.rb, line 18 def on? @is_on end
toggle()
click to toggle source
Toggle status @example on > off, off > on
# File lib/artoo/drivers/led.rb, line 43 def toggle on? ? off : on end
Private Instance Methods
change_state(pin, level)
click to toggle source
# File lib/artoo/drivers/led.rb, line 54 def change_state(pin, level) connection.digital_write(pin, level) end