mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 21:17:18 +03:00
Merge remote-tracking branch 'origin/master-v4.3' into master-v4.3
This commit is contained in:
@@ -198,13 +198,13 @@ CONFIG_SPI_CONFIG=""
|
|||||||
CONFIG_DISPLAY_CONFIG=""
|
CONFIG_DISPLAY_CONFIG=""
|
||||||
CONFIG_ETH_CONFIG=""
|
CONFIG_ETH_CONFIG=""
|
||||||
CONFIG_DAC_CONTROLSET="{\"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} ]}"
|
CONFIG_DAC_CONTROLSET="{\"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} ]}"
|
||||||
CONFIG_AUDIO_CONTROLS="[{\"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\"}}]"
|
CONFIG_AUDIO_CONTROLS="[{\"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, \"long_press\":1000, \"normal\":{\"pressed\":\"ACTRLS_TOGGLE\"},\"longpress\":{\"pressed\":\"ACTRLS_POWER\"}}]"
|
||||||
CONFIG_BAT_CONFIG="channel=5,scale=1,atten=3,cells=1"
|
CONFIG_BAT_CONFIG="channel=5,scale=1,atten=3,cells=1"
|
||||||
CONFIG_AMP_GPIO=21
|
CONFIG_AMP_GPIO=21
|
||||||
CONFIG_JACK_GPIO=34
|
CONFIG_JACK_GPIO=34
|
||||||
CONFIG_SPKFAULT_GPIO=-1
|
CONFIG_SPKFAULT_GPIO=-1
|
||||||
CONFIG_BAT_CHANNEL=-1
|
CONFIG_BAT_CHANNEL=-1
|
||||||
CONFIG_LED_GREEN_GPIO=22
|
CONFIG_LED_GREEN_GPIO=-1
|
||||||
CONFIG_LED_RED_GPIO=-1
|
CONFIG_LED_RED_GPIO=-1
|
||||||
CONFIG_TARGET="muse"
|
CONFIG_TARGET="muse"
|
||||||
# end of Target
|
# end of Target
|
||||||
|
|||||||
@@ -508,10 +508,9 @@ static esp_err_t actrls_init_json(const char *profile_name, bool create) {
|
|||||||
char *config;
|
char *config;
|
||||||
const cJSON *button;
|
const cJSON *button;
|
||||||
|
|
||||||
if (!profile_name || !*profile_name) return ESP_OK;
|
if (!profile_name) return ESP_OK;
|
||||||
|
if ((config = config_alloc_get_str(profile_name, NULL, CONFIG_AUDIO_CONTROLS)) == NULL) return ESP_FAIL;
|
||||||
config = config_alloc_get_default(NVS_TYPE_STR, profile_name, NULL, 0);
|
if (!*config) goto exit;
|
||||||
if(!config) return ESP_FAIL;
|
|
||||||
|
|
||||||
ESP_LOGD(TAG,"Parsing JSON structure %s", config);
|
ESP_LOGD(TAG,"Parsing JSON structure %s", config);
|
||||||
cJSON *buttons = cJSON_Parse(config);
|
cJSON *buttons = cJSON_Parse(config);
|
||||||
@@ -526,7 +525,8 @@ static esp_err_t actrls_init_json(const char *profile_name, bool create) {
|
|||||||
if(!cur_config) {
|
if(!cur_config) {
|
||||||
ESP_LOGE(TAG,"Config buffer was empty. ");
|
ESP_LOGE(TAG,"Config buffer was empty. ");
|
||||||
cJSON_Delete(buttons);
|
cJSON_Delete(buttons);
|
||||||
return ESP_FAIL;
|
err = ESP_FAIL;
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG,"Processing button definitions. ");
|
ESP_LOGD(TAG,"Processing button definitions. ");
|
||||||
cJSON_ArrayForEach(button, buttons){
|
cJSON_ArrayForEach(button, buttons){
|
||||||
@@ -557,6 +557,8 @@ static esp_err_t actrls_init_json(const char *profile_name, bool create) {
|
|||||||
// the last init that completes will assigh the first json config object found, which will match
|
// the last init that completes will assigh the first json config object found, which will match
|
||||||
// the default config from nvs.
|
// the default config from nvs.
|
||||||
json_config = config_root;
|
json_config = config_root;
|
||||||
|
exit:
|
||||||
|
free(config);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ static __inline Word64 xSAR64(Word64 x, int n)
|
|||||||
}
|
}
|
||||||
//mw
|
//mw
|
||||||
|
|
||||||
#elif defined(__APPLE__) || defined(ESP_PLATFORM) || defined(__x86_64__)
|
#elif defined(__APPLE__) || defined(ESP_PLATFORM) || defined(__amd64__)
|
||||||
|
|
||||||
static __inline int FASTABS(int x)
|
static __inline int FASTABS(int x)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,7 +67,9 @@
|
|||||||
#
|
#
|
||||||
#elif defined(__GNUC__) && defined(__thumb__)
|
#elif defined(__GNUC__) && defined(__thumb__)
|
||||||
#
|
#
|
||||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
#elif defined(__GNUC__) && defined(__i386__)
|
||||||
|
#
|
||||||
|
#elif defined(__amd64__)
|
||||||
#
|
#
|
||||||
#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
|
#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -46,58 +46,43 @@ static const char TAG[] = "muse";
|
|||||||
static void (*battery_handler_chain)(float value);
|
static void (*battery_handler_chain)(float value);
|
||||||
static void battery_svc(float value);
|
static void battery_svc(float value);
|
||||||
static bool init(void);
|
static bool init(void);
|
||||||
|
static void set_battery_led(float value);
|
||||||
|
|
||||||
const struct target_s target_muse = { "muse", init };
|
const struct target_s target_muse = { .model = "muse", .init = init };
|
||||||
|
|
||||||
static bool init(void) {
|
static bool init(void) {
|
||||||
battery_handler_chain = battery_handler_svc;
|
battery_handler_chain = battery_handler_svc;
|
||||||
battery_handler_svc = battery_svc;
|
battery_handler_svc = battery_svc;
|
||||||
ESP_LOGI(TAG, "Initializing for Muse");
|
|
||||||
|
ws2812_control_init();
|
||||||
|
float value = battery_value_svc();
|
||||||
|
set_battery_led(value);
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Initializing for Muse %f", value);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define VGREEN 4.0
|
||||||
|
#define VRED 3.6
|
||||||
|
|
||||||
|
static void set_battery_led(float value) {
|
||||||
|
struct led_state new_state;
|
||||||
|
|
||||||
|
if (value > VGREEN) new_state.leds[0] = GREEN;
|
||||||
|
else if (value < VRED) new_state.leds[0] = RED;
|
||||||
|
else new_state.leds[0] = YELLOW;
|
||||||
|
|
||||||
|
ws2812_write_leds(new_state);
|
||||||
|
}
|
||||||
|
|
||||||
static void battery_svc(float value) {
|
static void battery_svc(float value) {
|
||||||
|
set_battery_led(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
|
|
||||||
/*
|
|
||||||
static void battery(void *data)
|
|
||||||
{
|
|
||||||
#define VGREEN 2300
|
|
||||||
#define VRED 2000
|
|
||||||
#define NM 10
|
|
||||||
static int val;
|
|
||||||
static int V[NM];
|
|
||||||
static int I=0;
|
|
||||||
int S;
|
|
||||||
for(int i=0;i<NM;i++)V[i]=VGREEN;
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
struct led_state new_state;
|
|
||||||
ws2812_control_init();
|
|
||||||
// init ADC interface for battery survey
|
|
||||||
adc1_config_width(ADC_WIDTH_BIT_12);
|
|
||||||
adc1_config_channel_atten(ADC1_GPIO33_CHANNEL, ADC_ATTEN_DB_11);
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
V[I++] = adc1_get_raw(ADC1_GPIO33_CHANNEL);
|
|
||||||
if(I >= NM)I = 0;
|
|
||||||
S = 0;
|
|
||||||
for(int i=0;i<NM;i++)S = S + V[i];
|
|
||||||
val = S / NM;
|
|
||||||
new_state.leds[0] = YELLOW;
|
|
||||||
if(val > VGREEN) new_state.leds[0] = GREEN;
|
|
||||||
if(val < VRED) new_state.leds[0] = RED;
|
|
||||||
printf("====> %d %6x\n", val, new_state.leds[0]);
|
|
||||||
ws2812_write_leds(new_state);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 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];
|
||||||
|
|
||||||
@@ -139,5 +124,5 @@ void setup_rmt_data_buffer(struct led_state new_state)
|
|||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
const struct target_s *target_set[] = { &target_muse, NULL };
|
const struct target_s *target_set[] = { &target_muse, NULL };
|
||||||
|
|
||||||
void target_init(char *target) {
|
void target_init(char *target) {
|
||||||
for (int i = 0; target_set[i]; i++) if (strcasestr(target_set[i]->model, target)) {
|
for (int i = 0; *target && target_set[i]; i++) if (strcasestr(target_set[i]->model, target)) {
|
||||||
target_set[i]->init();
|
target_set[i]->init();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,12 +133,12 @@ menu "Squeezelite-ESP32"
|
|||||||
default ""
|
default ""
|
||||||
config AUDIO_CONTROLS
|
config AUDIO_CONTROLS
|
||||||
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, \"long_press\":1000, \"normal\":{\"pressed\":\"ACTRLS_TOGGLE\"},\"longpress\":{\"pressed\":\"ACTRLS_POWER\"}}]" if MUSE
|
||||||
default ""
|
default ""
|
||||||
config BAT_CONFIG
|
config BAT_CONFIG
|
||||||
string
|
string
|
||||||
default "channel=7,scale=20.24,atten=0" if SQUEEZEAMP
|
default "channel=7,scale=20.24,atten=0" if SQUEEZEAMP
|
||||||
default "channel=5,scale=1,atten=3,cells=1" if MUSE
|
default "channel=5,scale=7.48,atten=3,cells=1" if MUSE
|
||||||
default ""
|
default ""
|
||||||
config TARGET
|
config TARGET
|
||||||
string
|
string
|
||||||
@@ -163,7 +163,6 @@ menu "Squeezelite-ESP32"
|
|||||||
config LED_GREEN_GPIO
|
config LED_GREEN_GPIO
|
||||||
int
|
int
|
||||||
default 12 if SQUEEZEAMP
|
default 12 if SQUEEZEAMP
|
||||||
default 22 if MUSE
|
|
||||||
default -1
|
default -1
|
||||||
config LED_RED_GPIO
|
config LED_RED_GPIO
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ void app_main()
|
|||||||
ESP_LOGI(TAG,"Initializing display");
|
ESP_LOGI(TAG,"Initializing display");
|
||||||
display_init("SqueezeESP32");
|
display_init("SqueezeESP32");
|
||||||
MEMTRACE_PRINT_DELTA();
|
MEMTRACE_PRINT_DELTA();
|
||||||
char *target = config_alloc_get_default(NVS_TYPE_STR, "target", CONFIG_TARGET, 0);
|
char *target = config_alloc_get_str("target", CONFIG_TARGET, NULL);
|
||||||
if (target) {
|
if (target) {
|
||||||
target_init(target);
|
target_init(target);
|
||||||
free(target);
|
free(target);
|
||||||
@@ -481,7 +481,7 @@ void app_main()
|
|||||||
|
|
||||||
if(!is_recovery_running){
|
if(!is_recovery_running){
|
||||||
ESP_LOGD(TAG,"Getting audio control mapping ");
|
ESP_LOGD(TAG,"Getting audio control mapping ");
|
||||||
char *actrls_config = config_alloc_get_default(NVS_TYPE_STR, "actrls_config", CONFIG_AUDIO_CONTROLS, 0);
|
char *actrls_config = config_alloc_get_default(NVS_TYPE_STR, "actrls_config", "", 0);
|
||||||
if (actrls_init(actrls_config) == ESP_OK) {
|
if (actrls_init(actrls_config) == ESP_OK) {
|
||||||
ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_config);
|
ESP_LOGD(TAG,"Initializing audio control buttons type %s", actrls_config);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user