tm1640 - tm1640 Digital tube and LED driver 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、tm1640 The driver's digital tube should choose a common negative digital tube
--2、tm1640 Can also drive LED, if it is LED, you should connect the LED into a common negative digital tube inside the same circuit
--3、AIR101 The official core board, the bottom layer is LuatOS-SoC_V0017_AIR101.soc, and the serial clock frequency of this script library is tested.20KHz
-- Usage Examples:
local tm1640 = require("tm1640")

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
    };   

    tm1640.init(pin.PB06,pin.PB07)  --clk,dat
    
    while 1 do
        for i = 0, 9, 1 do
            tm1640.setBright(tm1640.BRIGHT1)
            for grid = tm1640.GRID1, tm1640.GRID16, 1 do
                tm1640.sendDisplayData(grid,NUM_TABLE_AX[i])
            end
            sys.wait(200)
            tm1640.setBright(tm1640.BRIGHT3)
            sys.wait(200)
            tm1640.setBright(tm1640.BRIGHT5)
            sys.wait(200)
            tm1640.setBright(tm1640.BRIGHT8)
            sys.wait(200)
        end

        sys.wait(1000)

        tm1640.setBright(tm1640.BRIGHT5)
        for i = 0, 9, 1 do
            tm1640.clear()
            for grid = tm1640.GRID1, tm1640.GRID16, 1 do
                tm1640.sendDisplayData(grid,NUM_TABLE_AX[i])
                sys.wait(100)
            end
        end
    end
end)

tm1640.sendDisplayData(grid,seg_data)#

Send the specified segment data to the video memory corresponding to a specified bit (grid) of TM1640 for display

Parameters

Incoming Value Type

Explanation

number

grid,Define the bit selection parameter, with a value tm1640.GRID1~tm1640.GRID16

number

seg_data,Define segment data parameters

Return Value

None

Examples

tm1640.sendDisplayData(tm1640.GRID1,0xff)

tm1640.clear()#

Clear all bits of TM1640 (grid) corresponding to the video memory data, that is, all brush write 0

Parameters

None

Return Value

None

Examples

tm1640.clear()

tm1640.open()#

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

Parameters

None

Return Value

None

Examples

tm1640.open()

tm1640.close()#

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

Parameters

None

Return Value

None

Examples

tm1640.close()

tm1640.setBright(bri)#

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

Parameters

Incoming Value Type

Explanation

number

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

Return Value

None

Examples

tm1640.setBright(tm1640.BRIGHT8)

tm1640.init(clk,dat,bri)#

TM1640 Initialization

Parameters

Incoming Value Type

Explanation

number

clk,Defines the clock line driver pin

number

dat,Data line driver pin defined

number

bri,The initial brightness parameter, the preferable value is tm1640.BRIGHT1 ~ tm1640.BRIGHT8. Optional, the default value is tm1640.BRIGHT5。

Return Value

None

Examples

tm1640.init(pin.PB06,pin.PB07)
tm1640.init(pin.PB06,pin.PB07,tm1640.BRIGHT8)