mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 12:37:01 +03:00
Compare commits
16 Commits
developmen
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
889b1097cc | ||
|
|
41cdb8bcdd | ||
|
|
8c33acfd35 | ||
|
|
0222a34286 | ||
|
|
a90c9802ab | ||
|
|
94da8ca950 | ||
|
|
9a9a4fef65 | ||
|
|
3a7b1f48c7 | ||
|
|
a46bbb409f | ||
|
|
08d16c2ca2 | ||
|
|
b501352ddc | ||
|
|
1c51598366 | ||
|
|
db839a9ccd | ||
|
|
5aba426b98 | ||
|
|
6c184efa92 | ||
|
|
028a090864 |
@@ -35,7 +35,7 @@ static bool I2CDefaultWriteData( struct GDS_Device* Device, const uint8_t* Data,
|
|||||||
bool GDS_I2CInit( int PortNumber, int SDA, int SCL, int Speed ) {
|
bool GDS_I2CInit( int PortNumber, int SDA, int SCL, int Speed ) {
|
||||||
I2CPortNumber = PortNumber;
|
I2CPortNumber = PortNumber;
|
||||||
|
|
||||||
I2CWait = pdMS_TO_TICKS( Speed ? Speed / 4000 : 100 );
|
I2CWait = pdMS_TO_TICKS( Speed ? (250 * 250000) / Speed : 250 );
|
||||||
|
|
||||||
if (SDA != -1 && SCL != -1) {
|
if (SDA != -1 && SCL != -1) {
|
||||||
i2c_config_t Config = { 0 };
|
i2c_config_t Config = { 0 };
|
||||||
|
|||||||
@@ -396,3 +396,27 @@ const char *display_conf_get_driver_name(char * driver){
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
char * display_get_supported_drivers(){
|
||||||
|
int total_size = 1;
|
||||||
|
char * supported_drivers=NULL;
|
||||||
|
const char * separator = "|";
|
||||||
|
int separator_len = strlen(separator);
|
||||||
|
|
||||||
|
for(uint8_t i=0;known_drivers[i]!=NULL && strlen(known_drivers[i])>0;i++ ){
|
||||||
|
total_size += strlen(known_drivers[i])+separator_len;
|
||||||
|
}
|
||||||
|
total_size+=2;
|
||||||
|
supported_drivers = malloc(total_size);
|
||||||
|
memset(supported_drivers,0x00,total_size);
|
||||||
|
strcat(supported_drivers,"<");
|
||||||
|
for(uint8_t i=0;known_drivers[i]!=NULL && strlen(known_drivers[i])>0;i++ ){
|
||||||
|
supported_drivers = strcat(supported_drivers,known_drivers[i]);
|
||||||
|
supported_drivers = strcat(supported_drivers,separator);
|
||||||
|
}
|
||||||
|
strcat(supported_drivers,">");
|
||||||
|
return supported_drivers;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "gds.h"
|
#include "gds.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The displayer is not thread-safe and the caller must ensure use its own
|
The displayer is not thread-safe and the caller must ensure use its own
|
||||||
mutexes if it wants something better. Especially, text() line() and draw()
|
mutexes if it wants something better. Especially, text() line() and draw()
|
||||||
@@ -38,3 +39,4 @@ void displayer_scroll(char *string, int speed, int pause);
|
|||||||
void displayer_control(enum displayer_cmd_e cmd, ...);
|
void displayer_control(enum displayer_cmd_e cmd, ...);
|
||||||
void displayer_metadata(char *artist, char *album, char *title);
|
void displayer_metadata(char *artist, char *album, char *title);
|
||||||
void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);
|
void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);
|
||||||
|
char * display_get_supported_drivers();
|
||||||
|
|||||||
@@ -82,15 +82,17 @@ static struct {
|
|||||||
} i2ccheck_args;
|
} i2ccheck_args;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct arg_lit *clear;
|
|
||||||
struct arg_lit *hflip;
|
|
||||||
struct arg_lit *vflip;
|
|
||||||
struct arg_lit *rotate;
|
|
||||||
struct arg_int *address;
|
|
||||||
struct arg_int *width;
|
|
||||||
struct arg_int *height;
|
|
||||||
struct arg_str *name;
|
struct arg_str *name;
|
||||||
struct arg_str *driver;
|
struct arg_str *driver;
|
||||||
|
struct arg_int *width;
|
||||||
|
struct arg_int *height;
|
||||||
|
struct arg_int *address;
|
||||||
|
struct arg_lit *rotate;
|
||||||
|
struct arg_lit *hflip;
|
||||||
|
struct arg_lit *vflip;
|
||||||
|
struct arg_int *speed;
|
||||||
|
struct arg_int *back;
|
||||||
|
struct arg_lit *clear;
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} i2cdisp_args;
|
} i2cdisp_args;
|
||||||
|
|
||||||
@@ -368,7 +370,7 @@ static int do_i2c_show_display(int argc, char **argv){
|
|||||||
|
|
||||||
static int do_i2c_set_display(int argc, char **argv)
|
static int do_i2c_set_display(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int width=0, height=0, address=60;
|
int width=0, height=0, address=60, back=-1, speed=8000000 ;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
char * name = NULL;
|
char * name = NULL;
|
||||||
char * driver= NULL;
|
char * driver= NULL;
|
||||||
@@ -426,6 +428,7 @@ static int do_i2c_set_display(int argc, char **argv)
|
|||||||
fprintf(f,"Missing parameter: --height\n");
|
fprintf(f,"Missing parameter: --height\n");
|
||||||
nerrors ++;
|
nerrors ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check "--name" option */
|
/* Check "--name" option */
|
||||||
if (i2cdisp_args.name->count) {
|
if (i2cdisp_args.name->count) {
|
||||||
name=strdup(i2cdisp_args.name->sval[0]);
|
name=strdup(i2cdisp_args.name->sval[0]);
|
||||||
@@ -436,6 +439,21 @@ static int do_i2c_set_display(int argc, char **argv)
|
|||||||
driver=strdup(i2cdisp_args.driver->sval[0]);
|
driver=strdup(i2cdisp_args.driver->sval[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check "--speed" option */
|
||||||
|
if (i2cdisp_args.speed->count) {
|
||||||
|
speed=i2cdisp_args.speed->ival[0];
|
||||||
|
}
|
||||||
|
/* Check "--back" option */
|
||||||
|
if (i2cdisp_args.back->count) {
|
||||||
|
back=i2cdisp_args.back->ival[0];
|
||||||
|
if(!GPIO_IS_VALID_OUTPUT_GPIO(back)){
|
||||||
|
fprintf(f,"Invalid GPIO for back light: %d %s\n", back, GPIO_IS_VALID_GPIO(back)?"has input capabilities only":"is not a GPIO");
|
||||||
|
back=-1;
|
||||||
|
nerrors ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!name) name = strdup("I2C");
|
if(!name) name = strdup("I2C");
|
||||||
if(!driver) driver = strdup("SSD1306");
|
if(!driver) driver = strdup("SSD1306");
|
||||||
|
|
||||||
@@ -456,8 +474,8 @@ static int do_i2c_set_display(int argc, char **argv)
|
|||||||
bool rotate = i2cdisp_args.rotate->count>0;
|
bool rotate = i2cdisp_args.rotate->count>0;
|
||||||
|
|
||||||
if(nerrors==0){
|
if(nerrors==0){
|
||||||
snprintf(config_string, sizeof(config_string),"%s:width=%i,height=%i,address=%i,driver=%s%s%s",
|
snprintf(config_string, sizeof(config_string),"%s:back=%i,speed=%i,width=%i,height=%i,address=%i,driver=%s%s%s",
|
||||||
name,width,height,address,driver,rotate || i2cdisp_args.hflip->count?",HFlip":"",rotate || i2cdisp_args.vflip->count?",VFlip":"" );
|
name,back,speed,width,height,address,driver,rotate || i2cdisp_args.hflip->count?",HFlip":"",rotate || i2cdisp_args.vflip->count?",VFlip":"" );
|
||||||
fprintf(f,"Updating display configuration string configuration to :\n"
|
fprintf(f,"Updating display configuration string configuration to :\n"
|
||||||
"display_config = \"%s\"",config_string );
|
"display_config = \"%s\"",config_string );
|
||||||
result = config_set_value(NVS_TYPE_STR, "display_config", config_string)!=ESP_OK;
|
result = config_set_value(NVS_TYPE_STR, "display_config", config_string)!=ESP_OK;
|
||||||
@@ -897,15 +915,19 @@ cJSON * i2c_set_display_cb(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void register_i2c_set_display(){
|
static void register_i2c_set_display(){
|
||||||
|
char * supported_drivers = display_get_supported_drivers();
|
||||||
|
|
||||||
i2cdisp_args.address = arg_int0("a", "address", "<n>", "Set the device address, default 60");
|
i2cdisp_args.address = arg_int0("a", "address", "<n>", "Set the device address, default 60");
|
||||||
i2cdisp_args.width = arg_int0("w", "width", "<n>", "Set the display width");
|
i2cdisp_args.width = arg_int0("w", "width", "<n>", "Set the display width");
|
||||||
i2cdisp_args.height = arg_int0("h", "height", "<n>", "Set the display height");
|
i2cdisp_args.height = arg_int0("h", "height", "<n>", "Set the display height");
|
||||||
i2cdisp_args.name = arg_str0("t", "type", "<I2C|SPI>", "Display type, I2C or SPI. Default I2C");
|
i2cdisp_args.name = arg_str0("t", "type", "<I2C|SPI>", "Display type, I2C or SPI. Default I2C");
|
||||||
i2cdisp_args.driver = arg_str0("d", "driver", "<string>", "Set the display driver name. Default SSD1306");
|
i2cdisp_args.driver = arg_str0("d", "driver", supported_drivers?supported_drivers:"<string>", "Set the display driver name. Default SSD1306");
|
||||||
i2cdisp_args.clear = arg_lit0(NULL, "clear", "clear configuration and return");
|
i2cdisp_args.clear = arg_lit0(NULL, "clear", "clear configuration and return");
|
||||||
i2cdisp_args.hflip = arg_lit0(NULL, "hf", "Flip picture horizontally");
|
i2cdisp_args.hflip = arg_lit0(NULL, "hf", "Flip picture horizontally");
|
||||||
i2cdisp_args.vflip = arg_lit0(NULL, "vf", "Flip picture vertically");
|
i2cdisp_args.vflip = arg_lit0(NULL, "vf", "Flip picture vertically");
|
||||||
i2cdisp_args.rotate = arg_lit0("r", "rotate", "Rotate the picture 180 deg");
|
i2cdisp_args.rotate = arg_lit0("r", "rotate", "Rotate the picture 180 deg");
|
||||||
|
i2cdisp_args.back = arg_int0("b", "back", "<n>","Backlight GPIO (if applicable)");
|
||||||
|
i2cdisp_args.speed = arg_int0("s", "speed", "<n>","Default speed is 8000000 (8MHz) but SPI can work up to 26MHz or even 40MHz");
|
||||||
i2cdisp_args.end = arg_end(8);
|
i2cdisp_args.end = arg_end(8);
|
||||||
const esp_console_cmd_t i2c_set_display= {
|
const esp_console_cmd_t i2c_set_display= {
|
||||||
.command = "setdisplay",
|
.command = "setdisplay",
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ static void vCallbackFunction( TimerHandle_t xTimer ) {
|
|||||||
bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
|
bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
|
||||||
if (!leds[idx].gpio || leds[idx].gpio < 0 ) return false;
|
if (!leds[idx].gpio || leds[idx].gpio < 0 ) return false;
|
||||||
|
|
||||||
ESP_LOGD(TAG,"led_blink_core");
|
ESP_LOGD(TAG,"led_blink_core %d on:%d off:%d, pushed:%u", idx, ontime, offtime, pushed);
|
||||||
if (leds[idx].timer) {
|
if (leds[idx].timer) {
|
||||||
// normal requests waits if a pop is pending
|
// normal requests waits if a pop is pending
|
||||||
if (!pushed && leds[idx].pushed) {
|
if (!pushed && leds[idx].pushed) {
|
||||||
@@ -231,7 +231,6 @@ void led_svc_init(void) {
|
|||||||
#ifndef CONFIG_LED_LOCKED
|
#ifndef CONFIG_LED_LOCKED
|
||||||
parse_set_GPIO(set_led_gpio);
|
parse_set_GPIO(set_led_gpio);
|
||||||
#endif
|
#endif
|
||||||
ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d %d%%), red:%d (active:%d %d%%)", green.gpio, green.active, green.pwm, green.gpio, green.active, green.pwm );
|
|
||||||
|
|
||||||
char *nvs_item = config_alloc_get(NVS_TYPE_STR, "led_brightness"), *p;
|
char *nvs_item = config_alloc_get(NVS_TYPE_STR, "led_brightness"), *p;
|
||||||
if (nvs_item) {
|
if (nvs_item) {
|
||||||
@@ -242,4 +241,6 @@ void led_svc_init(void) {
|
|||||||
|
|
||||||
led_config(LED_GREEN, green.gpio, green.active, green.pwm);
|
led_config(LED_GREEN, green.gpio, green.active, green.pwm);
|
||||||
led_config(LED_RED, red.gpio, red.active, red.pwm);
|
led_config(LED_RED, red.gpio, red.active, red.pwm);
|
||||||
|
|
||||||
|
ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d %d%%), red:%d (active:%d %d%%)", green.gpio, green.active, green.pwm, red.gpio, red.active, red.pwm );
|
||||||
}
|
}
|
||||||
|
|||||||
10
components/squeezelite/external/dac_external.c
vendored
10
components/squeezelite/external/dac_external.c
vendored
@@ -128,12 +128,12 @@ static esp_err_t i2c_write_reg(uint8_t reg, uint8_t val) {
|
|||||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
i2c_master_start(cmd);
|
i2c_master_start(cmd);
|
||||||
|
|
||||||
i2c_master_write_byte(cmd, i2c_addr | I2C_MASTER_WRITE, I2C_MASTER_NACK);
|
i2c_master_write_byte(cmd, (i2c_addr << 1) | I2C_MASTER_WRITE, I2C_MASTER_NACK);
|
||||||
i2c_master_write_byte(cmd, reg, I2C_MASTER_NACK);
|
i2c_master_write_byte(cmd, reg, I2C_MASTER_NACK);
|
||||||
i2c_master_write_byte(cmd, val, I2C_MASTER_NACK);
|
i2c_master_write_byte(cmd, val, I2C_MASTER_NACK);
|
||||||
|
|
||||||
i2c_master_stop(cmd);
|
i2c_master_stop(cmd);
|
||||||
ret = i2c_master_cmd_begin(i2c_port, cmd, 1000 / portTICK_RATE_MS);
|
ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
|
||||||
i2c_cmd_link_delete(cmd);
|
i2c_cmd_link_delete(cmd);
|
||||||
|
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
@@ -153,15 +153,15 @@ static uint8_t i2c_read_reg(uint8_t reg) {
|
|||||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
i2c_master_start(cmd);
|
i2c_master_start(cmd);
|
||||||
|
|
||||||
i2c_master_write_byte(cmd, i2c_addr | I2C_MASTER_WRITE, I2C_MASTER_NACK);
|
i2c_master_write_byte(cmd, (i2c_addr << 1) | I2C_MASTER_WRITE, I2C_MASTER_NACK);
|
||||||
i2c_master_write_byte(cmd, reg, I2C_MASTER_NACK);
|
i2c_master_write_byte(cmd, reg, I2C_MASTER_NACK);
|
||||||
|
|
||||||
i2c_master_start(cmd);
|
i2c_master_start(cmd);
|
||||||
i2c_master_write_byte(cmd, i2c_addr | I2C_MASTER_READ, I2C_MASTER_NACK);
|
i2c_master_write_byte(cmd, (i2c_addr << 1) | I2C_MASTER_READ, I2C_MASTER_NACK);
|
||||||
i2c_master_read_byte(cmd, &data, I2C_MASTER_NACK);
|
i2c_master_read_byte(cmd, &data, I2C_MASTER_NACK);
|
||||||
|
|
||||||
i2c_master_stop(cmd);
|
i2c_master_stop(cmd);
|
||||||
ret = i2c_master_cmd_begin(i2c_port, cmd, 1000 / portTICK_RATE_MS);
|
ret = i2c_master_cmd_begin(i2c_port, cmd, 100 / portTICK_RATE_MS);
|
||||||
i2c_cmd_link_delete(cmd);
|
i2c_cmd_link_delete(cmd);
|
||||||
|
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
|
|||||||
@@ -46,27 +46,17 @@ struct buffer *streambuf = &buf;
|
|||||||
#define UNLOCK mutex_unlock(streambuf->mutex)
|
#define UNLOCK mutex_unlock(streambuf->mutex)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
After a lot of hesitation, I've added that "poll mutex" to prevent
|
When LMS sends a close/open sequence very quickly, the stream thread might
|
||||||
socket from being allocated while we are still in poll(). The issue
|
still be waiting in the poll() on the closed socket. It is never recommended
|
||||||
happens is we have a close quickly followed by an open, we might still
|
to have a thread closing a socket used by another thread but it works, as
|
||||||
be in the poll() and simple OS fail as they re-allocate the same socket
|
opposed to an infinite select().
|
||||||
on which a thread is still waiting.
|
In stream_sock() a new socket is created and full OS will allocate a different
|
||||||
Ideally, you want to set the lock in the disconnect() but that would mean
|
one but on RTOS and simple IP stack, the same might be re-used and that causes
|
||||||
very often we'd have to always wait for the end of the poll(), i.e. up to
|
an exception as a thread is already waiting on a newly allocated socket
|
||||||
100ms for nothing most of the time where if it is in the open(), it is
|
A simple variable that forces stream_sock() to wait until we are out of poll()
|
||||||
less elegant as closing a socket on which there is a poll() is not good
|
is enough and much faster than a mutex
|
||||||
but it's more efficient as it is very rare that you'd have an open() less
|
|
||||||
then 100ms after a close()
|
|
||||||
*/
|
*/
|
||||||
#if EMBEDDED
|
static bool polling;
|
||||||
static mutex_type poll_mutex;
|
|
||||||
#define LOCK_L mutex_lock(poll_mutex)
|
|
||||||
#define UNLOCK_L mutex_unlock(poll_mutex)
|
|
||||||
#else
|
|
||||||
#define LOCK_L
|
|
||||||
#define UNLOCK_L
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static sockfd fd;
|
static sockfd fd;
|
||||||
|
|
||||||
struct streamstate stream;
|
struct streamstate stream;
|
||||||
@@ -209,7 +199,6 @@ static void *stream_thread() {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
LOCK_L;
|
|
||||||
pollinfo.fd = fd;
|
pollinfo.fd = fd;
|
||||||
pollinfo.events = POLLIN;
|
pollinfo.events = POLLIN;
|
||||||
if (stream.state == SEND_HEADERS) {
|
if (stream.state == SEND_HEADERS) {
|
||||||
@@ -218,10 +207,12 @@ static void *stream_thread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UNLOCK;
|
UNLOCK;
|
||||||
|
// no mutex needed - we just want to know if we are inside poll()
|
||||||
|
polling = true;
|
||||||
|
|
||||||
if (_poll(ssl, &pollinfo, 100)) {
|
if (_poll(ssl, &pollinfo, 100)) {
|
||||||
|
|
||||||
UNLOCK_L;
|
polling = false;
|
||||||
LOCK;
|
LOCK;
|
||||||
|
|
||||||
// check socket has not been closed while in poll
|
// check socket has not been closed while in poll
|
||||||
@@ -374,7 +365,7 @@ static void *stream_thread() {
|
|||||||
UNLOCK;
|
UNLOCK;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
UNLOCK_L;
|
polling = false;
|
||||||
LOG_SDEBUG("poll timeout");
|
LOG_SDEBUG("poll timeout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,9 +418,6 @@ void stream_init(log_level level, unsigned stream_buf_size) {
|
|||||||
*stream.header = '\0';
|
*stream.header = '\0';
|
||||||
|
|
||||||
fd = -1;
|
fd = -1;
|
||||||
#if EMBEDDED
|
|
||||||
mutex_create_p(poll_mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if LINUX || FREEBSD
|
#if LINUX || FREEBSD
|
||||||
touch_memory(streambuf->buf, streambuf->size);
|
touch_memory(streambuf->buf, streambuf->size);
|
||||||
@@ -459,9 +447,6 @@ void stream_close(void) {
|
|||||||
#endif
|
#endif
|
||||||
free(stream.header);
|
free(stream.header);
|
||||||
buf_destroy(streambuf);
|
buf_destroy(streambuf);
|
||||||
#if EMBEDDED
|
|
||||||
mutex_destroy(poll_mutex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stream_file(const char *header, size_t header_len, unsigned threshold) {
|
void stream_file(const char *header, size_t header_len, unsigned threshold) {
|
||||||
@@ -503,9 +488,12 @@ void stream_file(const char *header, size_t header_len, unsigned threshold) {
|
|||||||
void stream_sock(u32_t ip, u16_t port, const char *header, size_t header_len, unsigned threshold, bool cont_wait) {
|
void stream_sock(u32_t ip, u16_t port, const char *header, size_t header_len, unsigned threshold, bool cont_wait) {
|
||||||
struct sockaddr_in addr;
|
struct sockaddr_in addr;
|
||||||
|
|
||||||
LOCK_L;
|
#if EMBEDDED
|
||||||
|
// wait till we are not polling anymore
|
||||||
|
while (polling && running) { usleep(10000); }
|
||||||
|
#endif
|
||||||
|
|
||||||
int sock = socket(AF_INET, SOCK_STREAM, 0);
|
int sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
UNLOCK_L;
|
|
||||||
|
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
LOG_ERROR("failed to create socket");
|
LOG_ERROR("failed to create socket");
|
||||||
|
|||||||
@@ -253,6 +253,10 @@ void process_received_data(const char * buffer, size_t size){
|
|||||||
if(bMirrorToUART){
|
if(bMirrorToUART){
|
||||||
write(uart_fd, command, size);
|
write(uart_fd, command, size);
|
||||||
}
|
}
|
||||||
|
for(int i=strlen(command);i>=0;i--){
|
||||||
|
// strip any cr/lf
|
||||||
|
if(command[i]== '\n' || command[i]== '\r') command[i]= '\0';
|
||||||
|
}
|
||||||
run_command((char *)command);
|
run_command((char *)command);
|
||||||
}
|
}
|
||||||
free(command);
|
free(command);
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ var checkStatusInterval = null;
|
|||||||
var StatusIntervalActive = false;
|
var StatusIntervalActive = false;
|
||||||
var RefreshAPIIntervalActive = false;
|
var RefreshAPIIntervalActive = false;
|
||||||
var LastRecoveryState=null;
|
var LastRecoveryState=null;
|
||||||
|
var LastCommandsState=null;
|
||||||
var output = '';
|
var output = '';
|
||||||
|
|
||||||
function stopCheckStatusInterval(){
|
function stopCheckStatusInterval(){
|
||||||
@@ -100,8 +101,98 @@ function RepeatRefreshAPInterval(){
|
|||||||
if(RefreshAPIIntervalActive)
|
if(RefreshAPIIntervalActive)
|
||||||
startRefreshAPInterval();
|
startRefreshAPInterval();
|
||||||
}
|
}
|
||||||
|
function getConfigJson(slimMode){
|
||||||
|
var config = {};
|
||||||
|
$("input.nvs").each(function() {
|
||||||
|
var key = $(this)[0].id;
|
||||||
|
var val = $(this).val();
|
||||||
|
if(!slimMode){
|
||||||
|
var nvs_type = parseInt($(this)[0].attributes.nvs_type.nodeValue,10);
|
||||||
|
if (key != '') {
|
||||||
|
config[key] = {};
|
||||||
|
if(nvs_type == nvs_type_t.NVS_TYPE_U8
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_I8
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_U16
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_I16
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_U32
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_I32
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_U64
|
||||||
|
|| nvs_type == nvs_type_t.NVS_TYPE_I64) {
|
||||||
|
config[key].value = parseInt(val);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config[key].value = val;
|
||||||
|
}
|
||||||
|
config[key].type = nvs_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config[key] = val;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var key = $("#nvs-new-key").val();
|
||||||
|
var val = $("#nvs-new-value").val();
|
||||||
|
if (key != '') {
|
||||||
|
if(!slimMode){
|
||||||
|
config[key] = {};
|
||||||
|
config[key].value = val;
|
||||||
|
config[key].type = 33;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config[key] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onFileLoad(elementId, event) {
|
||||||
|
var data={};
|
||||||
|
try{
|
||||||
|
data = JSON.parse(elementId.srcElement.result);
|
||||||
|
}
|
||||||
|
catch (e){
|
||||||
|
alert('Parsing failed!\r\n '+ e);
|
||||||
|
}
|
||||||
|
$("input.nvs").each(function() {
|
||||||
|
var key = $(this)[0].id;
|
||||||
|
var val = $(this).val();
|
||||||
|
if(data[key]){
|
||||||
|
if(data[key] != val){
|
||||||
|
console.log("Changed "& key & " " & val & "==>" & data[key]);
|
||||||
|
$(this).val(data[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("Value " & key & " missing from file");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onChooseFile(event, onLoadFileHandler) {
|
||||||
|
if (typeof window.FileReader !== 'function')
|
||||||
|
throw ("The file API isn't supported on this browser.");
|
||||||
|
let input = event.target;
|
||||||
|
if (!input)
|
||||||
|
throw ("The browser does not properly implement the event object");
|
||||||
|
if (!input.files)
|
||||||
|
throw ("This browser does not support the `files` property of the file input.");
|
||||||
|
if (!input.files[0])
|
||||||
|
return undefined;
|
||||||
|
let file = input.files[0];
|
||||||
|
let fr = new FileReader();
|
||||||
|
fr.onload = onLoadFileHandler;
|
||||||
|
fr.readAsText(file);
|
||||||
|
input.value="";
|
||||||
|
}
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$("input#show-commands")[0].checked=LastCommandsState==1?true:false;
|
||||||
|
$('a[href^="#tab-commands"]').hide();
|
||||||
|
$("#load-nvs").click(function () {
|
||||||
|
$("#nvsfilename").trigger('click');
|
||||||
|
});
|
||||||
$("#wifi-status").on("click", ".ape", function() {
|
$("#wifi-status").on("click", ".ape", function() {
|
||||||
$( "#wifi" ).slideUp( "fast", function() {});
|
$( "#wifi" ).slideUp( "fast", function() {});
|
||||||
$( "#connect-details" ).slideDown( "fast", function() {});
|
$( "#connect-details" ).slideDown( "fast", function() {});
|
||||||
@@ -210,6 +301,17 @@ $(document).ready(function(){
|
|||||||
$( "#wifi" ).slideDown( "fast", function() {})
|
$( "#wifi" ).slideDown( "fast", function() {})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("input#show-commands").on("click", function() {
|
||||||
|
this.checked=this.checked?1:0;
|
||||||
|
if(this.checked){
|
||||||
|
$('a[href^="#tab-commands"]').show();
|
||||||
|
LastCommandsState = 1;
|
||||||
|
} else {
|
||||||
|
LastCommandsState = 0;
|
||||||
|
$('a[href^="#tab-commands"]').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$("input#show-nvs").on("click", function() {
|
$("input#show-nvs").on("click", function() {
|
||||||
this.checked=this.checked?1:0;
|
this.checked=this.checked?1:0;
|
||||||
if(this.checked){
|
if(this.checked){
|
||||||
@@ -334,42 +436,27 @@ $(document).ready(function(){
|
|||||||
console.log('sent config JSON with data:', JSON.stringify(data));
|
console.log('sent config JSON with data:', JSON.stringify(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("#save-as-nvs").on("click", function() {
|
||||||
|
var data = { 'timestamp': Date.now() };
|
||||||
|
var config = getConfigJson(true);
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = URL.createObjectURL(
|
||||||
|
new Blob([JSON.stringify(config, null, 2)], {
|
||||||
|
type: "text/plain"
|
||||||
|
}));
|
||||||
|
a.setAttribute("download", "nvs_config" + Date.now() +"json");
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
console.log('sent config JSON with headers:', JSON.stringify(headers));
|
||||||
|
console.log('sent config JSON with data:', JSON.stringify(data));
|
||||||
|
});
|
||||||
|
|
||||||
$("#save-nvs").on("click", function() {
|
$("#save-nvs").on("click", function() {
|
||||||
var headers = {};
|
var headers = {};
|
||||||
var data = { 'timestamp': Date.now() };
|
var data = { 'timestamp': Date.now() };
|
||||||
var config = {};
|
var config = getConfigJson(false);
|
||||||
$("input.nvs").each(function() {
|
|
||||||
var key = $(this)[0].id;
|
|
||||||
var val = $(this).val();
|
|
||||||
var nvs_type = parseInt($(this)[0].attributes.nvs_type.nodeValue,10);
|
|
||||||
if (key != '') {
|
|
||||||
config[key] = {};
|
|
||||||
if(nvs_type == nvs_type_t.NVS_TYPE_U8
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I8
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_U16
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I16
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_U32
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I32
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_U64
|
|
||||||
|| nvs_type == nvs_type_t.NVS_TYPE_I64) {
|
|
||||||
config[key].value = parseInt(val);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
config[key].value = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
config[key].type = nvs_type;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var key = $("#nvs-new-key").val();
|
|
||||||
var val = $("#nvs-new-value").val();
|
|
||||||
if (key != '') {
|
|
||||||
// headers["X-Custom-" +key] = val;
|
|
||||||
config[key] = {};
|
|
||||||
config[key].value = val;
|
|
||||||
config[key].type = 33;
|
|
||||||
}
|
|
||||||
data['config'] = config;
|
data['config'] = config;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/config.json',
|
url: '/config.json',
|
||||||
@@ -421,7 +508,6 @@ $(document).ready(function(){
|
|||||||
fwurl : {
|
fwurl : {
|
||||||
value : url,
|
value : url,
|
||||||
type : 33
|
type : 33
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -935,7 +1021,8 @@ function checkStatus(){
|
|||||||
blockAjax = false;
|
blockAjax = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function runCommand(button) {
|
|
||||||
|
function runCommand(button,reboot) {
|
||||||
pardiv = button.parentNode.parentNode;
|
pardiv = button.parentNode.parentNode;
|
||||||
fields=document.getElementById("flds-"+button.value);
|
fields=document.getElementById("flds-"+button.value);
|
||||||
cmdstring=button.value+' ';
|
cmdstring=button.value+' ';
|
||||||
@@ -984,6 +1071,31 @@ function runCommand(button) {
|
|||||||
console.log(xhr.status);
|
console.log(xhr.status);
|
||||||
console.log(thrownError);
|
console.log(thrownError);
|
||||||
if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR');
|
if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR');
|
||||||
|
|
||||||
|
},
|
||||||
|
complete: function(response) {
|
||||||
|
//var returnedResponse = JSON.parse(response.responseText);
|
||||||
|
console.log(response.responseText);
|
||||||
|
if(reboot){
|
||||||
|
showMessage('Applying. Please wait for the ESP32 to reboot', 'MESSAGING_WARNING');
|
||||||
|
console.log('now triggering reboot');
|
||||||
|
$.ajax({
|
||||||
|
url: '/reboot.json',
|
||||||
|
dataType: 'text',
|
||||||
|
method: 'POST',
|
||||||
|
cache: false,
|
||||||
|
contentType: 'application/json; charset=utf-8',
|
||||||
|
data: JSON.stringify({ 'timestamp': Date.now()}),
|
||||||
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
|
console.log(xhr.status);
|
||||||
|
console.log(thrownError);
|
||||||
|
if (thrownError != '') showMessage(thrownError, 'MESSAGING_ERROR');
|
||||||
|
},
|
||||||
|
complete: function(response) {
|
||||||
|
console.log('reboot call completed');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
enableStatusTimer = true;
|
enableStatusTimer = true;
|
||||||
@@ -993,37 +1105,50 @@ function runCommand(button) {
|
|||||||
function getCommands() {
|
function getCommands() {
|
||||||
$.getJSON("/commands.json", function(data) {
|
$.getJSON("/commands.json", function(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
innerhtml='';
|
var advancedtabhtml='';
|
||||||
|
|
||||||
data.commands.forEach(function(command) {
|
data.commands.forEach(function(command) {
|
||||||
innerhtml+='<tr><td>';
|
isConfig=($('#'+command.name+'-list').length>0);
|
||||||
innerhtml+=escapeHTML(command.help).replace(/\n/g, '<br />')+'<br>';
|
innerhtml='';
|
||||||
|
innerhtml+='<tr><td>'+(isConfig?'<h1>':'');
|
||||||
|
innerhtml+=escapeHTML(command.help).replace(/\n/g, '<br />')+(isConfig?'</h1>':'<br>');
|
||||||
innerhtml+='<div >';
|
innerhtml+='<div >';
|
||||||
if(command.hasOwnProperty("argtable")){
|
if(command.hasOwnProperty("argtable")){
|
||||||
innerhtml+='<table class="table table-hover" id="flds-'+command.name+'"><tbody>';
|
innerhtml+='<table class="table table-hover" id="flds-'+command.name+'"><tbody>';
|
||||||
command.argtable.forEach(function (arg){
|
command.argtable.forEach(function (arg){
|
||||||
innerhtml+="<tr>";
|
placeholder=arg?.datatype || '';
|
||||||
ctrlname=command.name+'-'+arg.longopts;
|
ctrlname=command.name+'-'+arg.longopts;
|
||||||
innerhtml+='<td><label for="'+ctrlname+'">'+ arg.glossary+'</label></td>';
|
curvalue=data.values?.[command.name]?.[arg.longopts] || '';
|
||||||
|
innerhtml+="<tr>";
|
||||||
|
var attributes ='datatype="'+arg.datatype+'" ';
|
||||||
|
attributes+='hasvalue='+arg.hasvalue+' ';
|
||||||
|
attributes+='longopts="'+arg.longopts+'" ';
|
||||||
|
attributes+='shortopts="'+arg.shortopts+'" ';
|
||||||
|
attributes+='checkbox='+arg.checkbox+' ';
|
||||||
|
|
||||||
|
|
||||||
|
if(placeholder.includes('|')){
|
||||||
|
placeholder = placeholder.replace('<','').replace('>','');
|
||||||
|
innerhtml+='<td><select name="'+ctrlname+'" ';
|
||||||
|
innerhtml+=attributes;
|
||||||
|
innerhtml+=' class="custom-select">';
|
||||||
|
innerhtml+='<option '+(curvalue.length>0?'value':'selected')+'>'+arg.glossary+'</option>'
|
||||||
|
placeholder.split('|').forEach(function(choice){
|
||||||
|
innerhtml+='<option '+(curvalue.length>0&&curvalue==choice?'selected':'value')+'="'+choice+'">'+choice+'</option>';
|
||||||
|
});
|
||||||
|
innerhtml+='</select></td>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
ctrltype="text";
|
ctrltype="text";
|
||||||
if(arg.checkbox){
|
if(arg.checkbox){
|
||||||
ctrltype="checkbox";
|
ctrltype="checkbox";
|
||||||
}
|
}
|
||||||
curvalue=data.values?.[command.name]?.[arg.longopts] || '';
|
|
||||||
placeholder=arg?.datatype || '';
|
innerhtml+='<td><label for="'+ctrlname+'">'+ arg.glossary+'</label></td>';
|
||||||
innerhtml+='<td><input type="'+ctrltype+'" id="'+ctrlname+'" name="'+ctrlname+'" placeholder="'+placeholder+'" hasvalue="'+arg.hasvalue+'" ';
|
innerhtml+='<td><input type="'+ctrltype+'" id="'+ctrlname+'" name="'+ctrlname+'" placeholder="'+placeholder+'" hasvalue="'+arg.hasvalue+'" ';
|
||||||
|
innerhtml+=attributes;
|
||||||
|
|
||||||
innerhtml+='datatype="'+arg.datatype+'" ';
|
|
||||||
innerhtml+='hasvalue='+arg.hasvalue+' ';
|
|
||||||
innerhtml+='longopts="'+arg.longopts+'" ';
|
|
||||||
innerhtml+='shortopts="'+arg.shortopts+'" ';
|
|
||||||
innerhtml+='checkbox='+arg.checkbox+' ';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(arg.checkbox){
|
if(arg.checkbox){
|
||||||
if(curvalue=data.values?.[command.name]?.[arg.longopts] ){
|
if(data.values?.[command.name]?.[arg.longopts] ){
|
||||||
innerhtml+='checked=true ';
|
innerhtml+='checked=true ';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -1037,16 +1162,25 @@ function getCommands() {
|
|||||||
innerhtml+='value="'+curvalue+'" ';
|
innerhtml+='value="'+curvalue+'" ';
|
||||||
innerhtml+='></input></td>'+ curvalue.length>0?'<td>last: '+curvalue+'</td>':'';
|
innerhtml+='></input></td>'+ curvalue.length>0?'<td>last: '+curvalue+'</td>':'';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
innerhtml+="</tr>";
|
innerhtml+="</tr>";
|
||||||
});
|
});
|
||||||
innerhtml+='</tbody></table><br>';
|
innerhtml+='</tbody></table>';
|
||||||
|
|
||||||
}
|
}
|
||||||
innerhtml+='<div class="buttons"><input id="btn-'+ command.name + '" type="button" class="btn btn-danger btn-sm" value="'+command.name+'" onclick="runCommand(this);"></div></div><td></tr>';
|
if(isConfig){
|
||||||
|
innerhtml+='<div class="buttons"><input id="btn-'+ command.name + '" type="button" class="btn btn-success" value="Save" onclick="runCommand(this,false);">';
|
||||||
|
innerhtml+='<input id="btn-'+ command.name + '-apply" type="button" class="btn btn-success" value="Apply" onclick="runCommand(this,true);"></div></div><td></tr>';
|
||||||
|
$('#'+command.name+'-list').append(innerhtml);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
advancedtabhtml+='<br>'+innerhtml;
|
||||||
|
advancedtabhtml+='<div class="buttons"><input id="btn-'+ command.name + '" type="button" class="btn btn-danger btn-sm" value="'+command.name+'" onclick="runCommand(this);"></div></div><td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
$("#commands-list").append(innerhtml);
|
$("#commands-list").append(advancedtabhtml);
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.fail(function(xhr, ajaxOptions, thrownError) {
|
.fail(function(xhr, ajaxOptions, thrownError) {
|
||||||
|
|||||||
@@ -721,6 +721,7 @@ esp_err_t config_post_handler(httpd_req_t *req){
|
|||||||
|
|
||||||
if(err==ESP_OK){
|
if(err==ESP_OK){
|
||||||
httpd_resp_sendstr(req, "{ \"result\" : \"OK\" }");
|
httpd_resp_sendstr(req, "{ \"result\" : \"OK\" }");
|
||||||
|
messaging_post_message(MESSAGING_INFO,MESSAGING_CLASS_SYSTEM,"Save Success");
|
||||||
}
|
}
|
||||||
cJSON_Delete(root);
|
cJSON_Delete(root);
|
||||||
if(bOTA) {
|
if(bOTA) {
|
||||||
|
|||||||
@@ -67,11 +67,14 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="tab" href="#tab-firmware">Firmware</a>
|
<a class="nav-link" data-toggle="tab" href="#tab-firmware">Firmware</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" href="#tab-setdisplay">Display</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="tab" href="#tab-syslog">Syslog</a>
|
<a class="nav-link" data-toggle="tab" href="#tab-syslog">Syslog</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="tab" href="#tab-commands">System</a>
|
<a class="nav-link" data-toggle="tab" href="#tab-commands">Advanced</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="tab" href="#tab-nvs">NVS editor</a>
|
<a class="nav-link" data-toggle="tab" href="#tab-nvs">NVS editor</a>
|
||||||
@@ -195,6 +198,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- wifi -->
|
</div> <!-- wifi -->
|
||||||
|
<div class="tab-pane fade" id="tab-setdisplay">
|
||||||
|
<table class="table table-hover" id="setdisplay-table">
|
||||||
|
<tbody id="setdisplay-list">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div> <!-- display -->
|
||||||
|
|
||||||
<div class="tab-pane fade" id="tab-audio">
|
<div class="tab-pane fade" id="tab-audio">
|
||||||
<div id="audioout">
|
<div id="audioout">
|
||||||
@@ -304,7 +313,6 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div> <!-- system -->
|
</div> <!-- system -->
|
||||||
|
|
||||||
<div class="tab-pane fade" id="tab-syslog">
|
<div class="tab-pane fade" id="tab-syslog">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -338,7 +346,10 @@
|
|||||||
<button id="reboot-button" type="submit" class="btn btn-primary">Reboot</button>
|
<button id="reboot-button" type="submit" class="btn btn-primary">Reboot</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<input id="save-nvs" type="button" class="btn btn-success" value="Save" />
|
<input id="save-nvs" type="button" class="btn btn-success" value="Commit">
|
||||||
|
<input id="save-as-nvs" type="button" class="btn btn-success" value="Download config">
|
||||||
|
<input id="load-nvs" type="button" class="btn btn-success" value="Load File">
|
||||||
|
<input aria-describedby="fileHelp" onchange="onChooseFile(event, onFileLoad.bind(this))" id="nvsfilename" type="file" style="display:none">
|
||||||
</div>
|
</div>
|
||||||
</div> <!-- nvs -->
|
</div> <!-- nvs -->
|
||||||
|
|
||||||
@@ -363,6 +374,11 @@
|
|||||||
<input type="checkbox" class="custom-control-input" id="show-nvs" checked="checked">
|
<input type="checkbox" class="custom-control-input" id="show-nvs" checked="checked">
|
||||||
<label class="custom-control-label" for="show-nvs"></label>
|
<label class="custom-control-label" for="show-nvs"></label>
|
||||||
</div>
|
</div>
|
||||||
|
<h2>Show Advanced Commands</h2>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="show-commands" checked="checked">
|
||||||
|
<label class="custom-control-label" for="show-commands"></label>
|
||||||
|
</div>
|
||||||
</div> <!-- credits -->
|
</div> <!-- credits -->
|
||||||
</div>
|
</div>
|
||||||
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
|
<footer class="footer"><span id="foot-fw"></span><span id="foot-wifi"></span></footer>
|
||||||
|
|||||||
@@ -462,7 +462,11 @@ cJSON * wifi_manager_get_basic_info(cJSON **old){
|
|||||||
cJSON_AddNumberToObject(root,"Voltage", battery_value_svc());
|
cJSON_AddNumberToObject(root,"Voltage", battery_value_svc());
|
||||||
cJSON_AddNumberToObject(root,"disconnect_count", num_disconnect );
|
cJSON_AddNumberToObject(root,"disconnect_count", num_disconnect );
|
||||||
cJSON_AddNumberToObject(root,"avg_conn_time", num_disconnect>0?(total_connected_time/num_disconnect):0 );
|
cJSON_AddNumberToObject(root,"avg_conn_time", num_disconnect>0?(total_connected_time/num_disconnect):0 );
|
||||||
|
#if CONFIG_I2C_LOCKED
|
||||||
|
cJSON_AddTrueToObject(root, "is_i2c_locked");
|
||||||
|
#else
|
||||||
|
cJSON_AddFalseToObject(root, "is_i2c_locked");
|
||||||
|
#endif
|
||||||
ESP_LOGV(TAG, "wifi_manager_get_basic_info done");
|
ESP_LOGV(TAG, "wifi_manager_get_basic_info done");
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ menu "Squeezelite-ESP32"
|
|||||||
string
|
string
|
||||||
default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP
|
default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP
|
||||||
default "model=AC101,bck=27,ws=26,do=25,di=35,sda=33,scl=32" if A1S
|
default "model=AC101,bck=27,ws=26,do=25,di=35,sda=33,scl=32" if A1S
|
||||||
default "model=I2S,bck=26,ws=25,do=33,i2c=106,sda=21,scl=22" if TWATCH2020
|
default "model=I2S,bck=26,ws=25,do=33,i2c=53,sda=21,scl=22" if TWATCH2020
|
||||||
default ""
|
default ""
|
||||||
config SPDIF_CONFIG
|
config SPDIF_CONFIG
|
||||||
string
|
string
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ void app_main()
|
|||||||
|
|
||||||
/* start the wifi manager */
|
/* start the wifi manager */
|
||||||
ESP_LOGD(TAG,"Blinking led");
|
ESP_LOGD(TAG,"Blinking led");
|
||||||
led_blink(LED_GREEN, 250, 250);
|
led_blink_pushed(LED_GREEN, 250, 250);
|
||||||
|
|
||||||
if(bypass_wifi_manager){
|
if(bypass_wifi_manager){
|
||||||
ESP_LOGW(TAG,"*******************************************************************************************");
|
ESP_LOGW(TAG,"*******************************************************************************************");
|
||||||
|
|||||||
Binary file not shown.
@@ -78,7 +78,7 @@ sub displayWidth {
|
|||||||
if ($display->widthOverride) {
|
if ($display->widthOverride) {
|
||||||
my $artwork = $prefs->client($client)->get('artwork');
|
my $artwork = $prefs->client($client)->get('artwork');
|
||||||
if ($artwork->{'enable'} && $artwork->{'y'} < 32 && ($client->isPlaying || $client->isPaused)) {
|
if ($artwork->{'enable'} && $artwork->{'y'} < 32 && ($client->isPlaying || $client->isPaused)) {
|
||||||
return $artwork->{x} + ($display->modes->[$mode || 0]{_width} || 0);
|
return ($artwork->{x} || $display->widthOverride) + ($display->modes->[$mode || 0]{_width} || 0);
|
||||||
} else {
|
} else {
|
||||||
return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
|
return $display->widthOverride + ($display->modes->[$mode || 0]{_width} || 0);
|
||||||
}
|
}
|
||||||
@@ -113,9 +113,9 @@ sub build_modes {
|
|||||||
my $artwork = $cprefs->get('artwork');
|
my $artwork = $cprefs->get('artwork');
|
||||||
my $disp_width = $cprefs->get('width') || 128;
|
my $disp_width = $cprefs->get('width') || 128;
|
||||||
|
|
||||||
# if artwork is in main display, reduce width
|
# if artwork is in main display, reduce width but when artwork is (0,0) fake it
|
||||||
my $width = ($artwork->{'enable'} && $artwork->{'y'} < 32) ? $artwork->{'x'} : $disp_width;
|
my $width = ($artwork->{'enable'} && $artwork->{'y'} < 32 && $artwork->{'x'}) ? $artwork->{'x'} : $disp_width;
|
||||||
my $width_low = ($artwork->{'enable'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width;
|
my $width_low = ($artwork->{'enable'} && $artwork->{'x'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width;
|
||||||
|
|
||||||
my $small_VU = $cprefs->get('small_VU');
|
my $small_VU = $cprefs->get('small_VU');
|
||||||
my $spectrum = $cprefs->get('spectrum');
|
my $spectrum = $cprefs->get('spectrum');
|
||||||
|
|||||||
@@ -13,6 +13,19 @@ my $sprefs = preferences('server');
|
|||||||
my $prefs = preferences('plugin.squeezeesp32');
|
my $prefs = preferences('plugin.squeezeesp32');
|
||||||
my $log = logger('plugin.squeezeesp32');
|
my $log = logger('plugin.squeezeesp32');
|
||||||
|
|
||||||
|
{
|
||||||
|
__PACKAGE__->mk_accessor('rw', 'tone_update');
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my $class = shift;
|
||||||
|
my $client = $class->SUPER::new(@_);
|
||||||
|
$client->init_accessor(
|
||||||
|
tone_update => 0,
|
||||||
|
);
|
||||||
|
return $client;
|
||||||
|
}
|
||||||
|
|
||||||
our $defaultPrefs = {
|
our $defaultPrefs = {
|
||||||
'analogOutMode' => 0,
|
'analogOutMode' => 0,
|
||||||
'bass' => 0,
|
'bass' => 0,
|
||||||
@@ -44,7 +57,6 @@ sub hasIR { 1 }
|
|||||||
# TODO: add in settings when ready
|
# TODO: add in settings when ready
|
||||||
sub hasLineIn { 0 }
|
sub hasLineIn { 0 }
|
||||||
sub hasHeadSubOut { 1 }
|
sub hasHeadSubOut { 1 }
|
||||||
# TODO: LMS sliders are hard-coded in html file from -23 to +23
|
|
||||||
sub maxTreble { 20 }
|
sub maxTreble { 20 }
|
||||||
sub minTreble { -13 }
|
sub minTreble { -13 }
|
||||||
sub maxBass { 20 }
|
sub maxBass { 20 }
|
||||||
@@ -117,25 +129,41 @@ sub playerSettingsFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub bass {
|
sub bass {
|
||||||
return tone(2, @_);
|
my ($client, $new) = @_;
|
||||||
|
my $value = $client->SUPER::bass($new);
|
||||||
|
|
||||||
|
$client->update_equalizer($value, [2, 1, 3]) if defined $new;
|
||||||
|
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub treble {
|
sub treble {
|
||||||
return tone(8, @_);
|
my ($client, $new) = @_;
|
||||||
|
my $value = $client->SUPER::treble($new);
|
||||||
|
|
||||||
|
$client->update_equalizer($value, [8, 9, 7]) if defined $new;
|
||||||
|
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub tone {
|
sub update_equalizer {
|
||||||
my ($center, $client, $value) = @_;
|
my ($client, $value, $index) = @_;
|
||||||
my $equalizer = $prefs->client($client)->get('equalizer');
|
return if $client->tone_update;
|
||||||
|
|
||||||
if (defined($value)) {
|
my $equalizer = $prefs->client($client)->get('equalizer');
|
||||||
$equalizer->[$center-1] = int($value * 0.2 + 0.5);
|
$equalizer->[$index->[0]] = $value;
|
||||||
$equalizer->[$center] = int($value * 0.7 + 0.5);
|
$equalizer->[$index->[1]] = int($value / 2 + 0.5);
|
||||||
$equalizer->[$center+1] = int($value * 0.1 + 0.5);
|
$equalizer->[$index->[2]] = int($value / 4 + 0.5);
|
||||||
$prefs->client($client)->set('equalizer', $equalizer);
|
$prefs->client($client)->set('equalizer', $equalizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return int($equalizer->[$center-1] * 0.2 + $equalizer->[$center] * 0.7 + $equalizer->[$center+1] * 0.1);
|
sub update_tones {
|
||||||
|
my ($client, $equalizer) = @_;
|
||||||
|
|
||||||
|
$client->tone_update(1);
|
||||||
|
$sprefs->client($client)->set('bass', int(($equalizer->[1] * 2 + $equalizer->[2] + $equalizer->[3] * 4) / 7 + 0.5));
|
||||||
|
$sprefs->client($client)->set('treble', int(($equalizer->[7] * 4 + $equalizer->[8] + $equalizer->[9] * 2) / 7 + 0.5));
|
||||||
|
$client->tone_update(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub update_artwork {
|
sub update_artwork {
|
||||||
@@ -193,6 +221,11 @@ sub clear_artwork {
|
|||||||
if ($artwork && $artwork->{'enable'}) {
|
if ($artwork && $artwork->{'enable'}) {
|
||||||
main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . $request->getRequestString());
|
main::INFOLOG && $log->is_info && $log->info("artwork stop/clear " . $request->getRequestString());
|
||||||
$client->pluginData('artwork_md5', '');
|
$client->pluginData('artwork_md5', '');
|
||||||
|
# refresh screen and disable artwork when artwork was full screen (hack)
|
||||||
|
if (!$artwork->{'x'} && !$artwork->{'y'}) {
|
||||||
|
$client->sendFrame(grfa => \("\x00"x4)) unless $artwork->{'x'} || $artwork->{'y'};
|
||||||
|
$client->display->update;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ sub page {
|
|||||||
sub prefs {
|
sub prefs {
|
||||||
my ($class, $client) = @_;
|
my ($class, $client) = @_;
|
||||||
my @prefs;
|
my @prefs;
|
||||||
push @prefs, qw(width small_VU) if $client->displayWidth;
|
push @prefs, qw(width small_VU) if defined $client->displayWidth;
|
||||||
return ($prefs->client($client), @prefs);
|
return ($prefs->client($client), @prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ sub handler {
|
|||||||
my ($cprefs, @prefs) = $class->prefs($client);
|
my ($cprefs, @prefs) = $class->prefs($client);
|
||||||
|
|
||||||
if ($paramRef->{'saveSettings'}) {
|
if ($paramRef->{'saveSettings'}) {
|
||||||
if ($client->displayWidth) {
|
if (defined $client->displayWidth) {
|
||||||
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
|
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
|
||||||
my $spectrum = {
|
my $spectrum = {
|
||||||
scale => $paramRef->{'pref_spectrum_scale'} || 25,
|
scale => $paramRef->{'pref_spectrum_scale'} || 25,
|
||||||
@@ -73,9 +73,10 @@ sub handler {
|
|||||||
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
|
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
|
||||||
}
|
}
|
||||||
$cprefs->set('equalizer', $equalizer);
|
$cprefs->set('equalizer', $equalizer);
|
||||||
|
$client->update_tones($equalizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($client->displayWidth) {
|
if (defined $client->displayWidth) {
|
||||||
# the Settings super class can't handle anything but scalar values
|
# the Settings super class can't handle anything but scalar values
|
||||||
# we need to populate the $paramRef for the other prefs manually
|
# we need to populate the $paramRef for the other prefs manually
|
||||||
$paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
|
$paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
<name>PLUGIN_SQUEEZEESP32</name>
|
<name>PLUGIN_SQUEEZEESP32</name>
|
||||||
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
||||||
<module>Plugins::SqueezeESP32::Plugin</module>
|
<module>Plugins::SqueezeESP32::Plugin</module>
|
||||||
<version>0.100</version>
|
<version>0.104</version>
|
||||||
<creator>Philippe</creator>
|
<creator>Philippe</creator>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?xml version='1.0' standalone='yes'?>
|
<?xml version='1.0' standalone='yes'?>
|
||||||
<extensions>
|
<extensions>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin version="0.100" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
<plugin version="0.104" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
||||||
<link>https://github.com/sle118/squeezelite-esp32</link>
|
<link>https://github.com/sle118/squeezelite-esp32</link>
|
||||||
<creator>Philippe</creator>
|
<creator>Philippe</creator>
|
||||||
<sha>572fa8afeaa3bc3cfb245b8d42ba05739aec584b</sha>
|
<sha>79e505a30d7b6dbf43893acab176d57438e2a4a1</sha>
|
||||||
<email>philippe_44@outlook.com</email>
|
<email>philippe_44@outlook.com</email>
|
||||||
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
|
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
|
||||||
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>
|
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>
|
||||||
|
|||||||
Reference in New Issue
Block a user