keyboard - Keyboard Matrix#

Adapted Air105

Note

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

Tip

This library has its own demo,click this link to view keyboard demo examples

keyboard.init(port, conf, map, debounce)#

Initialize keyboard matrix

Parameters

Incoming Value Type

Explanation

int

Reserved, currently filled 0

int

The keyboard pin mask that is enabled. For example, if keyboard0 ~ 9 is used, the mask is 0x1FF. If 0~3 is used, the mask is 0x1FF. 0xF

int

keyboard Pin direction mapping, where the input is 0 and the output is 1, set by bit. For example, keyboard0 ~ 3 as input and keyboard4 ~ 7 as input, then 0xF0

int

Shake elimination configuration, reserved, can not fill in

Return Value

None

Examples

-- Make a 4*4 keyboard matrix and use keyboard0 ~ 7, where 0~3 is input and 4~7 is output.
-- Using keyboard0 ~ 7, the corresponding conf is 0xFF
-- Where 0~3 is input and 4~7 is output, corresponding to map 0xF0
keyboard.init(0, 0xFF, 0xF0)

-- Make a 2*3 keyboard matrix and use keyboard0 ~ 4, where 0~1 is input and 2~4 is output.
-- Using keyboard0 ~ 4, the binary is 11111, and the hexadecimal expression of the corresponding conf is 0x1F
-- Where 0~1 is input, 2~4 is output, and binary is 11100 corresponding to map 0x14
-- keyboard.init(0, 0xFF, 0x14)

sys.subscribe("KB_INC", function(port, data, state)
    -- port Currently fixed to 0, can be ignored
    -- data, Need to cooperate with init map for parsing
    -- state, 1 is pressed, 0 is released
    -- TODO Detailed introduction
end)