Class: FakeArduinoReader

Inherits:
ArduinoReader show all
Defined in:
lib/arduino_reader.rb

Instance Method Summary collapse

Methods inherited from ArduinoReader

#initialize

Constructor Details

This class inherits a constructor from ArduinoReader

Instance Method Details

#connectObject



35
36
37
38
# File 'lib/arduino_reader.rb', line 35

def connect
  @inputs << AnalogInput.new(window: @window, pin: 0)
  @inputs << AnalogInput.new(window: @window, pin: 1)
end

#pwmObject



40
41
42
# File 'lib/arduino_reader.rb', line 40

def pwm
  return true
end

#setup_callbacksObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/arduino_reader.rb', line 44

def setup_callbacks
  Thread.new {
    loop do
      AnalogInput[0].callback(0)
      AnalogInput[1].callback(rand(1023))
      sleep 0.09
      AnalogInput[0].callback(1023)
      sleep 0.09
    end
  }
end