Button Application Programming Interfaces (APIs)

Last modified by Microchip on 2026/03/19 13:43

MTOUCH_Button_Initialize

void  MTOUCH_Button_Initialize(enum mtouch_button_names button);

Description: Initializes the individual button state, baseline, state counter, baseline counter, and then calibrates it. 

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: None

MTOUCH_Button_InitializeAll

void MTOUCH_Button_InitializeAll(void)

Description: Initializes all the configured buttons. 

Parameters: None

Return: None

Button_Service

void Button_Service(enum mtouch_button_names name)

Description: Starts the button service by updating the button reading and deviation.

Parameter:

Type Description
enumEnumerator for the configured button names

Return: None

MTOUCH_Button_ServiceAll

void MTOUCH_Button_ServiceAll(void)

Description: Initializes service for all configured buttons.

Parameters: None

Return: None

MTOUCH_Button_Tick

void MTOUCH_Button_Tick(void)

Description: Updates the button state counter based on real time button press. 

Parameters: None

Return: None

MTOUCH_Button_Deviation_Get

mtouch_button_deviation_t MTOUCH_Button_Deviation_Get(enum mtouch_button_names name) 

Description: Returns the button deviation based on the baseline value change. 

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: 

Type Description
mtouch_button_deviation_tButton deviation value

MTOUCH_Button_Reading_Get

mtouch_button_reading_t MTOUCH_Button_Reading_Get(enum mtouch_button_names name) 

Description: Gets the current button reading. 

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: 

Type Description
mtouch_button_reading_tCurrent button reading value

MTOUCH_Button_Baseline_Get

mtouch_button_reading_t MTOUCH_Button_Baseline_Get(enum mtouch_button_names name)

Description: Gets the current button reading. 

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: 

Type Description
mtouch_button_reading_tCurrent button reading value

MTOUCH_Button_Scaling_Get

mtouch_button_scaling_t MTOUCH_Button_Scaling_Get(enum mtouch_button_names name)

Description: Gets the current button scaling value. 

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: 

Type Description
mtouch_button_scaling_tCurrent button scaling value

MTOUCH_Button_Scaling_Set

void MTOUCH_Button_Scaling_Set(enum mtouch_button_names name,mtouch_button_scaling_t scaling)

Description: Sets the button scaling with respect to current value.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names
mtouch_button_scaling_t scalingCurrent scaling value

Return: None

MTOUCH_Button_Threshold_Get

mtouch_button_threshold_t MTOUCH_Button_Threshold_Get(enum mtouch_button_names name)

Description: Obtains the current value of the button threshold.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: 

Type Description
mtouch_button_threshold_tConfigured button threshold value

MTOUCH_Button_Threshold_Set

void MTOUCH_Button_Threshold_Set(enum mtouch_button_names name,mtouch_button_threshold_t threshold)

Description: Sets the button threshold based on the range configured.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names
mtouch_button_threshold_t thresholdInitially configured threshold value

Return: None

MTOUCH_Button_Oversampling_Get

uint8_t MTOUCH_Button_Oversampling_Get(enum mtouch_button_names name)

Description: Gets the button oversampling value.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: uint8_t

MTOUCH_Button_Oversampling_Set

void MTOUCH_Button_Oversampling_Set(enum mtouch_button_names name,uint8_t oversampling) 

Description: Oversampling value for each button can be set manually with this API.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names
uint8_t oversamplingManually configured oversampling value

Return: None

MTOUCH_Button_isPressed

bool MTOUCH_Button_isPressed(enum mtouch_button_names name)

Description: Checks whether the button is pressed or not and returns 0 or 1.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: bool

MTOUCH_Button_isInitialized

bool MTOUCH_Button_isInitialized(enum mtouch_button_names name)

Description: Checks whether the particular button is initialized or not and returns 0 or 1.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: bool

MTOUCH_Button_Buttonmask_Get

mtouch_buttonmask_t MTOUCH_Button_Buttonmask_Get(void)

Description: Checks whether button is pressed or not and returns the button mask output.

Parameter: None

Return: 

Type Description
mtouch_buttonmask_tReturns the button mask value

MTOUCH_Button_State_Get

uint8_t MTOUCH_Button_State_Get(enum mtouch_button_names name)

Description: Gets the button state.

Parameter:

Type Description
enum mtouch_button_namesEnumerator for the configured button names

Return: uint8_t

Back to Top