First set of MUSE support

This commit is contained in:
Philippe G
2022-01-18 20:00:23 -08:00
parent 86953fff14
commit 94fe9b0acf
2 changed files with 53 additions and 18 deletions

View File

@@ -75,6 +75,10 @@ sure that using rate_delay would fix that
#define STATS_PERIOD_MS 5000
#define STAT_STACK_SIZE (3*1024)
#ifndef CONFIG_AMP_GPIO_LEVEL
#define CONFIG_AMP_GPIO_LEVEL 1
#endif
extern struct outputstate output;
extern struct buffer *streambuf;
extern struct buffer *outputbuf;
@@ -101,7 +105,7 @@ static TaskHandle_t stats_task, output_i2s_task;
static bool stats;
static struct {
int gpio, active;
} amp_control = { -1, 1 },
} amp_control = { CONFIG_AMP_GPIO, CONFIG_AMP_GPIO_LEVEL },
mute_control = { CONFIG_MUTE_GPIO, CONFIG_MUTE_GPIO_LEVEL };
DECLARE_ALL_MIN_MAX;
@@ -171,20 +175,16 @@ static void jack_handler(bool inserted) {
/****************************************************************************************
* amp GPIO
*/
#ifndef AMP_GPIO_LOCKED
static void set_amp_gpio(int gpio, char *value) {
char *p;
if (strcasestr(value, "amp")) {
amp_control.gpio = gpio;
if ((p = strchr(value, ':')) != NULL) amp_control.active = atoi(p + 1);
gpio_pad_select_gpio_x(amp_control.gpio);
gpio_set_direction_x(amp_control.gpio, GPIO_MODE_OUTPUT);
gpio_set_level_x(amp_control.gpio, !amp_control.active);
LOG_INFO("setting amplifier GPIO %d (active:%d)", amp_control.gpio, amp_control.active);
}
}
#endif
/****************************************************************************************
* Set pin from config string
@@ -347,14 +347,22 @@ void output_init_i2s(log_level level, char *device, unsigned output_buf_size, ch
jack_handler_chain = jack_handler_svc;
jack_handler_svc = jack_handler;
#ifndef AMP_GPIO_LOCKED
parse_set_GPIO(set_amp_gpio);
#endif
if (amp_control.gpio != -1) {
gpio_pad_select_gpio_x(amp_control.gpio);
gpio_set_direction_x(amp_control.gpio, GPIO_MODE_OUTPUT);
gpio_set_level_x(amp_control.gpio, !amp_control.active);
LOG_INFO("setting amplifier GPIO %d (active:%d)", amp_control.gpio, amp_control.active);
}
if (jack_mutes_amp && jack_inserted_svc()) adac->speaker(false);
else adac->speaker(true);
adac->headset(jack_inserted_svc());
// create task as a FreeRTOS task but uses stack in internal RAM
{
static DRAM_ATTR StaticTask_t xTaskBuffer __attribute__ ((aligned (4)));

View File

@@ -21,6 +21,8 @@ menu "Squeezelite-ESP32"
help
Set logging level info|debug|sdebug
endmenu
config AMP_LOCKED
bool
config JACK_LOCKED
bool
config BAT_LOCKED
@@ -54,6 +56,12 @@ menu "Squeezelite-ESP32"
config TWATCH2020
bool "T-WATCH2020 by LilyGo"
select I2C_LOCKED
config MUSE
bool "Muse"
select JACK_LOCKED
select BAT_LOCKED
select I2C_LOCKED
select AMP_LOCKED
endchoice
config RELEASE_API
string "Software update URL"
@@ -71,11 +79,13 @@ menu "Squeezelite-ESP32"
string
default "SqueezeAMP" if SQUEEZEAMP
default "Squeezelite-TWATCH" if TWATCH2020
default "Muse" if MUSE
default "Squeezelite-ESP32"
config FW_PLATFORM_NAME
string
default "SqueezeAmp" if SQUEEZEAMP
default "TWATCH" if TWATCH2020
default "Muse" if MUSE
default "ESP32"
# AGGREGATES - begin
# these parameters are "aggregates" that take precedence. They must have a default value
@@ -83,6 +93,7 @@ menu "Squeezelite-ESP32"
string
default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP
default "model=I2S,bck=26,ws=25,do=33,i2c=53,sda=21,scl=22" if TWATCH2020
default "model=I2S,bck=5,ws=25,do=26,di=35,i2c=16,sda=18,scl=23,mck" if MUSE
default ""
config SPDIF_CONFIG
string
@@ -94,6 +105,7 @@ menu "Squeezelite-ESP32"
config SPI_CONFIG
string
default "dc=27,data=19,clk=18" if TWATCH2020
default "mosi=15,miso=2,clk=14" if MUSE
default ""
config DISPLAY_CONFIG
string
@@ -105,6 +117,7 @@ menu "Squeezelite-ESP32"
config DAC_CONTROLSET
string
default "{ \"init\": [ {\"reg\":41, \"val\":128}, {\"reg\":18, \"val\":255} ], \"poweron\": [ {\"reg\":18, \"val\":64, \"mode\":\"or\"} ], \"poweroff\": [ {\"reg\":18, \"val\":191, \"mode\":\"and\"} ] }" if TWATCH2020
default "{\"init\":[ {\"reg\":0,\"val\":128}, {\"reg\":0,\"val\":0}, {\"reg\":25,\"val\":4}, {\"reg\":1,\"val\":80}, {\"reg\":2,\"val\":0}, {\"reg\":8,\"val\":0}, {\"reg\":4,\"val\":192}, {\"reg\":0,\"val\":18}, {\"reg\":1,\"val\":0}, {\"reg\":23,\"val\":24}, {\"reg\":24,\"val\":2}, {\"reg\":38,\"val\":9}, {\"reg\":39,\"val\":144}, {\"reg\":42,\"val\":144}, {\"reg\":43,\"val\":128}, {\"reg\":45,\"val\":128}, {\"reg\":27,\"val\":0}, {\"reg\":26,\"val\":0}, {\"reg\":2,\"val\":240}, {\"reg\":2,\"val\":0}, {\"reg\":29,\"val\":28}, {\"reg\":4,\"val\":48}, {\"reg\":25,\"val\":0} ]}" if MUSE
default ""
# AGGREGATES - end
endmenu
@@ -308,7 +321,7 @@ menu "Squeezelite-ESP32"
endmenu
menu "Various I/O"
visible if !TWATCH2020
visible if !TWATCH2020 && !MUSE
config I2C_CONFIG
string "I2C system configuration"
default ""
@@ -343,17 +356,18 @@ menu "Squeezelite-ESP32"
model=<model>[,addr=<addr>][,base=<100..N>][,count=<0..32>][,intr=<gpio>][,port=dac|system]
endmenu
menu "LED configuration"
visible if !SQUEEZEAMP && !TWATCH2020
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
config LED_GREEN_GPIO
int "Green led GPIO"
default 12 if SQUEEZEAMP
default 22 if MUSE
default -1
help
Set to -1 for no LED
config LED_GREEN_GPIO_LEVEL
int "Green led ON level"
depends on LED_GREEN_GPIO != -1
default 0 if SQUEEZEAMP
default 0 if SQUEEZEAMP || MUSE
default 1
config LED_RED_GPIO
int "Red led GPIO"
@@ -368,10 +382,10 @@ menu "Squeezelite-ESP32"
default 1
endmenu
menu "Audio JACK"
visible if !SQUEEZEAMP && !TWATCH2020
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
config JACK_GPIO
int "Jack insertion GPIO"
default 34 if SQUEEZEAMP
default 34 if SQUEEZEAMP || MUSE
default -1
help
GPIO to detect speaker jack insertion. Set to -1 for no detection.
@@ -380,8 +394,21 @@ menu "Squeezelite-ESP32"
int "Level when inserted (0/1)"
default 0
endmenu
menu "Amplifier"
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
config AMP_GPIO
int "Amplifier GPIO"
default 21 if MUSE
default -1
help
GPIO to switch on/off amplifier. Set to -1 for no amplifier.
config AMP_GPIO_LEVEL
depends on AMP_GPIO != -1
int "Active level(0/1)"
default 1
endmenu
menu "Speaker Fault"
visible if !SQUEEZEAMP && !TWATCH2020
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
config SPKFAULT_GPIO
int "Speaker fault GPIO"
default 2 if SQUEEZEAMP