Class: Lorraine::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/lorraine/connection.rb

Instance Method Summary collapse

Constructor Details

#initializeConnection

Returns a new instance of Connection.



5
6
# File 'lib/lorraine/connection.rb', line 5

def initialize
end

Instance Method Details

#animate_to_image(other_image, duration = 1, fps = 24) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/lorraine/connection.rb', line 29

def animate_to_image(other_image, duration = 1, fps = 24)
  frame_time = duration.to_f / fps.to_f
  frame_count = duration * fps
  frames = Lorraine::Image.frames_between(@current_image, other_image, frame_count)
  frames.each do |frame|
    display_image frame
    sleep frame_time
  end
end

#display_image(img) ⇒ Object



24
25
26
27
# File 'lib/lorraine/connection.rb', line 24

def display_image(img)
  @current_image = img
  display_pixels img.rgb_pixels(4095)
end

#display_pixels(pixel_array) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lorraine/connection.rb', line 12

def display_pixels(pixel_array)
  commands = []
  pixel_array.each_with_index do |pixel, i|
    commands << Lorraine::Message.new(:set_pixel, i, pixel[0], pixel[1], pixel[2])
  end
  commands << Lorraine::Message.new(:refresh)
  commands.each do |command|
    self.write_message command
    #self.read_line
  end
end

#sever!Object



39
40
41
# File 'lib/lorraine/connection.rb', line 39

def sever!
  
end

#write_message(msg) ⇒ Object



8
9
10
# File 'lib/lorraine/connection.rb', line 8

def write_message(msg)
  puts "Writing message unimplemented."
end