class I2CDevice::AQM0802A

Public Class Methods

new(args={}) click to toggle source
Calls superclass method I2CDevice::HD44780::new
# File lib/templates/grove_pi/i2c/device/aqm0802.rb, line 7
def initialize(args={})
        args[:address] ||= 0x3e
        super
        @is = 0
end

Public Instance Methods

follower_control(fon, rab) click to toggle source
# File lib/templates/grove_pi/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) click to toggle source
is
Integer

Instruction set 1: extension, 0: normal

# File lib/templates/grove_pi/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_lcd() click to toggle source
# File lib/templates/grove_pi/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) click to toggle source

Must set is = 1 by function_set before call.

# File lib/templates/grove_pi/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) click to toggle source
# File lib/templates/grove_pi/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) click to toggle source
# File lib/templates/grove_pi/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