Class: HelloClock

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/hello_clock.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



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/examples/hello_clock.rb', line 45

def loop
    mainloop.track
    myLCD.setxy 12,3,  mainloop.get_total
    rtc.get clock, 1
    if clock[0] == 0
      if @flag == 0
        print_main
        @flag = 1
      end
    else
      @flag = 0
    end
   	myLCD.setxy 6,2
   	printlz clock[2]
   	myLCD.print ":"
   printlz clock[1]
   	myLCD.print ":"
   printlz clock[0]

   delay 50
    
end


73
74
75
76
77
78
79
80
81
82
# File 'lib/examples/hello_clock.rb', line 73

def	print_main
  myLCD.setxy 1,1, @days[clock[3]-1]
myLCD.print ", "
  myLCD.print @months[clock[5]-1]
  myLCD.print " "
  printlz clock[4]
  myLCD.print ", "
  printlz clock[6] + 2000
  
end

#printlz(w) ⇒ Object



68
69
70
71
# File 'lib/examples/hello_clock.rb', line 68

def	printlz(w)
			myLCD.print "0" if w < 10
			myLCD.print w
end

#setupObject



37
38
39
40
41
42
43
# File 'lib/examples/hello_clock.rb', line 37

def setup
  myLCD.clearscr "   --<Date/Time>--"
  myLCD.setxy 1,3, "looptime = "
  rtc.get clock, 1
  print_main
  @flag = 1
end