Class: ObjectOrientedBeagleboneBlack::Led
- Inherits:
-
Object
- Object
- ObjectOrientedBeagleboneBlack::Led
- Includes:
- IO, PinMappings
- Defined in:
- lib/object_oriented_beaglebone_black/led.rb
Constant Summary collapse
- LED_RELATIVE_DIRECTORY_PATTERN =
"leds/beaglebone:green:%s"- TRIGGER_FILENAME =
"trigger"- GPIO_FILENAME =
"brightness"
Instance Method Summary collapse
- #digital_write(state) ⇒ Object
-
#initialize(led_name) ⇒ Led
constructor
A new instance of Led.
- #pin_mode=(pin_mode) ⇒ Object
- #state ⇒ Object
Methods included from IO
#read_from_io_file, #write_to_io_file
Methods included from PinMappings
#load_pin_index_array, #property_hash
Constructor Details
#initialize(led_name) ⇒ Led
Returns a new instance of Led.
10 11 12 |
# File 'lib/object_oriented_beaglebone_black/led.rb', line 10 def initialize(led_name) @led_name = led_name end |
Instance Method Details
#digital_write(state) ⇒ Object
23 24 25 |
# File 'lib/object_oriented_beaglebone_black/led.rb', line 23 def digital_write(state) write_to_io_file(GPIO_FILENAME, state) end |
#pin_mode=(pin_mode) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/object_oriented_beaglebone_black/led.rb', line 14 def pin_mode=(pin_mode) case pin_mode when "out" write_to_io_file(TRIGGER_FILENAME, "gpio") else raise "Invalid pin_mode for Led: #{pin_mode}. Must be 'out'" end end |
#state ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/object_oriented_beaglebone_black/led.rb', line 27 def state state = read_from_io_file(GPIO_FILENAME) begin state.to_i rescue state end end |