tm1650 - tm1650 Digital tube and key scanning chip#

Adaptation status unknown

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Example

--Attention:
--1、tm1650 The driver's digital tube should choose a common negative digital tube
--2、tm1650 Can also drive LED, if it is LED, you should connect the LED into a common negative digital tube inside the same circuit
--3、Support key scan, in this mode, the DP/KP pin of tm1650 is the interrupt output pin
--=========Key scan example==========
local function tm1650_kcb(key_code)
    log.info('tm1650 user cb,key code=',string.format("%02X",key_code))
end
sys.taskInit(function()
    tm1650.init(pin.PB06,pin.PB07,tm1650.MODE_KEY_INPUT,pin.PB08,tm1650_kcb)
    while 1 do
        sys.wait(2000)
    end
end)
--==========Digital tube display example===========
sys.taskInit(function()
    --Common Yin segment code table, 0~9 numbers
    local NUM_TABLE_AX = {
        [0]=0x3f,[1]=0x06,[2]=0x5b,[3]=0x4f,[4]=0x66,
        [5]=0x6d,[6]=0x7d,[7]=0x07,[8]=0x7f,[9]=0x6f
    };   
    tm1650.init(pin.PB06,pin.PB07,tm1650.MODE_LED_OUTPUT)
    while 1 do
        for i = tm1650.DIG1, tm1650.DIG4, 1 do
            tm1650.print(i,NUM_TABLE_AX[6])
            sys.wait(500)
        end
        sys.wait(1000)
        for i = tm1650.BRIGHT1, tm1650.BRIGHT8, 1 do
            tm1650.setBright(i)
            sys.wait(500)
        end
        for i = 1, 8, 1 do
            sys.wait(500)
            tm1650.close()    
            sys.wait(500)
            tm1650.open()
        end
        sys.wait(2000)
        tm1650.clear()
    end
end)

tm1650.init(scl_pin,sda_pin,mode,irq_pin,key_cb)#

TM1650 Initialization, according to the mode parameters can be set to digital tube display or key scanning mode

Parameters

Incoming Value Type

Explanation

number

scl_pin,Defines the clock line driver pin

number

sda_pin,Data line driver pin defined

number

mode,Defines the working mode, tm1650.MODE_LED_OUTPUT, digital tube LED drive mode; Tm1650.MODE_KEY_INPUT, key detection mode

number

irq_pin,Define Key Interrupt Pin

function

key_cb,Key user callback function, this function has a number type parameter, which is the key code of the pressed key

Return Value

None

Examples

tm1650.init(pin.PB06,pin.PB07,tm1650.MODE_LED_OUTPUT) --Digital tube display mode
tm1650.init(pin.PB06,pin.PB07,tm1650.MODE_KEY_INPUT,pin.PB08,tm1650_kcb)  --Key Scan Mode

tm1650.setBright(bri)#

Set the display brightness of TM1650, this operation does not affect the data in the video memory

Parameters

Incoming Value Type

Explanation

number

The brightness parameter, with a value tm1650.BRIGHT1~tm1650.BRIGHT8

Return Value

None

Examples

tm1650.setBright(tm1650.BRIGHT8)

tm1650.open()#

Open the display of TM1650, this operation does not affect the data in the video memory

Parameters

None

Return Value

None

Examples

tm1650.open()

tm1650.close()#

Turn off the display of TM1650, this operation does not affect the data in the video memory

Parameters

None

Return Value

None

Examples

tm1650.close()

tm1650.print(dig,seg_data)#

Send the specified segment data to the video memory corresponding to a specified bit of TM1650 for display

Parameters

Incoming Value Type

Explanation

number

dig,Define the bit selection parameter, with a value tm1650.DIG1~tm1650.DIG4

number

seg_data,Define segment data parameters

Return Value

None

Examples

tm1650.print(tm1650.DIG1,0x3f)

tm1650.clear()#

Clear all bits of TM1650 corresponding to the video memory data, that is, all brush write 0

Parameters

None

Return Value

None

Examples

tm1650.clear()