Class: I2CDevice::AQM0802A

Inherits:
HD44780 show all
Defined in:
lib/i2c/device/aqm0802.rb

Constant Summary

Constants inherited from HD44780

HD44780::MAP

Constants inherited from I2CDevice

VERSION

Instance Attribute Summary

Attributes inherited from I2CDevice

#address

Instance Method Summary collapse

Methods inherited from HD44780

#clear_display, #cursor_or_display_shift, #define_character, #display_on_off_control, #entry_mode_set, #read_busy_flag_and_address, #return_home, #set_cgram_address, #set_ddram_address

Methods inherited from I2CDevice

#i2cget, #i2cset

Constructor Details

#initialize(args = {}) ⇒ AQM0802A

Returns a new instance of AQM0802A.



7
8
9
10
11
# File 'lib/i2c/device/aqm0802.rb', line 7

def initialize(args={})
	args[:address] ||= 0x3e
	super
	@is = 0
end

Instance Method Details

#follower_control(fon, rab) ⇒ Object



45
46
47
48
# File 'lib/i2c/device/aqm0802.rb', line 45

def follower_control(fon, rab)
	i2cset(0, 0b01100000 | (fon<<3) | rab)
	sleep 300e-3
end

#function_set(dl, n, f, is) ⇒ Object

is
Integer

Instruction set 1: extension, 0: normal



51
52
53
54
55
# File 'lib/i2c/device/aqm0802.rb', line 51

def function_set(dl, n, f, is)
	@is = is
	i2cset(0, 0b00100000 | (dl<<4) | (n<<3) | (f<<2) | (is))
	sleep 37e-6
end

#initialize_lcdObject



16
17
18
19
20
21
22
23
24
# File 'lib/i2c/device/aqm0802.rb', line 16

def initialize_lcd
	function_set(1, 1, 0, 1)
	internal_osc_frequency(0, 0b100)
	power_icon_control_contrast_set(0, 1, 0b10000)
	follower_control(1, 0b100)
	function_set(1, 1, 0, 0)
	display_on_off_control(1, 0, 0)
	clear
end

#internal_osc_frequency(bs, f) ⇒ Object

Must set is = 1 by function_set before call.



28
29
30
31
32
33
# File 'lib/i2c/device/aqm0802.rb', line 28

def internal_osc_frequency(bs, f)
	raise "is must be 1" unless @is == 1
	f &= 0b111
	i2cset(0, 0b00010000 | (bs << 3) | (f))
	sleep 26.3e-6
end

#power_icon_control_contrast_set(ion, bon, c) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/i2c/device/aqm0802.rb', line 35

def power_icon_control_contrast_set(ion, bon, c)
	c &= 0b111111
	# contrast_set
	i2cset(0, 0b01110000 | (c&0b111))
	sleep 26.3e-6
	# power_icon_control_contrast_set
	i2cset(0, 0b01010000 | (ion<<3) | (bon<<2) | (c>>3))
	sleep 26.3e-6
end

#put_line(line, str, force = false) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/i2c/device/aqm0802.rb', line 57

def put_line(line, str, force=false)
	str.force_encoding(Encoding::BINARY)
	str.gsub!(/#{MAP.keys.join('|')}/, MAP)
	str = "%- 8s" % str
	if force || str != @lines[line]
		# set ddram address
		set_ddram_address(line<<6) # line is 0 or 1
		sleep 60e-6
		i2cset(0b01000000, *str.unpack("C*"))
		sleep 60e-6
	end
	@lines[line] = str
end