Class: ScopeWindow

Inherits:
Gosu::Window
  • Object
show all
Defined in:
lib/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScopeWindow

Returns a new instance of ScopeWindow.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/window.rb', line 4

def initialize
  super 1024+124,768

  @scope_width = 1023
  self.caption = "Oscilloscope"

  @font = Gosu::Font.new(18)

  @max_volts = 5
  @yscale=(self.height/@max_volts)
  @paused = false

  @center_line = CenterLine.new(self)
  @minmaxtext = MinMaxText.new(self)
  @right_line = RightLine.new(self)
  @ar = ArduinoReader.new(self)
  # @ar = FakeArduinoReader.new(self)
  AnalogInput[0].visible = true
end

Instance Attribute Details

#clockObject (readonly)

Returns the value of attribute clock.



2
3
4
# File 'lib/window.rb', line 2

def clock
  @clock
end

#display_pinsObject

Returns the value of attribute display_pins.



3
4
5
# File 'lib/window.rb', line 3

def display_pins
  @display_pins
end

#max_voltsObject (readonly)

Returns the value of attribute max_volts.



2
3
4
# File 'lib/window.rb', line 2

def max_volts
  @max_volts
end

#scope_widthObject (readonly)

Returns the value of attribute scope_width.



2
3
4
# File 'lib/window.rb', line 2

def scope_width
  @scope_width
end

#yscaleObject (readonly)

Returns the value of attribute yscale.



2
3
4
# File 'lib/window.rb', line 2

def yscale
  @yscale
end

Instance Method Details

#button_down(id) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/window.rb', line 24

def button_down(id)
  close if id == Gosu::KbEscape or id == Gosu::KbQ
  @paused = ! @paused if id == Gosu::KbP

  [Gosu::Kb0,Gosu::Kb1,Gosu::Kb2,Gosu::Kb3,Gosu::Kb4,Gosu::Kb5].each_with_index {|b,i|
      AnalogInput[i].visible = ! AnalogInput[i].visible if AnalogInput[i] if id == b
  }

end

#drawObject



39
40
41
42
43
44
45
# File 'lib/window.rb', line 39

def draw
  # Draw interface
  @center_line.draw
  @right_line.draw
  @minmaxtext.draw
  AnalogInput.all.each {|i| i.draw }
end

#updateObject



34
35
36
37
# File 'lib/window.rb', line 34

def update
  return if @paused
  AnalogInput.all.each {|i| i.update }
end