Skip to content

File syn_keypad.c

FileList > input > syn_keypad.c

Go to the source code of this file

Non-blocking Matrix Keypad Scanner (3x4, 4x4, etc.).

  • #include "syn_keypad.h"
  • #include "../util/syn_assert.h"
  • #include <string.h>

Public Functions

Type Name
bool syn_keypad_get_key (const SYN_Keypad * kp, char * out_key)
Get the currently pressed key character.
SYN_Status syn_keypad_init (SYN_Keypad * kp, const SYN_GPIO_Pin * rows, uint8_t num_rows, const SYN_GPIO_Pin * cols, uint8_t num_cols, const char * keymap)
Initialize a Matrix Keypad instance.
void syn_keypad_scan (SYN_Keypad * kp)
Perform a non-blocking matrix scan.
void syn_keypad_set_callback (SYN_Keypad * kp, SYN_KeypadCallback callback, void * user_ctx)
Set event callback for key press and release events.

Public Functions Documentation

function syn_keypad_get_key

Get the currently pressed key character.

bool syn_keypad_get_key (
    const SYN_Keypad * kp,
    char * out_key
) 

Parameters:

  • kp Keypad context.
  • out_key [out] Key character (if pressed).

Returns:

True if a key is currently held pressed.


function syn_keypad_init

Initialize a Matrix Keypad instance.

SYN_Status syn_keypad_init (
    SYN_Keypad * kp,
    const SYN_GPIO_Pin * rows,
    uint8_t num_rows,
    const SYN_GPIO_Pin * cols,
    uint8_t num_cols,
    const char * keymap
) 

Configures row pins as outputs and col pins as inputs with pull-down/up.

Parameters:

  • kp Keypad context.
  • rows Array of row GPIO pins.
  • num_rows Number of row pins (1-8).
  • cols Array of column GPIO pins.
  • num_cols Number of column pins (1-8).
  • keymap String keymap of length (num_rows * num_cols).

Returns:

SYN_OK on success.


function syn_keypad_scan

Perform a non-blocking matrix scan.

void syn_keypad_scan (
    SYN_Keypad * kp
) 

Parameters:

  • kp Keypad context.

function syn_keypad_set_callback

Set event callback for key press and release events.

void syn_keypad_set_callback (
    SYN_Keypad * kp,
    SYN_KeypadCallback callback,
    void * user_ctx
) 

Parameters:

  • kp Keypad context.
  • callback Event handler callback function.
  • user_ctx User context pointer.


The documentation for this class was generated from the following file src/syntropic/input/syn_keypad.c