class HelloFormatPrint

Public Instance Methods

loop() click to toggle source
# File lib/examples/hello_format_print.rb, line 44
def loop 
  if millis % 500 == 0
    write_line "millis()= %ld", millis
    my_lcd.setxy 1, 2, string_line
  end 
  say_hello     if button_one.read_input 
  say_more      if button_two.read_input 
  say_it_large  if button_three.read_input 
end
say_hello() click to toggle source
# File lib/examples/hello_format_print.rb, line 54
def say_hello
  @toggle = true
  my_lcd.clearscr "This sketch has?nbeen running for?n "
  write_line "%ld mins and %d secs?n", millis/60000, (millis/1000)%60
  my_lcd.print string_line
  delay 3000
  my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
end
say_it_large() click to toggle source
# File lib/examples/hello_format_print.rb, line 78
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
  delay 3000
  my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"      
end
say_more() click to toggle source
# File lib/examples/hello_format_print.rb, line 63
  def say_more # passing print strings to home and setxy (also works on clearscr)
    @toggle = false
    my_lcd.clearscr "Food Store Prices"
    write_line "Pies $%2d.%02d", @pie_cents/100, @pie_cents%100
#    write_line "Pies $%6.2f", @pie_price # float doessn't seem to work .....
    my_lcd.setxy 2, 1, string_line
#    write_line "toggle state is [%s]", @toggle ? "ON" : "OFF"  # RubyToC screws this construct up and RAD mistajekl put 1 ad 0
                                                                # in place of "ON" and "OFF"
    write_line "toggle state is [%d]", @toggle
    my_lcd.setxy 2, 3, string_line
    delay 3000
    my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
  end
setup() click to toggle source
# File lib/examples/hello_format_print.rb, line 40
def setup
  my_lcd.clearscr " --<Press Button>--?nOne, Two, or Three"
end