Module: BrickPi::Configuration

Included in:
Bot
Defined in:
lib/brick_pi/configuration.rb

Instance Method Summary collapse

Instance Method Details

#color_sensor(port) ⇒ Object



49
50
51
# File 'lib/brick_pi/configuration.rb', line 49

def color_sensor(port)
  sensor(port, :color)
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



11
12
13
# File 'lib/brick_pi/configuration.rb', line 11

def configure &block
  yield self
end

#motor(port) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/brick_pi/configuration.rb', line 15

def motor(port)
  case port
  when :port_A
    @motor_A = BrickPi::Motor.new(Native::PORT_A)
  when :port_B
    @motor_B = BrickPi::Motor.new(Native::PORT_B)
  when :port_C
    @motor_C = BrickPi::Motor.new(Native::PORT_C)
  when :port_D
    @motor_D = BrickPi::Motor.new(Native::PORT_D)
  end
end

#sensor(port, sensor_type) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/brick_pi/configuration.rb', line 28

def sensor(port, sensor_type)
  case port
  when :port_1
    @sensor_1 = BrickPi::Sensor.new(:port_1, sensor_type)
  when :port_2
    @sensor_2 = BrickPi::Sensor.new(:port_2, sensor_type)
  when :port_3
    @sensor_3 = BrickPi::Sensor.new(:port_3, sensor_type)
  when :port_4
    @sensor_4 = BrickPi::Sensor.new(:port_4, sensor_type)
  end
end

#touch_sensor(port) ⇒ Object



41
42
43
# File 'lib/brick_pi/configuration.rb', line 41

def touch_sensor(port)
  sensor(port, :touch)
end

#ultrasonic_sensor(port) ⇒ Object



45
46
47
# File 'lib/brick_pi/configuration.rb', line 45

def ultrasonic_sensor(port)
  sensor(port, :ultrasonic)
end