diff --git a/components/squeezelite/embedded.h b/components/squeezelite/embedded.h index ebf2429f..64ddf26f 100644 --- a/components/squeezelite/embedded.h +++ b/components/squeezelite/embedded.h @@ -8,11 +8,11 @@ - pthread_create_name - stack size - s16_t, s32_t, s64_t and u64_t - - EXT_BSS can overload (use #define) - exit - gettime_ms - BASE_CAP + - EXT_BSS recommended to add platform specific include(s) here */ diff --git a/components/squeezelite/output_i2s.c b/components/squeezelite/output_i2s.c index 9c22c96c..72d4689a 100644 --- a/components/squeezelite/output_i2s.c +++ b/components/squeezelite/output_i2s.c @@ -109,7 +109,8 @@ extern struct outputstate output; extern struct buffer *streambuf; extern struct buffer *outputbuf; extern u8_t *silencebuf; -extern bool jack_mutes_amp; + +bool jack_mutes_amp = false; static log_level loglevel; static bool running, isI2SStarted; @@ -120,6 +121,7 @@ static u8_t *obuf; static frames_t oframes; static bool spdif; static size_t dma_buf_frames; +static int jack_status = -1; // 0 = inserted DECLARE_ALL_MIN_MAX; @@ -154,7 +156,7 @@ static void spdif_convert(ISAMPLE_T *src, size_t frames, u32_t *dst, size_t *cou #define I2C_PORT 0 #define I2C_ADDR 0x4c -#define VOLUME_GPIO 33 +#define VOLUME_GPIO 14 #define JACK_GPIO 34 struct tas575x_cmd_s { @@ -438,10 +440,17 @@ static void *output_thread_i2s() { TIME_MEASUREMENT_START(timer_start); - LOCK; - if(jack_mutes_amp){ - // todo: implement some muting logic + // handle jack insertion as a polling function (to avoid to have to do de-bouncing) + if (gpio_get_level(JACK_GPIO) != jack_status) { + jack_status = gpio_get_level(JACK_GPIO); + if (jack_mutes_amp) { + //gpio_set_level(VOLUME_GPIO, jack_status); + LOG_INFO("Changing jack status %d", jack_status); + } } + + LOCK; + // manage led display if (state != output.state) { LOG_INFO("Output state is %d", output.state); @@ -464,7 +473,7 @@ static void *output_thread_i2s() { } else if (output.state == OUTPUT_STOPPED) { synced = false; } - + oframes = 0; output.updated = gettime_ms(); output.frames_played_dmp = output.frames_played; @@ -493,7 +502,7 @@ static void *output_thread_i2s() { } UNLOCK; - + // now send all the data TIME_MEASUREMENT_START(timer_start); diff --git a/components/squeezelite/squeezelite.h b/components/squeezelite/squeezelite.h index 8de70146..02d22158 100644 --- a/components/squeezelite/squeezelite.h +++ b/components/squeezelite/squeezelite.h @@ -442,6 +442,10 @@ void _wake_create(event_event*); #define wake_close(e) CloseHandle(e) #endif +#ifndef EXT_BSS +#define EXT_BSS +#endif + // printf/scanf formats for u64_t #if (LINUX && __WORDSIZE == 64) || (FREEBSD && __LP64__) #define FMT_u64 "%lu" diff --git a/main/esp_app_main.c b/main/esp_app_main.c index 5bd86c13..b565d93d 100644 --- a/main/esp_app_main.c +++ b/main/esp_app_main.c @@ -47,11 +47,12 @@ #include #include "config.h" +extern bool enable_bt_sink; +extern bool enable_airplay; +extern bool jack_mutes_amp; EventGroupHandle_t wifi_event_group; -bool enable_bt_sink=false; -bool enable_airplay=false; -bool jack_mutes_amp=false; + bool bypass_wifi_manager=false; const int CONNECTED_BIT = BIT0; #define JOIN_TIMEOUT_MS (10000)