Module: MonomeSerial

Defined in:
lib/monome_serial.rb,
lib/monome_serial/examples/toggle.rb,
lib/monome_serial/monome_communicator.rb,
lib/monome_serial/serial_communicator.rb,
lib/monome_serial/serial_communicator/communicator.rb,
lib/monome_serial/serial_communicator/real_communicator.rb,
lib/monome_serial/serial_communicator/dummy_communicator.rb,
lib/monome_serial/serial_communicator/binary_patterns/series.rb,
lib/monome_serial/serial_communicator/binary_patterns/fourtyh.rb

Defined Under Namespace

Modules: Examples, SerialCommunicator Classes: MonomeCommunicator, NoMonomesFoundError

Class Method Summary collapse

Class Method Details

.detect_monomeObject



16
17
18
# File 'lib/monome_serial.rb', line 16

def self.detect_monome
  detect_monomes.first
end

.detect_monomesObject



20
21
22
# File 'lib/monome_serial.rb', line 20

def self.detect_monomes
  find_ttys.map{|tty| MonomeCommunicator.new(tty)}
end

.find_ttysObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/monome_serial.rb', line 24

def self.find_ttys
  possible_monome_io_file_matchers = ['/dev/ttyUSB*', '/dev/tty.usbserial-m*']
  files = possible_monome_io_file_matchers.inject([]) do |files, to_try|
    files << Dir[to_try]
  end

  files.flatten!

  if files.empty? then
    raise NoMonomesFoundError,
    "No monomes were found connected to your computer"
  end

  files
end