Class: ScopeWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- ScopeWindow
- Defined in:
- lib/window.rb
Instance Attribute Summary collapse
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#display_pins ⇒ Object
Returns the value of attribute display_pins.
-
#max_volts ⇒ Object
readonly
Returns the value of attribute max_volts.
-
#scope_width ⇒ Object
readonly
Returns the value of attribute scope_width.
-
#yscale ⇒ Object
readonly
Returns the value of attribute yscale.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ ScopeWindow
constructor
A new instance of ScopeWindow.
- #update ⇒ Object
Constructor Details
#initialize ⇒ ScopeWindow
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
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
2 3 4 |
# File 'lib/window.rb', line 2 def clock @clock end |
#display_pins ⇒ Object
Returns the value of attribute display_pins.
3 4 5 |
# File 'lib/window.rb', line 3 def display_pins @display_pins end |
#max_volts ⇒ Object (readonly)
Returns the value of attribute max_volts.
2 3 4 |
# File 'lib/window.rb', line 2 def max_volts @max_volts end |
#scope_width ⇒ Object (readonly)
Returns the value of attribute scope_width.
2 3 4 |
# File 'lib/window.rb', line 2 def scope_width @scope_width end |
#yscale ⇒ Object (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 (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 |
#draw ⇒ Object
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 |
#update ⇒ Object
34 35 36 37 |
# File 'lib/window.rb', line 34 def update return if @paused AnalogInput.all.each {|i| i.update } end |