mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
add Muse support
This commit is contained in:
@@ -309,7 +309,7 @@ CONFIG_SPKFAULT_GPIO=-1
|
|||||||
#
|
#
|
||||||
# Battery measure
|
# Battery measure
|
||||||
#
|
#
|
||||||
CONFIG_BAT_CHANNEL=-1
|
CONFIG_BAT_CONFIG=""
|
||||||
# end of Battery measure
|
# end of Battery measure
|
||||||
|
|
||||||
CONFIG_DEFAULT_COMMAND_LINE="squeezelite -o I2S -b 500:2000 -d all=info -C 30 -W"
|
CONFIG_DEFAULT_COMMAND_LINE="squeezelite -o I2S -b 500:2000 -d all=info -C 30 -W"
|
||||||
|
|||||||
@@ -269,8 +269,7 @@ CONFIG_JACK_GPIO=34
|
|||||||
CONFIG_JACK_GPIO_LEVEL=0
|
CONFIG_JACK_GPIO_LEVEL=0
|
||||||
CONFIG_SPKFAULT_GPIO=2
|
CONFIG_SPKFAULT_GPIO=2
|
||||||
CONFIG_SPKFAULT_GPIO_LEVEL=0
|
CONFIG_SPKFAULT_GPIO_LEVEL=0
|
||||||
CONFIG_BAT_CHANNEL=7
|
CONFIG_BAT_CONFIG="channel=7,scale=20.24,atten=0"
|
||||||
CONFIG_BAT_SCALE="20.24"
|
|
||||||
CONFIG_DEFAULT_COMMAND_LINE="squeezelite -o I2S -b 500:2000 -d all=info -C 30 -W"
|
CONFIG_DEFAULT_COMMAND_LINE="squeezelite -o I2S -b 500:2000 -d all=info -C 30 -W"
|
||||||
# end of Squeezelite-ESP32
|
# end of Squeezelite-ESP32
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ extern "C" {
|
|||||||
if ((__p = strcasestr(S, P)) && (__p = strchr(__p, C))) V = atoi(__p+1); \
|
if ((__p = strcasestr(S, P)) && (__p = strchr(__p, C))) V = atoi(__p+1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define PARSE_PARAM_FLOAT(S,P,C,V) do { \
|
||||||
|
char *__p; \
|
||||||
|
if ((__p = strcasestr(S, P)) && (__p = strchr(__p, C))) V = atof(__p+1); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define PARSE_PARAM_STR(S,P,C,V,I) do { \
|
#define PARSE_PARAM_STR(S,P,C,V,I) do { \
|
||||||
char *__p; \
|
char *__p; \
|
||||||
if ((__p = strstr(S, P)) && (__p = strchr(__p, C))) { \
|
if ((__p = strstr(S, P)) && (__p = strchr(__p, C))) { \
|
||||||
|
|||||||
@@ -1109,7 +1109,6 @@ cJSON * get_gpio_list(bool refresh) {
|
|||||||
}
|
}
|
||||||
gpio_list= cJSON_CreateArray();
|
gpio_list= cJSON_CreateArray();
|
||||||
|
|
||||||
#ifndef CONFIG_BAT_LOCKED
|
|
||||||
char *bat_config = config_alloc_get_default(NVS_TYPE_STR, "bat_config", NULL, 0);
|
char *bat_config = config_alloc_get_default(NVS_TYPE_STR, "bat_config", NULL, 0);
|
||||||
if (bat_config) {
|
if (bat_config) {
|
||||||
int channel = -1;
|
int channel = -1;
|
||||||
@@ -1121,11 +1120,6 @@ cJSON * get_gpio_list(bool refresh) {
|
|||||||
}
|
}
|
||||||
free(bat_config);
|
free(bat_config);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if(adc1_pad_get_io_num(CONFIG_BAT_CHANNEL,&gpio_num )==ESP_OK){
|
|
||||||
cJSON_AddItemToArray(gpio_list,get_gpio_entry("bat","other",gpio_num,true));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
gpio_list=get_GPIO_nvs_list(gpio_list);
|
gpio_list=get_GPIO_nvs_list(gpio_list);
|
||||||
gpio_list=get_SPDIF_GPIO(gpio_list,is_spdif_config_locked());
|
gpio_list=get_SPDIF_GPIO(gpio_list,is_spdif_config_locked());
|
||||||
gpio_list=get_Rotary_GPIO(gpio_list);
|
gpio_list=get_Rotary_GPIO(gpio_list);
|
||||||
|
|||||||
@@ -36,9 +36,8 @@ static struct {
|
|||||||
int cells, attenuation;
|
int cells, attenuation;
|
||||||
TimerHandle_t timer;
|
TimerHandle_t timer;
|
||||||
} battery = {
|
} battery = {
|
||||||
.channel = CONFIG_BAT_CHANNEL,
|
.channel = -1,
|
||||||
.cells = 2,
|
.cells = 2,
|
||||||
.attenuation = ADC_ATTEN_DB_0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void (*battery_handler_svc)(float value);
|
void (*battery_handler_svc)(float value);
|
||||||
@@ -76,17 +75,18 @@ static void battery_callback(TimerHandle_t xTimer) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void battery_svc_init(void) {
|
void battery_svc_init(void) {
|
||||||
#ifdef CONFIG_BAT_SCALE
|
char *nvs_item = config_alloc_get_default(NVS_TYPE_STR, "bat_config", "", 0);
|
||||||
battery.scale = atof(CONFIG_BAT_SCALE);
|
|
||||||
|
#ifdef CONFIG_BAT_LOCKED
|
||||||
|
char *p = nvs_item;
|
||||||
|
asprintf(&nvs_item, CONFIG_BAT_CONFIG ",%s", p);
|
||||||
|
free(p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *nvs_item = config_alloc_get_default(NVS_TYPE_STR, "bat_config", "n", 0);
|
|
||||||
if (nvs_item) {
|
if (nvs_item) {
|
||||||
#ifndef CONFIG_BAT_LOCKED
|
|
||||||
PARSE_PARAM(nvs_item, "channel", '=', battery.channel);
|
PARSE_PARAM(nvs_item, "channel", '=', battery.channel);
|
||||||
PARSE_PARAM(nvs_item, "scale", '=', battery.scale);
|
PARSE_PARAM_FLOAT(nvs_item, "scale", '=', battery.scale);
|
||||||
PARSE_PARAM(nvs_item, "atten", '=', battery.attenuation);
|
PARSE_PARAM(nvs_item, "atten", '=', battery.attenuation);
|
||||||
#endif
|
|
||||||
PARSE_PARAM(nvs_item, "cells", '=', battery.cells);
|
PARSE_PARAM(nvs_item, "cells", '=', battery.cells);
|
||||||
free(nvs_item);
|
free(nvs_item);
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ void battery_svc_init(void) {
|
|||||||
battery.timer = xTimerCreate("battery", BATTERY_TIMER / portTICK_RATE_MS, pdTRUE, NULL, battery_callback);
|
battery.timer = xTimerCreate("battery", BATTERY_TIMER / portTICK_RATE_MS, pdTRUE, NULL, battery_callback);
|
||||||
xTimerStart(battery.timer, portMAX_DELAY);
|
xTimerStart(battery.timer, portMAX_DELAY);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Battery measure channel: %u, scale %f, cells %u, avg %.2fV", battery.channel, battery.scale, battery.cells, battery.avg);
|
ESP_LOGI(TAG, "Battery measure channel: %u, scale %f, atten %d, cells %u, avg %.2fV", battery.channel, battery.scale, battery.attenuation, battery.cells, battery.avg);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "No battery");
|
ESP_LOGI(TAG, "No battery");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
#include <driver/adc.h>
|
//#include <driver/adc.h>
|
||||||
#include "driver/rmt.h"
|
#include "driver/rmt.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
|
||||||
@@ -43,8 +43,6 @@ void ws2812_write_leds(struct led_state new_state);
|
|||||||
static const char TAG[] = "muse";
|
static const char TAG[] = "muse";
|
||||||
|
|
||||||
static void (*battery_handler_chain)(float value);
|
static void (*battery_handler_chain)(float value);
|
||||||
|
|
||||||
static void battery(void *data);
|
|
||||||
static void battery_svc(float value);
|
static void battery_svc(float value);
|
||||||
|
|
||||||
void target_init(void) {
|
void target_init(void) {
|
||||||
@@ -55,10 +53,12 @@ void target_init(void) {
|
|||||||
|
|
||||||
static void battery_svc(float value) {
|
static void battery_svc(float value) {
|
||||||
ESP_LOGI(TAG, "Called for battery service with %f", value);
|
ESP_LOGI(TAG, "Called for battery service with %f", value);
|
||||||
|
// put here your code for LED according to value
|
||||||
if (battery_handler_chain) battery_handler_chain(value);
|
if (battery_handler_chain) battery_handler_chain(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Battery monitoring
|
// Battery monitoring
|
||||||
|
/*
|
||||||
static void battery(void *data)
|
static void battery(void *data)
|
||||||
{
|
{
|
||||||
#define VGREEN 2300
|
#define VGREEN 2300
|
||||||
@@ -91,6 +91,7 @@ static void battery(void *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// This is the buffer which the hw peripheral will access while pulsing the output pin
|
// This is the buffer which the hw peripheral will access while pulsing the output pin
|
||||||
rmt_item32_t led_data_buffer[LED_BUFFER_ITEMS];
|
rmt_item32_t led_data_buffer[LED_BUFFER_ITEMS];
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ menu "Squeezelite-ESP32"
|
|||||||
config MUTE_GPIO_LEVEL
|
config MUTE_GPIO_LEVEL
|
||||||
int
|
int
|
||||||
default 0
|
default 0
|
||||||
|
config WELL_KNOWN
|
||||||
|
bool
|
||||||
|
default n
|
||||||
menu "Target"
|
menu "Target"
|
||||||
choice OUTPUT_TYPE
|
choice OUTPUT_TYPE
|
||||||
prompt "Main system"
|
prompt "Main system"
|
||||||
@@ -56,17 +59,20 @@ menu "Squeezelite-ESP32"
|
|||||||
select I2C_LOCKED
|
select I2C_LOCKED
|
||||||
select LED_LOCKED
|
select LED_LOCKED
|
||||||
select SPKFAULT_LOCKED
|
select SPKFAULT_LOCKED
|
||||||
config BASIC_I2C_BT
|
select WELL_KNOWN
|
||||||
bool "Generic I2S & Bluetooth"
|
|
||||||
config TWATCH2020
|
|
||||||
bool "T-WATCH2020 by LilyGo"
|
|
||||||
select I2C_LOCKED
|
|
||||||
config MUSE
|
config MUSE
|
||||||
bool "Muse"
|
bool "Muse"
|
||||||
select JACK_LOCKED
|
select JACK_LOCKED
|
||||||
select BAT_LOCKED
|
select BAT_LOCKED
|
||||||
select I2C_LOCKED
|
select I2C_LOCKED
|
||||||
select AMP_LOCKED
|
select AMP_LOCKED
|
||||||
|
select WELL_KNOWN
|
||||||
|
config BASIC_I2C_BT
|
||||||
|
bool "Generic I2S & Bluetooth"
|
||||||
|
config TWATCH2020
|
||||||
|
bool "T-WATCH2020 by LilyGo"
|
||||||
|
select I2C_LOCKED
|
||||||
|
select WELL_KNOWN
|
||||||
endchoice
|
endchoice
|
||||||
config RELEASE_API
|
config RELEASE_API
|
||||||
string "Software update URL"
|
string "Software update URL"
|
||||||
@@ -129,7 +135,10 @@ menu "Squeezelite-ESP32"
|
|||||||
string
|
string
|
||||||
default "[{\"gpio\":32, \"pull\":true, \"debounce\":10, \"normal\":{\"pressed\":\"ACTRLS_VOLDOWN\"}}, {\"gpio\":19, \"pull\":true, \"debounce\":40, \"normal\":{\"pressed\":\"ACTRLS_VOLUP\"}}, {\"gpio\":12, \"pull\":true, \"debounce\":40, \"longpress\":1000, \"normal\":{\"pressed\":\"ACTRLS_TOGGLE\"},\"longpress\":{\"pressed\":\"ACTRLS_POWER\"}}]" if MUSE
|
default "[{\"gpio\":32, \"pull\":true, \"debounce\":10, \"normal\":{\"pressed\":\"ACTRLS_VOLDOWN\"}}, {\"gpio\":19, \"pull\":true, \"debounce\":40, \"normal\":{\"pressed\":\"ACTRLS_VOLUP\"}}, {\"gpio\":12, \"pull\":true, \"debounce\":40, \"longpress\":1000, \"normal\":{\"pressed\":\"ACTRLS_TOGGLE\"},\"longpress\":{\"pressed\":\"ACTRLS_POWER\"}}]" if MUSE
|
||||||
default ""
|
default ""
|
||||||
default -1
|
config BAT_CONFIG
|
||||||
|
default "channel=7,scale=20.24,atten=0" if SQUEEZEAMP
|
||||||
|
default "channel=5,scale=1,atten=3,cells=1" if MUSE
|
||||||
|
default ""
|
||||||
config AMP_GPIO
|
config AMP_GPIO
|
||||||
int
|
int
|
||||||
default 21 if MUSE
|
default 21 if MUSE
|
||||||
@@ -371,7 +380,7 @@ menu "Squeezelite-ESP32"
|
|||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Audio JACK"
|
menu "Audio JACK"
|
||||||
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
|
visible if !WELL_KNOWN
|
||||||
config JACK_GPIO
|
config JACK_GPIO
|
||||||
int "Jack insertion GPIO"
|
int "Jack insertion GPIO"
|
||||||
help
|
help
|
||||||
@@ -383,7 +392,7 @@ menu "Squeezelite-ESP32"
|
|||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Amplifier"
|
menu "Amplifier"
|
||||||
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
|
visible if !WELL_KNOWN
|
||||||
config AMP_GPIO
|
config AMP_GPIO
|
||||||
int "Amplifier GPIO"
|
int "Amplifier GPIO"
|
||||||
help
|
help
|
||||||
@@ -395,7 +404,7 @@ menu "Squeezelite-ESP32"
|
|||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Speaker Fault"
|
menu "Speaker Fault"
|
||||||
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
|
visible if !WELL_KNOWN
|
||||||
config SPKFAULT_GPIO
|
config SPKFAULT_GPIO
|
||||||
int "Speaker fault GPIO"
|
int "Speaker fault GPIO"
|
||||||
help
|
help
|
||||||
@@ -405,20 +414,16 @@ menu "Squeezelite-ESP32"
|
|||||||
int "Level when fault (0/1)"
|
int "Level when fault (0/1)"
|
||||||
default 0
|
default 0
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Battery measure"
|
menu "Battery measure"
|
||||||
visible if !SQUEEZEAMP && !TWATCH2020
|
visible if !WELL_KNOWN
|
||||||
config BAT_CHANNEL
|
config BAT_CONFIG
|
||||||
int "Set channel (0..7)"
|
string "Battery acquisition configuration"
|
||||||
help
|
help
|
||||||
Read a value every 10s on ADC1 on set Channel
|
Sets parameters for battery voltage measure
|
||||||
config BAT_SCALE
|
channel=<0..7>,scale=<ratio_to_4096>,atten=<adc_atten>,cells=<1..3>
|
||||||
string "Set scaling factor"
|
|
||||||
depends on BAT_CHANNEL != -1
|
|
||||||
default "20.24" if SQUEEZEAMP
|
|
||||||
default ""
|
|
||||||
help
|
|
||||||
Set the scaling factor for this 12 bits ADC
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
config DEFAULT_COMMAND_LINE
|
config DEFAULT_COMMAND_LINE
|
||||||
string "Default command line to execute"
|
string "Default command line to execute"
|
||||||
default "squeezelite -o I2S -b 500:2000 -d all=info -C 30"
|
default "squeezelite -o I2S -b 500:2000 -d all=info -C 30"
|
||||||
|
|||||||
Reference in New Issue
Block a user