Sha256: 1682dcb9b2c6a67fa0d5045114f2834626af756d156b702b863e044787fd6d36

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

#require external libraries
require 'active_support'
require 'fcntl'

require 'monome_serial/serial_communicator'
require 'monome_serial/serial_communicator/communicator'
require 'monome_serial/serial_communicator/dummy_communicator'
require 'monome_serial/serial_communicator/binary_patterns/series'
require 'monome_serial/serial_communicator/binary_patterns/fourtyh'
require 'monome_serial/monome_communicator'
require 'monome_serial/examples/toggle'

module MonomeSerial
  class NoMonomesFoundError < StandardError ; end

  def self.detect_monome
    detect_monomes.first
  end

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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
monome_serial-1.1.0 lib/monome_serial.rb