mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 04:27:12 +03:00
SOme displays needs to adjust CS_post for speed
This commit is contained in:
@@ -86,6 +86,10 @@ static void SetContrast( struct GDS_Device* Device, uint8_t Contrast ) {
|
|||||||
Device->WriteCommand( Device, Contrast );
|
Device->WriteCommand( Device, Contrast );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SPIParams(int Speed, uint8_t *mode, uint8_t *CS_pre, uint8_t *CS_post) {
|
||||||
|
*CS_post = Speed / (8*1000*1000);
|
||||||
|
}
|
||||||
|
|
||||||
static bool Init( struct GDS_Device* Device ) {
|
static bool Init( struct GDS_Device* Device ) {
|
||||||
#ifdef SHADOW_BUFFER
|
#ifdef SHADOW_BUFFER
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
||||||
@@ -140,7 +144,7 @@ static const struct GDS_Device SH1106 = {
|
|||||||
.SetLayout = SetLayout,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update, .Init = Init,
|
.Update = Update, .Init = Init,
|
||||||
.Depth = 1,
|
.Depth = 1,
|
||||||
.CS_post = 2,
|
.SPIParams = SPIParams,
|
||||||
#if !defined SHADOW_BUFFER && defined USE_IRAM
|
#if !defined SHADOW_BUFFER && defined USE_IRAM
|
||||||
.Alloc = GDS_ALLOC_IRAM_SPI;
|
.Alloc = GDS_ALLOC_IRAM_SPI;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ struct GDS_Device {
|
|||||||
struct {
|
struct {
|
||||||
spi_device_handle_t SPIHandle;
|
spi_device_handle_t SPIHandle;
|
||||||
int8_t CSPin;
|
int8_t CSPin;
|
||||||
int8_t CS_pre, CS_post, SPI_mode;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -125,6 +124,8 @@ struct GDS_Device {
|
|||||||
// may provide for optimization
|
// may provide for optimization
|
||||||
void (*DrawRGB)( struct GDS_Device* Device, uint8_t *Image,int x, int y, int Width, int Height, int RGB_Mode );
|
void (*DrawRGB)( struct GDS_Device* Device, uint8_t *Image,int x, int y, int Width, int Height, int RGB_Mode );
|
||||||
void (*ClearWindow)( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color );
|
void (*ClearWindow)( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color );
|
||||||
|
// may provide for tweaking
|
||||||
|
void (*SPIParams)(int Speed, uint8_t *mode, uint8_t *CS_pre, uint8_t *CS_post);
|
||||||
|
|
||||||
// interface-specific methods
|
// interface-specific methods
|
||||||
WriteCommandProc WriteCommand;
|
WriteCommandProc WriteCommand;
|
||||||
|
|||||||
@@ -51,9 +51,8 @@ bool GDS_SPIAttachDevice( struct GDS_Device* Device, int Width, int Height, int
|
|||||||
SPIDeviceConfig.spics_io_num = CSPin;
|
SPIDeviceConfig.spics_io_num = CSPin;
|
||||||
SPIDeviceConfig.queue_size = 1;
|
SPIDeviceConfig.queue_size = 1;
|
||||||
SPIDeviceConfig.flags = SPI_DEVICE_NO_DUMMY;
|
SPIDeviceConfig.flags = SPI_DEVICE_NO_DUMMY;
|
||||||
SPIDeviceConfig.cs_ena_pretrans = Device->CS_pre;
|
if (Device->SPIParams) Device->SPIParams(SPIDeviceConfig.clock_speed_hz, &SPIDeviceConfig.mode,
|
||||||
SPIDeviceConfig.cs_ena_posttrans = Device->CS_post;
|
&SPIDeviceConfig.cs_ena_pretrans, &SPIDeviceConfig.cs_ena_posttrans);
|
||||||
SPIDeviceConfig.mode = Device->SPI_mode;
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK_NONFATAL( spi_bus_add_device( SPIHost, &SPIDeviceConfig, &SPIDevice ), return false );
|
ESP_ERROR_CHECK_NONFATAL( spi_bus_add_device( SPIHost, &SPIDeviceConfig, &SPIDevice ), return false );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user