diff --git a/components/display/driver_SSD13x6.c b/components/display/driver_SSD13x6.c index e5bc3be9..252225ca 100644 --- a/components/display/driver_SSD13x6.c +++ b/components/display/driver_SSD13x6.c @@ -124,12 +124,13 @@ static bool init(char *config, char *welcome) { ESP_LOGI(TAG, "Display is I2C on port %u", address); } else if (strstr(config, "SPI") && spi_system_host != -1) { - int CS_pin = -1; + int CS_pin = -1, speed = 0; - if ((p = strcasestr(config, "CS")) != NULL) CS_pin = atoi(strchr(p, '=') + 1); + if ((p = strcasestr(config, "cs")) != NULL) CS_pin = atoi(strchr(p, '=') + 1); + if ((p = strcasestr(config, "speed")) != NULL) speed = atoi(strchr(p, '=') + 1); SSD13x6_SPIMasterInitDefault( spi_system_host, spi_system_dc_gpio ); - SSD13x6_SPIMasterAttachDisplayDefault( &Display, model, width, height, CS_pin, -1 ); + SSD13x6_SPIMasterAttachDisplayDefault( &Display, model, width, height, CS_pin, -1, speed ); SSD13x6_SetFont( &Display, &Font_droid_sans_fallback_15x17 ); SSD13x6_display.width = width; SSD13x6_display.height = height; diff --git a/components/display/tarablessd13x6/ifaces/default_if_spi.c b/components/display/tarablessd13x6/ifaces/default_if_spi.c index 2d7336c4..997ff9ad 100644 --- a/components/display/tarablessd13x6/ifaces/default_if_spi.c +++ b/components/display/tarablessd13x6/ifaces/default_if_spi.c @@ -33,7 +33,7 @@ bool SSD13x6_SPIMasterInitDefault( int SPI, int DC ) { return true; } -bool SSD13x6_SPIMasterAttachDisplayDefault( struct SSD13x6_Device* DeviceHandle, int Model, int Width, int Height, int CSPin, int RSTPin ) { +bool SSD13x6_SPIMasterAttachDisplayDefault( struct SSD13x6_Device* DeviceHandle, int Model, int Width, int Height, int CSPin, int RSTPin, int Speed ) { spi_device_interface_config_t SPIDeviceConfig; spi_device_handle_t SPIDeviceHandle; @@ -46,7 +46,7 @@ bool SSD13x6_SPIMasterAttachDisplayDefault( struct SSD13x6_Device* DeviceHandle, memset( &SPIDeviceConfig, 0, sizeof( spi_device_interface_config_t ) ); - SPIDeviceConfig.clock_speed_hz = SPI_MASTER_FREQ_8M; + SPIDeviceConfig.clock_speed_hz = Speed > 0 ? Speed : SPI_MASTER_FREQ_8M; SPIDeviceConfig.spics_io_num = CSPin; SPIDeviceConfig.queue_size = 1; diff --git a/components/display/tarablessd13x6/ssd13x6_default_if.h b/components/display/tarablessd13x6/ssd13x6_default_if.h index d7c4b1cc..c1173e14 100644 --- a/components/display/tarablessd13x6/ssd13x6_default_if.h +++ b/components/display/tarablessd13x6/ssd13x6_default_if.h @@ -9,7 +9,7 @@ bool SSD13x6_I2CMasterInitDefault( int PortNumber, int SDA, int SCL ); bool SSD13x6_I2CMasterAttachDisplayDefault( struct SSD13x6_Device* DisplayHandle, int Model, int Width, int Height, int I2CAddress, int RSTPin ); bool SSD13x6_SPIMasterInitDefault( int SPI, int DC); -bool SSD13x6_SPIMasterAttachDisplayDefault( struct SSD13x6_Device* DeviceHandle, int Model, int Width, int Height, int CSPin, int RSTPin ); +bool SSD13x6_SPIMasterAttachDisplayDefault( struct SSD13x6_Device* DeviceHandle, int Model, int Width, int Height, int CSPin, int RSTPin, int Speed ); #ifdef __cplusplus } diff --git a/components/squeezelite/a1s/ac101.c b/components/squeezelite/a1s/ac101.c index 5ba59081..17a02c47 100644 --- a/components/squeezelite/a1s/ac101.c +++ b/components/squeezelite/a1s/ac101.c @@ -82,7 +82,7 @@ static bool init(int i2c_port_num, int i2s_num, i2s_config_t *i2s_config) { .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_io_num = 32, .scl_pullup_en = GPIO_PULLUP_ENABLE, - .master.clk_speed = 100000, + .master.clk_speed = 250000, }; i2c_param_config(i2c_port, &i2c_config); diff --git a/components/squeezelite/display.c b/components/squeezelite/display.c index 0dedd208..7342f846 100644 --- a/components/squeezelite/display.c +++ b/components/squeezelite/display.c @@ -19,6 +19,7 @@ #include #include "squeezelite.h" +#include "slimproto.h" #include "display.h" #pragma pack(push, 1) @@ -84,6 +85,7 @@ static struct scroller_s { #define ANIM_SCREEN_2 0x08 static u8_t ANIC_resp = ANIM_NONE; +static u8_t SETD_width; #define SCROLL_STACK_SIZE (3*1024) #define LINELEN 40 @@ -150,6 +152,7 @@ bool sb_display_init(void) { // need to force height to 32 maximum display_width = display->width; display_height = min(display->height, 32); + SETD_width = display->width; // create scroll management task display_mutex = xSemaphoreCreateMutex(); @@ -195,6 +198,23 @@ static void send_server(void) { ANIC_resp = ANIM_NONE; } + if (SETD_width) { + struct SETD_header pkt_header; + + LOG_INFO("sending width %u", SETD_width); + + memset(&pkt_header, 0, sizeof(pkt_header)); + memcpy(&pkt_header.opcode, "SETD", 4); + + pkt_header.id = 0xfe; // id 0xfe is width S:P:Squeezebox2 + pkt_header.length = htonl(sizeof(pkt_header) + 2 - 8); + + send_packet((u8_t *)&pkt_header, sizeof(pkt_header)); + send_packet(&SETD_width, 2); + + SETD_width = 0; + } + if (slimp_loop_chain) (*slimp_loop_chain)(); } @@ -215,24 +235,25 @@ static bool handler(u8_t *data, int len){ bool res = true; // don't do anything if we dont own the display (no lock needed) - if (output.external && output.state >= OUTPUT_STOPPED) return true; - - if (!strncmp((char*) data, "vfdc", 4)) { - vfdc_handler(data, len); - } else if (!strncmp((char*) data, "grfe", 4)) { - grfe_handler(data, len); - } else if (!strncmp((char*) data, "grfb", 4)) { - grfb_handler(data, len); - } else if (!strncmp((char*) data, "grfs", 4)) { - grfs_handler(data, len); - } else if (!strncmp((char*) data, "grfg", 4)) { - grfg_handler(data, len); - } else { - res = false; - } + if (!output.external || output.state < OUTPUT_STOPPED) { + if (!strncmp((char*) data, "vfdc", 4)) { + vfdc_handler(data, len); + } else if (!strncmp((char*) data, "grfe", 4)) { + grfe_handler(data, len); + } else if (!strncmp((char*) data, "grfb", 4)) { + grfb_handler(data, len); + } else if (!strncmp((char*) data, "grfs", 4)) { + grfs_handler(data, len); + } else if (!strncmp((char*) data, "grfg", 4)) { + grfg_handler(data, len); + } else { + res = false; + } + } // chain protocol handlers (bitwise or is fine) if (*slimp_handler_chain) res |= (*slimp_handler_chain)(data, len); + return res; }