Class: Rustle::Receiver
- Inherits:
-
Object
- Object
- Rustle::Receiver
- Defined in:
- lib/rustle/receiver.rb
Overview
Receivers
Your receiver is, effectively, your Arduino. The receiver class’s purpose is to manage the serial communication between Ruby and your Arduino, and to ensure that changes made to a Strip object are reflected immediately on the actual LED strip. This class, however, is not responsible for actual serialization; the Frame and Color classes serialize themselves.
The Receiver class is initialized using a block.
bedroom_arduino = Rustle::Receiver.new do
port_file "/dev/[PORT_FILE]"
num_leds 30
end
Your port file can be found using the Arduino IDE.
Instance Attribute Summary collapse
-
#strip ⇒ Strip
readonly
When your receiver is instantiated, a Strip object is automatically created alongside it.
Instance Method Summary collapse
-
#initialize {|port_file, baud, num_leds| ... } ⇒ Receiver
constructor
Initializes a new receiver.
-
#push_frame(frame) ⇒ Object
Serializes
frameand sends it off to the the serial port.
Constructor Details
#initialize {|port_file, baud, num_leds| ... } ⇒ Receiver
Initializes a new receiver.
42 43 44 45 46 47 48 49 |
# File 'lib/rustle/receiver.rb', line 42 def initialize(&block) # Default value @baud = 921_600 instance_eval &block init_serialport end |
Instance Attribute Details
Instance Method Details
#push_frame(frame) ⇒ Object
Serializes frame and sends it off to the the serial port. push_frame is used internally, so its direct use is discouraged, but it would work in theory.
55 56 57 |
# File 'lib/rustle/receiver.rb', line 55 def push_frame(frame) @port.write frame.serialize end |