ADC Button Peripheral

Read status of buttons connected to an ADC input using a resistor ladder. Configuration provides for more than a singe ADC input to read several sets of buttons. For an example hardware implementation please refer to schematic of ESP32-LyraTD-MSC V2.2 Upper Board (PDF).

Application Examples

Implementation of this API is demonstrated in the following example:

API Reference

Functions

esp_periph_handle_t periph_adc_button_init(periph_adc_button_cfg_t *btn_cfg)

Create the button peripheral handle for esp_peripherals.

Note
The handle created by this function is automatically destroyed when esp_periph_destroy is called.
Return
The esp peripheral handle.
Parameters
  • btn_cfg: The button configuration.

Structures

struct periph_adc_button_cfg_t

The configuration of ADC Button.

Public Members

adc_arr_t *arr

An array with configuration of buttons

int arr_size

The array size

Macros

ADC_DEFAULT_ARR()

ESP32 ADC1 channels and GPIO table ADC1_CHANNEL_0 - GPIO36 ADC1_CHANNEL_1 - GPIO37 ADC1_CHANNEL_2 - GPIO38 ADC1_CHANNEL_3 - GPIO39 ADC1_CHANNEL_4 - GPIO32 ADC1_CHANNEL_5 - GPIO33 ADC1_CHANNEL_6 - GPIO34 ADC1_CHANNEL_7 - GPIO35

Enumerations

enum periph_adc_button_event_id_t

Values:

PERIPH_ADC_BUTTON_IDLE = 0
PERIPH_ADC_BUTTON_PRESSED
PERIPH_ADC_BUTTON_RELEASE
PERIPH_ADC_BUTTON_LONG_PRESSED
PERIPH_ADC_BUTTON_LONG_RELEASE