Class: PiLightsControl::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/pi-lights-control/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pin, options = {}) ⇒ Command

Returns a new instance of Command.



5
6
7
8
9
# File 'lib/pi-lights-control/command.rb', line 5

def initialize(pin, options = {})
  RPi::GPIO.set_numbering(options[:numbering] || :board)
  @repeat_count = 6
  @pin = pin
end

Instance Attribute Details

#repeat_countObject

Returns the value of attribute repeat_count.



3
4
5
# File 'lib/pi-lights-control/command.rb', line 3

def repeat_count
  @repeat_count
end

Instance Method Details

#power_offObject



11
12
13
# File 'lib/pi-lights-control/command.rb', line 11

def power_off
  transmit_command(PiLightsControl::COMMAND_TABLE[:power_off])
end

#power_onObject



15
16
17
# File 'lib/pi-lights-control/command.rb', line 15

def power_on
  transmit_command(PiLightsControl::COMMAND_TABLE[:power_on])
end

#program(name) ⇒ Object



19
20
21
22
# File 'lib/pi-lights-control/command.rb', line 19

def program(name)
  program_name = "program_#{name.to_s}"
  transmit_command(PiLightsControl::COMMAND_TABLE[program_name.to_sym])
end

#sync_lightsObject



24
25
26
# File 'lib/pi-lights-control/command.rb', line 24

def sync_lights
  transmit_command(PiLightsControl::COMMAND_TABLE[:sync_lights])
end