esp-adf icon indicating copy to clipboard operation
esp-adf copied to clipboard

Use custom keys (AUD-3857)

Open teddykishi opened this issue 2 years ago • 4 comments

Hi I'm using the ESP32-LyraT-Mini_V1.2

I soldered a wire to the GPIO4 in order to read analog data from a other board that has buttons separated by different resistors values. It is working with adc2_get_raw(ADC2_CHANNEL_0, ADC_WIDTH_BIT_12, &raw); But I'd like to use those keys with events like on the example of `get-started/play_mp3_control``

   ESP_LOGI(TAG, "[ 3 ] Create and start input key service");
    input_key_service_info_t input_key_info[] = INPUT_KEY_DEFAULT_INFO();
    input_key_service_cfg_t input_cfg = INPUT_KEY_SERVICE_DEFAULT_CONFIG();
    input_cfg.handle = set;
    periph_service_handle_t input_ser = input_key_service_create(&input_cfg);
    input_key_service_add_key(input_ser, input_key_info, INPUT_KEY_NUM);
    periph_service_set_callback(input_ser, input_key_service_cb, (void *)board_handle);

Is it possible ? Where can I find the documentation to achieve this ? Thanks

teddykishi avatar Jun 03 '22 16:06 teddykishi

Hi @teddykishi

Yes, GPIO4 is the optional pin of the four-wire sdcard, and GPIO39 is the input pin of the ADC button of the development board.

Please check here. https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/get-started-esp32-lyrat-mini.html

HengYongChao avatar Jun 08 '22 02:06 HengYongChao

Thank you for your response, but I would like to know how to add my sensor values from GPIO4 to static esp_err_t input_key_service_cb(periph_service_handle_t handle, periph_service_event_t *evt, void *ctx) Thank you verry much

teddykishi avatar Jun 09 '22 22:06 teddykishi

Hi @teddykishi

Please refer to check_board_buttons example.

HengYongChao avatar Jun 17 '22 08:06 HengYongChao

@teddykishi I think you can change the adc_btn_tag.adc_ch to ADC1_CHANNEL_4 after https://github.com/espressif/esp-adf/blob/b1d505b19afeb8ff89efb351c29b6b7a93e9a7a7/components/audio_board/lyrat_mini_v1_1/board.c#L114

jason-mao avatar Aug 08 '22 09:08 jason-mao

This topic has become inactive so I'm going to close the issue. Please reopen this if you have any questions or need any further assistance.

jason-mao avatar Sep 05 '23 08:09 jason-mao