mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
auto-detect DAC
This commit is contained in:
@@ -60,7 +60,9 @@ static void battery_callback(TimerHandle_t xTimer) {
|
||||
*/
|
||||
void battery_svc_init(void) {
|
||||
battery.channel = CONFIG_BAT_CHANNEL;
|
||||
#ifdef CONFIG_BAT_SCALE
|
||||
battery.scale = atof(CONFIG_BAT_SCALE);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BAT_LOCKED
|
||||
char *nvs_item = config_alloc_get_default(NVS_TYPE_STR, "bat_config", "n", 0);
|
||||
|
||||
@@ -36,9 +36,9 @@ static struct led_s {
|
||||
|
||||
static struct {
|
||||
int gpio;
|
||||
int state;
|
||||
} green = { CONFIG_LED_GREEN_GPIO, CONFIG_LED_GREEN_GPIO_LEVEL},
|
||||
red = { CONFIG_LED_RED_GPIO, CONFIG_LED_RED_GPIO_LEVEL };
|
||||
int active;
|
||||
} green = { CONFIG_LED_GREEN_GPIO, 0 },
|
||||
red = { CONFIG_LED_RED_GPIO, 0 };
|
||||
|
||||
/****************************************************************************************
|
||||
*
|
||||
@@ -162,19 +162,27 @@ void set_led_gpio(int gpio, char *value) {
|
||||
|
||||
if (strcasestr(value, "green")) {
|
||||
green.gpio = gpio;
|
||||
if ((p = strchr(value, ':')) != NULL) green.state = atoi(p + 1);
|
||||
if ((p = strchr(value, ':')) != NULL) green.active = atoi(p + 1);
|
||||
} else if (strcasestr(value, "red")) {
|
||||
red.state = gpio;
|
||||
if ((p = strchr(value, ':')) != NULL) red.state = atoi(p + 1);
|
||||
red.active = gpio;
|
||||
if ((p = strchr(value, ':')) != NULL) red.active = atoi(p + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void led_svc_init(void) {
|
||||
|
||||
#ifdef CONFIG_LED_GREEN_GPIO_LEVEL
|
||||
green.active = CONFIG_LED_GREEN_GPIO_LEVEL;
|
||||
#endif
|
||||
#ifdef CONFIG_LED_RED_GPIO_LEVEL
|
||||
red.active = CONFIG_LED_RED_GPIO_LEVEL;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_LED_LOCKED
|
||||
parse_set_GPIO(set_led_gpio);
|
||||
#endif
|
||||
ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d), red:%d (active:%d)", green.gpio, green.state, red.gpio, red.state);
|
||||
ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d), red:%d (active:%d)", green.gpio, green.active, red.gpio, red.active);
|
||||
|
||||
led_config(LED_GREEN, green.gpio, green.state);
|
||||
led_config(LED_RED, red.gpio, red.state);
|
||||
led_config(LED_GREEN, green.gpio, green.active);
|
||||
led_config(LED_RED, red.gpio, red.active);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "globdefs.h"
|
||||
#include "config.h"
|
||||
#include "accessors.h"
|
||||
|
||||
#define MONITOR_TIMER (10*1000)
|
||||
|
||||
static const char *TAG = "monitor";
|
||||
@@ -30,8 +31,8 @@ static TimerHandle_t monitor_timer;
|
||||
static struct {
|
||||
int gpio;
|
||||
int active;
|
||||
} jack = { CONFIG_JACK_GPIO, CONFIG_JACK_GPIO_LEVEL },
|
||||
spkfault = { CONFIG_SPKFAULT_GPIO, CONFIG_SPKFAULT_GPIO_LEVEL };
|
||||
} jack = { CONFIG_JACK_GPIO, 0 },
|
||||
spkfault = { CONFIG_SPKFAULT_GPIO, 0 };
|
||||
|
||||
void (*jack_handler_svc)(bool inserted);
|
||||
bool jack_inserted_svc(void);
|
||||
@@ -91,13 +92,28 @@ void set_jack_gpio(int gpio, char *value) {
|
||||
jack.gpio = gpio;
|
||||
if ((p = strchr(value, ':')) != NULL) jack.active = atoi(p + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
*
|
||||
*/
|
||||
void set_spkfault_gpio(int gpio, char *value) {
|
||||
if (strcasestr(value, "spkfault")) {
|
||||
char *p;
|
||||
spkfault.gpio = gpio;
|
||||
if ((p = strchr(value, ':')) != NULL) spkfault.active = atoi(p + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
*
|
||||
*/
|
||||
void monitor_svc_init(void) {
|
||||
ESP_LOGI(TAG, "Initializing monitoring");
|
||||
|
||||
#ifdef CONFIG_JACK_GPIO_LEVEL
|
||||
jack.active = CONFIG_JACK_GPIO_LEVEL;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_JACK_LOCKED
|
||||
parse_set_GPIO(set_jack_gpio);
|
||||
@@ -108,6 +124,10 @@ void monitor_svc_init(void) {
|
||||
ESP_LOGI(TAG,"Adding jack (%s) detection GPIO %d", jack.active ? "high" : "low", jack.gpio);
|
||||
button_create(NULL, jack.gpio, jack.active ? BUTTON_HIGH : BUTTON_LOW, false, 250, jack_handler_default, 0, -1);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPKFAULT_GPIO_LEVEL
|
||||
spkfault.active = CONFIG_SPKFAULT_GPIO_LEVEL;
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SPKFAULT_LOCKED
|
||||
parse_set_GPIO(set_spkfault_gpio);
|
||||
|
||||
Reference in New Issue
Block a user