123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
-
- #include <stdlib.h>
- #include <unistd.h>
- #include "esp_system.h"
- #include "esp_log.h"
- #include "buttons.h"
- #include "audio_controls.h"
- static const char * TAG = "audio_controls";
- typedef struct {
- void (*volume_up)(void);
- void (*volume_down)(void);
- void (*play_toggle)(void);
- void (*play)(void);
- void (*pause)(void);
- void (*stop)(void);
- } audio_control_t;
- static audio_control_t default_control, current_control;
- static void volume_down(button_event_e event, button_press_e press) {
- ESP_LOGI(TAG, "volume down %u", event);
-
- }
- static void volume_down_special(button_event_e event, button_press_e press) {
- if (press == BUTTON_LONG) ESP_LOGI(TAG, "volume down long %u", event);
- else ESP_LOGI(TAG, "volume down shifted %u", event);
-
- }
- static void volume_up(button_event_e event, button_press_e press) {
- ESP_LOGI(TAG, "volume up %u", event);
-
- }
- static void volume_up_long(button_event_e event, button_press_e press) {
- if (press == BUTTON_LONG) ESP_LOGI(TAG, "volume up long %u", event);
- else ESP_LOGI(TAG, "volume up shifted %u", event);
-
- }
- void audio_controls_init(void) {
-
- button_create(4, BUTTON_LOW, true, volume_up, NULL);
- button_create(5, BUTTON_LOW, true, volume_down, "long", volume_down_special, 3000, "shift", volume_down_special, 4, NULL);
- }
- void default_audio_control(audio_control_t *control) {
- default_control = current_control = *control;
- }
- void register_audio_control(audio_control_t *control) {
- current_control = *control;
- }
- void deregister_audio_control(void) {
- current_control = default_control;
- }
|