Class: HelloEeprom
- Inherits:
-
ArduinoSketch
- Object
- ArduinoSketch
- HelloEeprom
- Defined in:
- lib/examples/hello_eeprom.rb
Instance Attribute Summary
Attributes inherited from ArduinoSketch
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
#loop ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/examples/hello_eeprom.rb', line 8 def loop myLCD.setxy 0,0 # set to 0,0 myLCD.print rtc.get(5, 1) # refresh registers (=1) get month myLCD.print "/" myLCD.print rtc.get(4, 0) # no need to refresh (=0) get day myLCD.print "/" myLCD.print rtc.get(6, 0) # get year myLCD.setxy(0,1) # set in 1 byte line 1 (second line) printlz 2 # print hours with lead zero myLCD.print ":" printlz 1 # print minutes with lead zero myLCD.print ":" printlz 0 # print seconds with lead zero myLCD.setxy 10,0 myLCD.print "write test" myLCD.setxy 0,2 32.upto(109) do # write address of byte to that b yte |x| mem0.write_byte x, x myLCD.print(".") if x%2 delay 10 end delay 2000 myLCD.clearline 2 # clears bottom two lines myLCD.clearline 3 myLCD.setxy 10,0, "read test " myLCD.setxy 0,2 # read and print 39 addresses with printable numbers 75.upto(113) { |x| myLCD.print(mem0.read_byte(x)) } delay 10000 myLCD.clearscr end |
#printlz(w) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/examples/hello_eeprom.rb', line 45 def printlz(w) f = 1 + w # hack to coerce w to int i = rtc.get(w,0) myLCD.print "0" if i < 10 myLCD.print i end |