Module: NXT::Command::LowSpeed
- Extended by:
- Utils::Accessors
- Includes:
- Base
- Included in:
- NXT::Connector::Input::Ultrasonic
- Defined in:
- lib/nxt/commands/low_speed.rb
Overview
An implementation of all the low speed I2C related NXT commands:
-
LSGETSTATUS
-
LSWRITE
-
LSREAD
This class can also be used to talk to other third-party accessories connected in the input ports on the NXT brick that talk using I2C low speed master/slave communication.
Constant Summary collapse
- COMMAND_IDENTIFIER =
{ ls_get_status: 0x0E, ls_write: 0x0F, ls_read: 0x10 }.freeze
Instance Method Summary collapse
- #command_type ⇒ Object
- #ls_clear_buffer ⇒ Object
- #ls_get_status(response_required: false) ⇒ Object
- #ls_read(response_required: false) ⇒ Object
- #ls_write(response_required: false) ⇒ Object
Methods included from Utils::Accessors
Methods included from Utils::Assertions
#assert_in, #assert_responds_to, #assert_type
Instance Method Details
#command_type ⇒ Object
24 25 26 |
# File 'lib/nxt/commands/low_speed.rb', line 24 def command_type COMMAND_TYPES[:direct] end |
#ls_clear_buffer ⇒ Object
28 29 30 31 32 |
# File 'lib/nxt/commands/low_speed.rb', line 28 def ls_clear_buffer ls_read rescue StandardError nil end |
#ls_get_status(response_required: false) ⇒ Object
34 35 36 |
# File 'lib/nxt/commands/low_speed.rb', line 34 def ls_get_status(response_required: false) send_and_receive(COMMAND_IDENTIFIER[:ls_get_status], [], response_required) end |
#ls_read(response_required: false) ⇒ Object
42 43 44 |
# File 'lib/nxt/commands/low_speed.rb', line 42 def ls_read(response_required: false) send_and_receive(COMMAND_IDENTIFIER[:ls_read], [], response_required) end |
#ls_write(response_required: false) ⇒ Object
38 39 40 |
# File 'lib/nxt/commands/low_speed.rb', line 38 def ls_write(response_required: false) send_and_receive(COMMAND_IDENTIFIER[:ls_write], [], response_required) end |