mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
more muse (battery)
This commit is contained in:
@@ -22,8 +22,7 @@ CONFIG_JACK_GPIO=-1
|
|||||||
CONFIG_JACK_GPIO_LEVEL=0
|
CONFIG_JACK_GPIO_LEVEL=0
|
||||||
CONFIG_SPKFAULT_GPIO=-1
|
CONFIG_SPKFAULT_GPIO=-1
|
||||||
CONFIG_SPKFAULT_GPIO_LEVEL=0
|
CONFIG_SPKFAULT_GPIO_LEVEL=0
|
||||||
CONFIG_BAT_CHANNEL=-1
|
CONFIG_BAT_CONFIG=""
|
||||||
CONFIG_BAT_SCALE="0"
|
|
||||||
CONFIG_I2S_NUM=0
|
CONFIG_I2S_NUM=0
|
||||||
CONFIG_I2S_BCK_IO=-1
|
CONFIG_I2S_BCK_IO=-1
|
||||||
CONFIG_I2S_WS_IO=-1
|
CONFIG_I2S_WS_IO=-1
|
||||||
|
|||||||
@@ -26,8 +26,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_I2S_NUM=0
|
CONFIG_I2S_NUM=0
|
||||||
CONFIG_SPDIF_NUM=0
|
CONFIG_SPDIF_NUM=0
|
||||||
CONFIG_SPDIF_CONFIG="bck=33,ws=25,do=15"
|
CONFIG_SPDIF_CONFIG="bck=33,ws=25,do=15"
|
||||||
|
|||||||
@@ -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))) { \
|
||||||
|
|||||||
@@ -974,11 +974,10 @@ 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;
|
||||||
PARSE_PARAM(bat_config, "channem", '=', channel);
|
PARSE_PARAM(bat_config, "channel", '=', channel);
|
||||||
if(channel != -1){
|
if(channel != -1){
|
||||||
if(adc1_pad_get_io_num(channel,&gpio_num )==ESP_OK){
|
if(adc1_pad_get_io_num(channel,&gpio_num )==ESP_OK){
|
||||||
cJSON_AddItemToArray(gpio_list,get_gpio_entry("bat","other",gpio_num,false));
|
cJSON_AddItemToArray(gpio_list,get_gpio_entry("bat","other",gpio_num,false));
|
||||||
@@ -986,11 +985,7 @@ 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");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,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"
|
||||||
@@ -51,17 +54,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"
|
||||||
@@ -124,60 +130,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 ""
|
||||||
endmenu
|
config BAT_CONFIG
|
||||||
|
default "channel=7,scale=20.24,atten=0" if SQUEEZEAMP
|
||||||
menu "Ethernet Options"
|
default "channel=5,scale=1,atten=3,cells=1" if MUSE
|
||||||
visible if BASIC_I2C_BT && (ETH_USE_ESP32_EMAC || ETH_USE_SPI_ETHERNET)
|
default ""
|
||||||
choice
|
|
||||||
prompt "Ethernet Chipset"
|
|
||||||
default ETH_NODRIVER
|
|
||||||
config ETH_NODRIVER
|
|
||||||
bool "Defined in NVS"
|
|
||||||
config ETH_LAN8720
|
|
||||||
bool "Microchip LAN8720 (RMII)"
|
|
||||||
config ETH_DM9051
|
|
||||||
bool "Davicom 9051 (SPI)"
|
|
||||||
endchoice
|
|
||||||
config ETH_PHY_RST_IO
|
|
||||||
int "PHY Reset GPIO number" if !ETH_NODRIVER
|
|
||||||
default -1
|
|
||||||
help
|
|
||||||
Set the GPIO number used to reset PHY chip.
|
|
||||||
Set to -1 to disable PHY chip hardware reset.
|
|
||||||
config ETH_MDC_IO
|
|
||||||
int "SMI MDC GPIO number" if ETH_LAN8720
|
|
||||||
default -1
|
|
||||||
help
|
|
||||||
Set the GPIO number used by SMI MDC.
|
|
||||||
config ETH_MDIO_IO
|
|
||||||
int "SMI MDIO GPIO number" if ETH_LAN8720
|
|
||||||
default -1
|
|
||||||
help
|
|
||||||
Set the GPIO number used by SMI MDIO.
|
|
||||||
config ETH_SPI_HOST
|
|
||||||
int "SPI host number (-1,1 or 2)" if ETH_DM9051
|
|
||||||
default -1
|
|
||||||
help
|
|
||||||
Set to -1 to use system's SPI config (see Various I/O)
|
|
||||||
Set to 2 or 3 to use a dedicated bus
|
|
||||||
config ETH_SPI_INTR_IO
|
|
||||||
int "interrupt" if ETH_DM9051
|
|
||||||
default -1
|
|
||||||
config ETH_SPI_CS_IO
|
|
||||||
int "Chip Select" if ETH_DM9051
|
|
||||||
default -1
|
|
||||||
config ETH_SPI_CLK_IO
|
|
||||||
int "SPI clock" if ETH_SPI_HOST != -1 && ETH_DM9051
|
|
||||||
default -1
|
|
||||||
config ETH_SPI_MOSI_IO
|
|
||||||
int "Data Out" if ETH_SPI_HOST != -1 && ETH_DM9051
|
|
||||||
default -1
|
|
||||||
config ETH_SPI_MISO_IO
|
|
||||||
int "Data In" if ETH_SPI_HOST != -1 && ETH_DM9051
|
|
||||||
default -1
|
|
||||||
config ETH_SPI_SPEED
|
|
||||||
int "SPI speed (Hz)" if ETH_SPI_HOST != -1 && ETH_DM9051
|
|
||||||
default 20000000
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "Audio settings"
|
menu "Audio settings"
|
||||||
@@ -369,7 +325,7 @@ menu "Squeezelite-ESP32"
|
|||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
menu "LED configuration"
|
menu "LED configuration"
|
||||||
visible if !SQUEEZEAMP && !TWATCH2020 && !MUSE
|
visible if !WELL_KNOWN
|
||||||
config LED_GREEN_GPIO
|
config LED_GREEN_GPIO
|
||||||
int "Green led GPIO"
|
int "Green led GPIO"
|
||||||
default 12 if SQUEEZEAMP
|
default 12 if SQUEEZEAMP
|
||||||
@@ -396,7 +352,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"
|
||||||
default 34 if SQUEEZEAMP || MUSE
|
default 34 if SQUEEZEAMP || MUSE
|
||||||
@@ -410,7 +366,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"
|
||||||
default 21 if MUSE
|
default 21 if MUSE
|
||||||
@@ -424,7 +380,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"
|
||||||
default 2 if SQUEEZEAMP
|
default 2 if SQUEEZEAMP
|
||||||
@@ -438,20 +394,12 @@ menu "Squeezelite-ESP32"
|
|||||||
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 acquisitiong configuration"
|
||||||
default 7 if SQUEEZEAMP
|
|
||||||
default -1
|
|
||||||
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
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
Reference in New Issue
Block a user