Module: BlinkStick::ColorHandler
- Included in:
- BlinkStick
- Defined in:
- lib/blink_stick/color_handler.rb
Instance Method Summary collapse
Instance Method Details
#color ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/blink_stick/color_handler.rb', line 12 def color result = @handle.control_transfer(bmRequestType: 0x80 | 0x20, bRequest: 0x1, wValue: 0x1, wIndex: 0x0000, dataIn: 4) [result[1].ord, result[2].ord, result[3].ord] end |
#color=(value) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/blink_stick/color_handler.rb', line 2 def color=(value) data_out = transform_color_to_hex(Color.parse(value)) @handle.control_transfer(bmRequestType: 0x20, bRequest: 0x9, wValue: 0x1, wIndex: 0x0000, dataOut: data_out) end |
#off ⇒ Object
22 23 24 |
# File 'lib/blink_stick/color_handler.rb', line 22 def off self.color = [0, 0, 0] end |
#random_color ⇒ Object
26 27 28 29 |
# File 'lib/blink_stick/color_handler.rb', line 26 def random_color r = Random.new self.color = [r.rand(255), r.rand(255), r.rand(255)] end |