Class: HelloPaLcd

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/hello_pa_lcd.rb

Instance Attribute Summary

Attributes inherited from ArduinoSketch

#pins

Instance Method Summary collapse

Methods inherited from ArduinoSketch

#add, add_to_setup, #array, #assembler, #comment_box, #compose_setup, #define, #delay, #digitalWrite, #formatted_print, #initialize, #input_pin, #input_pins, output_pin, #output_pin, post_process_ruby_to_c_methods, pre_process, #serial_begin

Methods included from ExternalVariableProcessing

#c_type, #check_variable_type, #post_process_arrays, #post_process_vars, #pre_process_vars, #process_external_vars, #translate_variables

Constructor Details

This class inherits a constructor from ArduinoSketch

Instance Method Details

#loopObject



25
26
27
28
29
# File 'lib/examples/hello_pa_lcd.rb', line 25

def loop  
  say_hello     if button_one.read_input 
  say_more      if button_two.read_input 
  say_it_large  if button_three.read_input 
end

#say_helloObject



31
32
33
34
35
36
37
# File 'lib/examples/hello_pa_lcd.rb', line 31

def say_hello
  @toggle = true
  my_lcd.clearscr "Any sufficiently    advanced technology"
  my_lcd.setxy 0,2
  my_lcd.setxy 0,3, "toggle state: "
  my_lcd.print @toggle
end

#say_it_largeObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/examples/hello_pa_lcd.rb', line 47

def say_it_large

  my_lcd.intoBignum
  my_lcd.clearscr            # line 0, col 0
  1.upto(32) do |i|
    my_lcd.setxy 0,1
    my_lcd.print i * i
    delay 200
  end
  my_lcd.outofBignum
end

#say_moreObject

passing print strings to home and setxy (also works on clearscr)



39
40
41
42
43
44
# File 'lib/examples/hello_pa_lcd.rb', line 39

def say_more # passing print strings to home and setxy (also works on clearscr)
  @toggle = false
  my_lcd.clearscr "is indistinguishablefrom magic"
  my_lcd.setxy 0,3, "toggle state: "
  my_lcd.print @toggle
end

#setupObject



17
18
19
20
21
22
23
# File 'lib/examples/hello_pa_lcd.rb', line 17

def setup
  delay 3000
  my_lcd.setxy 0,0
  my_lcd.print "Press button"
  my_lcd.setxy 0,1
  my_lcd.print "One, two or three...."
end