Class: I2cWithClockChip
Instance Attribute Summary
#pins
Instance Method Summary
collapse
#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
#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
#clear_bottom_line ⇒ Object
119
120
121
122
|
# File 'lib/examples/i2c_with_clock_chip.rb', line 119
def clear_bottom_line
myLCD.setxy 0,3
myLCD.print "?l"
end
|
#loop ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/examples/i2c_with_clock_chip.rb', line 39
def loop
until myTemp.reset do clear_bottom_line
myLCD.print " <1Wire Buss Error>"
delay 2000
end
myTemp.skip myTemp.write 0x44, 1
myLCD.setxy 6,0 myLCD.print rtc.get(5, 1)
myLCD.print "/"
myLCD.print rtc.get(4, 0)
myLCD.print "/"
myLCD.print rtc.get(6, 0)
myLCD.setxy 6,1
printlz rtc.get(2, 0)
myLCD.print ":"
printlz rtc.get(1, 0)
myLCD.print ":"
printlz rtc.get(0, 0)
delay 800
until myTemp.reset do clear_bottom_line
myLCD.print " <1Wire Buss Error>"
delay 2000
end
myTemp.skip myTemp.write 0xBE, 1
@lo_byte = myTemp.read @hi_byte = myTemp.read
clear_bottom_line myLCD.setxy 4,3 myLCD.print "raw = 0x"
print_hexbyte @hi_byte print_hexbyte @lo_byte
7.times { @device_crc = myTemp.read }
@t_reading = build_int @hi_byte, @lo_byte
@sign_bit = bit_and @t_reading, 0x8000
@t_reading = twos_comp @t_reading if @sign_bit
@tc_100 = (6 * @t_reading) + (@t_reading / 4)
myLCD.setxy 2,2
if @sign_bit
myLCD.print "-"
else
myLCD.print " "
end
myLCD.print(@tc_100 / 100) myLCD.print "."
printlz(@tc_100 % 100) myLCD.print " degrees C"
end
|
#print_hexbyte(w) ⇒ Object
114
115
116
117
|
# File 'lib/examples/i2c_with_clock_chip.rb', line 114
def print_hexbyte(w)
myLCD.print "0" if w < 0x10
myLCD.print w, 0x10
end
|
#printlz(w) ⇒ Object
109
110
111
112
|
# File 'lib/examples/i2c_with_clock_chip.rb', line 109
def printlz(w)
myLCD.print "0" if w < 10
myLCD.print w
end
|