lib/tamashii/agent/device/lcd/lcm1602_i2c.rb in tamashii-agent-0.3.1 vs lib/tamashii/agent/device/lcd/lcm1602_i2c.rb in tamashii-agent-0.3.3
- old
+ new
@@ -56,32 +56,12 @@
print_message("")
end
private
- def fetch_address
- if @options.has_key?(:address)
- address = @options[:address]
- else
- address = default_address
- logger.warn "No address specified. Use default address: #{address.to_s(16)}"
- end
- address
- end
-
- def fetch_path
- if @options.has_key?(:path)
- path = @options[:path]
- else
- path = default_path
- logger.warn "No path specified. Use default path: #{path}"
- end
- path
- end
-
def initialize_lcd
- @lcd = I2C.create(fetch_path)
- @address = fetch_address
+ @lcd = I2C.create(fetch_option(:path, default_path))
+ @address = fetch_option(:address, default_address)
@backlight = @options.fetch(:backlight, true)
byte(0x33, OP_CMD)
byte(0x32, OP_CMD)
byte(0x06, OP_CMD)