class LD220

Constants

VERSION

Attributes

debug[RW]

Public Class Methods

new(device, mode, options = {}) click to toggle source
# File lib/ld220.rb, line 7
def initialize(device, mode, options = {})
  extend mode
  options[:speed] ||= 9600
  @debug = options[:debug]
  @display = Serial.new device, options[:speed]
end

Public Instance Methods

type(string, delay = 0.1) click to toggle source
# File lib/ld220.rb, line 14
def type(string, delay = 0.1)
  clear
  sleep delay
  string.split('').each do |char|
    write char
    sleep delay
  end
end
write(data) click to toggle source
# File lib/ld220.rb, line 23
def write(data)
  data = data.encode Encoding::US_ASCII
  puts "Sending: #{data.inspect}" if @debug
  @display.write data
end