Class: PanTilt::CommandLine
- Inherits:
-
Object
- Object
- PanTilt::CommandLine
- Defined in:
- lib/pan_tilt/command_line.rb
Instance Method Summary collapse
-
#initialize(debug = false) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #run ⇒ Object
Constructor Details
#initialize(debug = false) ⇒ CommandLine
Returns a new instance of CommandLine.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/pan_tilt/command_line.rb', line 3 def initialize(debug=false) = { debug: debug, pan_position: PanTilt::PAN_START_POSITION, tilt_position: PanTilt::TILT_START_POSITION } @board = Dino::Board.new(Dino::TxRx::Serial.new) @rotor = PanTilt::Rotor.new @board, @led = Dino::Components::Led.new(pin: PanTilt::LIVE_LED, board: @board) end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pan_tilt/command_line.rb', line 14 def run print_instructions @led.send :on while key = STDIN.getch case key when PanTilt::ESCAPE @led.send :off break when PanTilt::LEFT_ARROW @rotor.rotate_by (- PanTilt::INCREMENT), 0 when PanTilt::RIGHT_ARROW @rotor.rotate_by PanTilt::INCREMENT, 0 when PanTilt::DOWN_ARROW @rotor.rotate_by 0, (- PanTilt::INCREMENT) when PanTilt::UP_ARROW @rotor.rotate_by 0, PanTilt::INCREMENT end end end |