mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-17 13:08:51 +03:00
ledvu-update-clean
This commit is contained in:
@@ -55,6 +55,7 @@ static EXT_RAM_ATTR struct {
|
||||
int vu_start_l;
|
||||
int vu_start_r;
|
||||
int vu_status;
|
||||
int vu_scale;
|
||||
} strip;
|
||||
|
||||
static int led_addr(int pos ) {
|
||||
@@ -76,25 +77,17 @@ static void battery_svc(float value, int cells) {
|
||||
*/
|
||||
void led_vu_init()
|
||||
{
|
||||
char* p;
|
||||
char* config = config_alloc_get_str("led_vu_config", NULL, "N/A");
|
||||
|
||||
// Initialize led VU strip
|
||||
char* drivername = strcasestr(config, "WS2812");
|
||||
|
||||
if ((p = strcasestr(config, "length")) != NULL) {
|
||||
strip.length = atoi(strchr(p, '=') + 1);
|
||||
} // else 0
|
||||
if ((p = strcasestr(config, "gpio")) != NULL) {
|
||||
strip.gpio = atoi(strchr(p, '=') + 1);
|
||||
} else {
|
||||
strip.gpio = LED_VU_DEFAULT_GPIO;
|
||||
}
|
||||
PARSE_PARAM(config, "length",'=', strip.length);
|
||||
PARSE_PARAM(config, "gpio",'=', strip.gpio);
|
||||
// check for valid configuration
|
||||
if (!drivername || !strip.gpio) {
|
||||
if (!strip.gpio) {
|
||||
ESP_LOGI(TAG, "led_vu configuration invalid");
|
||||
goto done;
|
||||
}
|
||||
strip.vu_scale = 100;
|
||||
PARSE_PARAM(config, "scale",'=',strip.vu_scale);
|
||||
|
||||
battery_handler_chain = battery_handler_svc;
|
||||
battery_handler_svc = battery_svc;
|
||||
@@ -114,7 +107,7 @@ void led_vu_init()
|
||||
strip.vu_start_r = strip.vu_length + 1;
|
||||
strip.vu_status = strip.vu_length;
|
||||
}
|
||||
ESP_LOGI(TAG, "vu meter using length:%d left:%d right:%d status:%d", strip.vu_length, strip.vu_start_l, strip.vu_start_r, strip.vu_status);
|
||||
ESP_LOGI(TAG, "vu meter using length:%d left:%d right:%d status:%d scale:%d", strip.vu_length, strip.vu_start_l, strip.vu_start_r, strip.vu_status, strip.vu_scale);
|
||||
|
||||
// create driver configuration
|
||||
led_strip_config.rgb_led_type = RGB_LED_TYPE_WS2812;
|
||||
@@ -157,6 +150,14 @@ uint16_t led_vu_string_length() {
|
||||
return (uint16_t)strip.length;
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
* Returns a user defined scale (percent)
|
||||
*/
|
||||
uint16_t led_vu_scale() {
|
||||
if (!led_display) return 0;
|
||||
return (uint16_t)strip.vu_scale;
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
* Turns all LEDs off (Black)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user