mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 20:47:08 +03:00
fix ST7789 + move VFLip/HFlip tp "Layout" option - release
This commit is contained in:
@@ -73,8 +73,11 @@ static void Update( struct GDS_Device* Device ) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetHFlip( struct GDS_Device* Device, bool On ) { Device->WriteCommand( Device, On ? 0xA1 : 0xA0 ); }
|
static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) {
|
||||||
static void SetVFlip( struct GDS_Device *Device, bool On ) { Device->WriteCommand( Device, On ? 0xC8 : 0xC0 ); }
|
Device->WriteCommand( Device, HFlip ? 0xA1 : 0xA0 );
|
||||||
|
Device->WriteCommand( Device, VFlip ? 0xC8 : 0xC0 );
|
||||||
|
}
|
||||||
|
|
||||||
static void DisplayOn( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAF ); }
|
static void DisplayOn( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAF ); }
|
||||||
static void DisplayOff( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAE ); }
|
static void DisplayOff( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAE ); }
|
||||||
|
|
||||||
@@ -117,8 +120,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
Device->WriteCommand( Device, 0x40 + 0x00 );
|
Device->WriteCommand( Device, 0x40 + 0x00 );
|
||||||
Device->SetContrast( Device, 0x7F );
|
Device->SetContrast( Device, 0x7F );
|
||||||
// set flip modes
|
// set flip modes
|
||||||
Device->SetVFlip( Device, false );
|
Device->SetLayout( Device, false, false, false );
|
||||||
Device->SetHFlip( Device, false );
|
|
||||||
// no Display Inversion
|
// no Display Inversion
|
||||||
Device->WriteCommand( Device, 0xA6 );
|
Device->WriteCommand( Device, 0xA6 );
|
||||||
// set Clocks
|
// set Clocks
|
||||||
@@ -135,7 +137,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
static const struct GDS_Device SH1106 = {
|
static const struct GDS_Device SH1106 = {
|
||||||
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
||||||
.SetVFlip = SetVFlip, .SetHFlip = SetHFlip,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update, .Init = Init,
|
.Update = Update, .Init = Init,
|
||||||
.Depth = 1,
|
.Depth = 1,
|
||||||
#if !defined SHADOW_BUFFER && defined USE_IRAM
|
#if !defined SHADOW_BUFFER && defined USE_IRAM
|
||||||
|
|||||||
@@ -85,8 +85,11 @@ static void Update( struct GDS_Device* Device ) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetHFlip( struct GDS_Device* Device, bool On ) { Device->WriteCommand( Device, On ? 0xA1 : 0xA0 ); }
|
static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) {
|
||||||
static void SetVFlip( struct GDS_Device *Device, bool On ) { Device->WriteCommand( Device, On ? 0xC8 : 0xC0 ); }
|
Device->WriteCommand( Device, HFlip ? 0xA1 : 0xA0 );
|
||||||
|
Device->WriteCommand( Device, VFlip ? 0xC8 : 0xC0 );
|
||||||
|
}
|
||||||
|
|
||||||
static void DisplayOn( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAF ); }
|
static void DisplayOn( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAF ); }
|
||||||
static void DisplayOff( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAE ); }
|
static void DisplayOff( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0xAE ); }
|
||||||
|
|
||||||
@@ -129,8 +132,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
Device->WriteCommand( Device, 0x40 + 0x00 );
|
Device->WriteCommand( Device, 0x40 + 0x00 );
|
||||||
Device->SetContrast( Device, 0x7F );
|
Device->SetContrast( Device, 0x7F );
|
||||||
// set flip modes
|
// set flip modes
|
||||||
Device->SetVFlip( Device, false );
|
Device->SetLayout( Device, false, false, false);
|
||||||
Device->SetHFlip( Device, false );
|
|
||||||
// no Display Inversion
|
// no Display Inversion
|
||||||
Device->WriteCommand( Device, 0xA6 );
|
Device->WriteCommand( Device, 0xA6 );
|
||||||
// set Clocks
|
// set Clocks
|
||||||
@@ -150,7 +152,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
static const struct GDS_Device SSD1306 = {
|
static const struct GDS_Device SSD1306 = {
|
||||||
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
||||||
.SetVFlip = SetVFlip, .SetHFlip = SetHFlip,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update, .Init = Init,
|
.Update = Update, .Init = Init,
|
||||||
.Mode = GDS_MONO, .Depth = 1,
|
.Mode = GDS_MONO, .Depth = 1,
|
||||||
#if !defined SHADOW_BUFFER && defined USE_IRAM
|
#if !defined SHADOW_BUFFER && defined USE_IRAM
|
||||||
|
|||||||
@@ -96,17 +96,10 @@ static void Update( struct GDS_Device* Device ) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetHFlip( struct GDS_Device* Device, bool On ) {
|
static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) {
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
||||||
Private->ReMap = On ? (Private->ReMap & ~(1 << 1)) : (Private->ReMap | (1 << 1));
|
Private->ReMap = HFlip ? (Private->ReMap & ~(1 << 1)) : (Private->ReMap | (1 << 1));
|
||||||
Device->WriteCommand( Device, 0xA0 );
|
Private->ReMap = VFlip ? (Private->ReMap | (1 << 4)) : (Private->ReMap & ~(1 << 4));
|
||||||
Device->WriteData( Device, &Private->ReMap, 1 );
|
|
||||||
WriteDataByte( Device, 0x11 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetVFlip( struct GDS_Device *Device, bool On ) {
|
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
|
||||||
Private->ReMap = On ? (Private->ReMap | (1 << 4)) : (Private->ReMap & ~(1 << 4));
|
|
||||||
Device->WriteCommand( Device, 0xA0 );
|
Device->WriteCommand( Device, 0xA0 );
|
||||||
Device->WriteData( Device, &Private->ReMap, 1 );
|
Device->WriteData( Device, &Private->ReMap, 1 );
|
||||||
WriteDataByte( Device, 0x11 );
|
WriteDataByte( Device, 0x11 );
|
||||||
@@ -152,8 +145,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
// set flip modes
|
// set flip modes
|
||||||
Private->ReMap = 0;
|
Private->ReMap = 0;
|
||||||
Device->SetVFlip( Device, false );
|
Device->SetLayout( Device, false, false, false);
|
||||||
Device->SetHFlip( Device, false );
|
|
||||||
|
|
||||||
// set Clocks
|
// set Clocks
|
||||||
Device->WriteCommand( Device, 0xB3 );
|
Device->WriteCommand( Device, 0xB3 );
|
||||||
@@ -187,7 +179,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
static const struct GDS_Device SSD1322 = {
|
static const struct GDS_Device SSD1322 = {
|
||||||
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
||||||
.SetVFlip = SetVFlip, .SetHFlip = SetHFlip,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update, .Init = Init,
|
.Update = Update, .Init = Init,
|
||||||
.Mode = GDS_GRAYSCALE, .Depth = 4,
|
.Mode = GDS_GRAYSCALE, .Depth = 4,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -222,18 +222,15 @@ static void DrawBitmapCBR(struct GDS_Device* Device, uint8_t *Data, int Width, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetHFlip( struct GDS_Device* Device, bool On ) {
|
static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) {
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
||||||
if (Private->Model == SSD1326) Private->ReMap = On ? (Private->ReMap | ((1 << 0) | (1 << 2))) : (Private->ReMap & ~((1 << 0) | (1 << 2)));
|
if (Private->Model == SSD1326) {
|
||||||
else Private->ReMap = On ? (Private->ReMap | ((1 << 0) | (1 << 1))) : (Private->ReMap & ~((1 << 0) | (1 << 1)));
|
Private->ReMap = HFlip ? (Private->ReMap | ((1 << 0) | (1 << 2))) : (Private->ReMap & ~((1 << 0) | (1 << 2)));
|
||||||
Device->WriteCommand( Device, 0xA0 );
|
Private->ReMap = HFlip ? (Private->ReMap | (1 << 1)) : (Private->ReMap & ~(1 << 1));
|
||||||
Device->WriteCommand( Device, Private->ReMap );
|
} else {
|
||||||
}
|
Private->ReMap = VFlip ? (Private->ReMap | ((1 << 0) | (1 << 1))) : (Private->ReMap & ~((1 << 0) | (1 << 1)));
|
||||||
|
Private->ReMap = VFlip ? (Private->ReMap | (1 << 4)) : (Private->ReMap & ~(1 << 4));
|
||||||
static void SetVFlip( struct GDS_Device *Device, bool On ) {
|
}
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
|
||||||
if (Private->Model == SSD1326) Private->ReMap = On ? (Private->ReMap | (1 << 1)) : (Private->ReMap & ~(1 << 1));
|
|
||||||
else Private->ReMap = On ? (Private->ReMap | (1 << 4)) : (Private->ReMap & ~(1 << 4));
|
|
||||||
Device->WriteCommand( Device, 0xA0 );
|
Device->WriteCommand( Device, 0xA0 );
|
||||||
Device->WriteCommand( Device, Private->ReMap );
|
Device->WriteCommand( Device, Private->ReMap );
|
||||||
}
|
}
|
||||||
@@ -291,8 +288,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
Device->WriteCommand( Device, 0x00 );
|
Device->WriteCommand( Device, 0x00 );
|
||||||
Device->SetContrast( Device, 0x7F );
|
Device->SetContrast( Device, 0x7F );
|
||||||
// set flip modes
|
// set flip modes
|
||||||
Device->SetVFlip( Device, false );
|
Device->SetLayout( Device, false, false, false );
|
||||||
Device->SetHFlip( Device, false );
|
|
||||||
// no Display Inversion
|
// no Display Inversion
|
||||||
Device->WriteCommand( Device, 0xA6 );
|
Device->WriteCommand( Device, 0xA6 );
|
||||||
// set Clocks
|
// set Clocks
|
||||||
@@ -316,7 +312,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
static const struct GDS_Device SSD132x = {
|
static const struct GDS_Device SSD132x = {
|
||||||
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
||||||
.SetVFlip = SetVFlip, .SetHFlip = SetHFlip,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update4, .Init = Init,
|
.Update = Update4, .Init = Init,
|
||||||
.Mode = GDS_GRAYSCALE, .Depth = 4,
|
.Mode = GDS_GRAYSCALE, .Depth = 4,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -164,30 +164,27 @@ static void Update24( struct GDS_Device* Device ) {
|
|||||||
#else
|
#else
|
||||||
// always update by full lines
|
// always update by full lines
|
||||||
SetColumnAddress( Device, 0, Device->Width - 1);
|
SetColumnAddress( Device, 0, Device->Width - 1);
|
||||||
|
|
||||||
|
for (int r = 0; r < Device->Height; r += min(Private->PageSize, Device->Height - r)) {
|
||||||
|
int Height = min(Private->PageSize, Device->Height - r);
|
||||||
|
|
||||||
|
SetRowAddress( Device, r, r + Height - 1 );
|
||||||
Device->WriteCommand(Device, ENABLE_WRITE);
|
Device->WriteCommand(Device, ENABLE_WRITE);
|
||||||
|
|
||||||
for (int r = 0; r < Device->Height; r += Private->PageSize) {
|
|
||||||
SetRowAddress( Device, r, r + Private->PageSize - 1 );
|
|
||||||
if (Private->iRAM) {
|
if (Private->iRAM) {
|
||||||
memcpy(Private->iRAM, Device->Framebuffer + r * Device->Width * 3, Private->PageSize * Device->Width * 3 );
|
memcpy(Private->iRAM, Device->Framebuffer + r * Device->Width * 3, Height * Device->Width * 3 );
|
||||||
Device->WriteData( Device, Private->iRAM, Private->PageSize * Device->Width * 3 );
|
Device->WriteData( Device, Private->iRAM, Height * Device->Width * 3 );
|
||||||
} else {
|
} else {
|
||||||
Device->WriteData( Device, Device->Framebuffer + r * Device->Width * 3, Private->PageSize * Device->Width * 3 );
|
Device->WriteData( Device, Device->Framebuffer + r * Device->Width * 3, Height * Device->Width * 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetHFlip( struct GDS_Device* Device, bool On ) {
|
static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) {
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
||||||
Private->ReMap = On ? (Private->ReMap & ~(1 << 1)) : (Private->ReMap | (1 << 1));
|
Private->ReMap = HFlip ? (Private->ReMap & ~(1 << 1)) : (Private->ReMap | (1 << 1));
|
||||||
Device->WriteCommand( Device, 0xA0 );
|
Private->ReMap = VFlip ? (Private->ReMap | (1 << 4)) : (Private->ReMap & ~(1 << 4));
|
||||||
WriteByte( Device, Private->ReMap );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetVFlip( struct GDS_Device *Device, bool On ) {
|
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
|
||||||
Private->ReMap = On ? (Private->ReMap | (1 << 4)) : (Private->ReMap & ~(1 << 4));
|
|
||||||
Device->WriteCommand( Device, 0xA0 );
|
Device->WriteCommand( Device, 0xA0 );
|
||||||
WriteByte( Device, Private->ReMap );
|
WriteByte( Device, Private->ReMap );
|
||||||
}
|
}
|
||||||
@@ -242,8 +239,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
// set flip modes & contrast
|
// set flip modes & contrast
|
||||||
Device->SetContrast( Device, 0x7F );
|
Device->SetContrast( Device, 0x7F );
|
||||||
Device->SetVFlip( Device, false );
|
Device->SetLayout( Device, false, false, false );
|
||||||
Device->SetHFlip( Device, false );
|
|
||||||
|
|
||||||
// set Adressing Mode Horizontal
|
// set Adressing Mode Horizontal
|
||||||
Private->ReMap |= (0 << 2);
|
Private->ReMap |= (0 << 2);
|
||||||
@@ -265,7 +261,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
static const struct GDS_Device SSD1351 = {
|
static const struct GDS_Device SSD1351 = {
|
||||||
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff, .SetContrast = SetContrast,
|
||||||
.SetVFlip = SetVFlip, .SetHFlip = SetHFlip,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update16, .Init = Init,
|
.Update = Update16, .Init = Init,
|
||||||
.Mode = GDS_RGB565, .Depth = 16,
|
.Mode = GDS_RGB565, .Depth = 16,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ enum { ST7735, ST7789 };
|
|||||||
|
|
||||||
struct PrivateSpace {
|
struct PrivateSpace {
|
||||||
uint8_t *iRAM, *Shadowbuffer;
|
uint8_t *iRAM, *Shadowbuffer;
|
||||||
|
struct {
|
||||||
|
uint16_t Height, Width;
|
||||||
|
} Offset;
|
||||||
uint8_t MADCtl, PageSize;
|
uint8_t MADCtl, PageSize;
|
||||||
uint8_t Model;
|
uint8_t Model;
|
||||||
};
|
};
|
||||||
@@ -75,8 +78,8 @@ static void Update16( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
FirstCol *= 2;
|
FirstCol *= 2;
|
||||||
LastCol = LastCol * 2 + 1;
|
LastCol = LastCol * 2 + 1;
|
||||||
SetRowAddress( Device, FirstRow, LastRow );
|
SetRowAddress( Device, FirstRow + Private->Offset.Height, LastRow + Private->Offset.Height);
|
||||||
SetColumnAddress( Device, FirstCol, LastCol );
|
SetColumnAddress( Device, FirstCol + Private->Offset.Width, LastCol + Private->Offset.Width );
|
||||||
Device->WriteCommand( Device, ENABLE_WRITE );
|
Device->WriteCommand( Device, ENABLE_WRITE );
|
||||||
|
|
||||||
int ChunkSize = (LastCol - FirstCol + 1) * 2;
|
int ChunkSize = (LastCol - FirstCol + 1) * 2;
|
||||||
@@ -100,12 +103,12 @@ static void Update16( struct GDS_Device* Device ) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// always update by full lines
|
// always update by full lines
|
||||||
SetColumnAddress( Device, 0, Device->Width - 1);
|
SetColumnAddress( Device, Private->Offset.Width, Device->Width - 1);
|
||||||
|
|
||||||
for (int r = 0; r < Device->Height; r += min(Private->PageSize, Device->Height - r)) {
|
for (int r = 0; r < Device->Height; r += min(Private->PageSize, Device->Height - r)) {
|
||||||
int Height = min(Private->PageSize, Device->Height - r);
|
int Height = min(Private->PageSize, Device->Height - r);
|
||||||
|
|
||||||
SetRowAddress( Device, r, r + Height - 1 );
|
SetRowAddress( Device, Private->Offset.Height + r, Private->Offset.Height + r + Height - 1 );
|
||||||
Device->WriteCommand(Device, ENABLE_WRITE);
|
Device->WriteCommand(Device, ENABLE_WRITE);
|
||||||
|
|
||||||
if (Private->iRAM) {
|
if (Private->iRAM) {
|
||||||
@@ -142,8 +145,8 @@ static void Update24( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
FirstCol = (FirstCol * 2) / 3;
|
FirstCol = (FirstCol * 2) / 3;
|
||||||
LastCol = (LastCol * 2 + 1) / 3;
|
LastCol = (LastCol * 2 + 1) / 3;
|
||||||
SetRowAddress( Device, FirstRow, LastRow );
|
SetRowAddress( Device, FirstRow + Private->Offset.Height, LastRow + Private->Offset.Height);
|
||||||
SetColumnAddress( Device, FirstCol, LastCol );
|
SetColumnAddress( Device, FirstCol + Private->Offset.Width, LastCol + Private->Offset.Width );
|
||||||
Device->WriteCommand( Device, ENABLE_WRITE );
|
Device->WriteCommand( Device, ENABLE_WRITE );
|
||||||
|
|
||||||
int ChunkSize = (LastCol - FirstCol + 1) * 3;
|
int ChunkSize = (LastCol - FirstCol + 1) * 3;
|
||||||
@@ -167,33 +170,43 @@ static void Update24( struct GDS_Device* Device ) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// always update by full lines
|
// always update by full lines
|
||||||
SetColumnAddress( Device, 0, Device->Width - 1);
|
SetColumnAddress( Device, Private->Offset.Width, Device->Width - 1);
|
||||||
|
|
||||||
|
for (int r = 0; r < Device->Height; r += min(Private->PageSize, Device->Height - r)) {
|
||||||
|
int Height = min(Private->PageSize, Device->Height - r);
|
||||||
|
|
||||||
|
SetRowAddress( Device, Private->Offset.Height + r, Private->Offset.Height + r + Height - 1 );
|
||||||
Device->WriteCommand(Device, ENABLE_WRITE);
|
Device->WriteCommand(Device, ENABLE_WRITE);
|
||||||
|
|
||||||
for (int r = 0; r < Device->Height; r += Private->PageSize) {
|
|
||||||
SetRowAddress( Device, r, r + Private->PageSize - 1 );
|
|
||||||
if (Private->iRAM) {
|
if (Private->iRAM) {
|
||||||
memcpy(Private->iRAM, Device->Framebuffer + r * Device->Width * 3, Private->PageSize * Device->Width * 3 );
|
memcpy(Private->iRAM, Device->Framebuffer + r * Device->Width * 3, Height * Device->Width * 3 );
|
||||||
Device->WriteData( Device, Private->iRAM, Private->PageSize * Device->Width * 3 );
|
Device->WriteData( Device, Private->iRAM, Height * Device->Width * 3 );
|
||||||
} else {
|
} else {
|
||||||
Device->WriteData( Device, Device->Framebuffer + r * Device->Width * 3, Private->PageSize * Device->Width * 3 );
|
Device->WriteData( Device, Device->Framebuffer + r * Device->Width * 3, Height * Device->Width * 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetHFlip( struct GDS_Device* Device, bool On ) {
|
static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) {
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
||||||
Private->MADCtl = On ? (Private->MADCtl & ~(1 << 7)) : (Private->MADCtl | (1 << 7));
|
|
||||||
Device->WriteCommand( Device, 0x36 );
|
|
||||||
WriteByte( Device, Private->MADCtl );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetVFlip( struct GDS_Device *Device, bool On ) {
|
Private->MADCtl = HFlip ? (Private->MADCtl | (1 << 7)) : (Private->MADCtl & ~(1 << 7));
|
||||||
struct PrivateSpace *Private = (struct PrivateSpace*) Device->Private;
|
Private->MADCtl = VFlip ? (Private->MADCtl | (1 << 6)) : (Private->MADCtl & ~(1 << 6));
|
||||||
Private->MADCtl = On ? (Private->MADCtl | (1 << 6)) : (Private->MADCtl & ~(1 << 6));
|
Private->MADCtl = Rotate ? (Private->MADCtl | (1 << 5)) : (Private->MADCtl & ~(1 << 5));
|
||||||
|
|
||||||
Device->WriteCommand( Device, 0x36 );
|
Device->WriteCommand( Device, 0x36 );
|
||||||
WriteByte( Device, Private->MADCtl );
|
WriteByte( Device, Private->MADCtl );
|
||||||
|
|
||||||
|
if (Private->Model == ST7789) {
|
||||||
|
if (Rotate) Private->Offset.Width = HFlip ? 320 - Device->Width : 0;
|
||||||
|
else Private->Offset.Height = HFlip ? 320 - Device->Height : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SHADOW_BUFFER
|
||||||
|
// force a full refresh (almost ...)
|
||||||
|
memset(Private->Shadowbuffer, 0xAA, Device->FramebufferSize);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DisplayOn( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0x29 ); }
|
static void DisplayOn( struct GDS_Device* Device ) { Device->WriteCommand( Device, 0x29 ); }
|
||||||
@@ -202,6 +215,10 @@ static void DisplayOff( struct GDS_Device* Device ) { Device->WriteCommand( Devi
|
|||||||
static void SetContrast( struct GDS_Device* Device, uint8_t Contrast ) {
|
static void SetContrast( struct GDS_Device* Device, uint8_t Contrast ) {
|
||||||
Device->WriteCommand( Device, 0x51 );
|
Device->WriteCommand( Device, 0x51 );
|
||||||
WriteByte( Device, Contrast );
|
WriteByte( Device, Contrast );
|
||||||
|
|
||||||
|
Device->SetContrast = NULL;
|
||||||
|
GDS_SetContrast( Device, Contrast );
|
||||||
|
Device->SetContrast = SetContrast;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Init( struct GDS_Device* Device ) {
|
static bool Init( struct GDS_Device* Device ) {
|
||||||
@@ -224,21 +241,21 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
Device->WriteCommand( Device, 0x11 );
|
Device->WriteCommand( Device, 0x11 );
|
||||||
|
|
||||||
// need BGR & Address Mode
|
// need BGR & Address Mode
|
||||||
Private->MADCtl = (1 << 3) | ((Device->Width > Device->Height ? 1 : 0) << 5);
|
Private->MADCtl = 1 << 3;
|
||||||
Device->WriteCommand( Device, 0x36 );
|
Device->WriteCommand( Device, 0x36 );
|
||||||
WriteByte( Device, Private->MADCtl );
|
WriteByte( Device, Private->MADCtl );
|
||||||
|
|
||||||
// set flip modes & contrast
|
// set flip modes & contrast
|
||||||
GDS_SetContrast( Device, 0x7F );
|
GDS_SetContrast( Device, 0x7f );
|
||||||
Device->SetVFlip( Device, false );
|
Device->SetLayout( Device, false, false, false );
|
||||||
Device->SetHFlip( Device, false );
|
|
||||||
|
|
||||||
// set screen depth (16/18)
|
// set screen depth (16/18)
|
||||||
Device->WriteCommand( Device, 0x3A );
|
Device->WriteCommand( Device, 0x3A );
|
||||||
WriteByte( Device, Device->Depth == 24 ? 0x06 : 0x05 );
|
if (Private->Model == ST7789) WriteByte( Device, Device->Depth == 24 ? 0x066 : 0x55 );
|
||||||
|
else WriteByte( Device, Device->Depth == 24 ? 0x06 : 0x05 );
|
||||||
|
|
||||||
// no Display Inversion
|
// no Display Inversion
|
||||||
Device->WriteCommand( Device, 0x20 );
|
Device->WriteCommand( Device, Private->Model == ST7735 ? 0x20 : 0x21 );
|
||||||
|
|
||||||
// gone with the wind
|
// gone with the wind
|
||||||
Device->DisplayOn( Device );
|
Device->DisplayOn( Device );
|
||||||
@@ -249,7 +266,7 @@ static bool Init( struct GDS_Device* Device ) {
|
|||||||
|
|
||||||
static const struct GDS_Device ST77xx = {
|
static const struct GDS_Device ST77xx = {
|
||||||
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff,
|
.DisplayOn = DisplayOn, .DisplayOff = DisplayOff,
|
||||||
.SetVFlip = SetVFlip, .SetHFlip = SetHFlip,
|
.SetLayout = SetLayout,
|
||||||
.Update = Update16, .Init = Init,
|
.Update = Update16, .Init = Init,
|
||||||
.Mode = GDS_RGB565, .Depth = 16,
|
.Mode = GDS_RGB565, .Depth = 16,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -236,8 +236,7 @@ void GDS_SetContrast( struct GDS_Device* Device, uint8_t Contrast ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDS_SetHFlip( struct GDS_Device* Device, bool On ) { if (Device->SetHFlip) Device->SetHFlip( Device, On ); }
|
void GDS_SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate ) { if (Device->SetLayout) Device->SetLayout( Device, HFlip, VFlip, Rotate ); }
|
||||||
void GDS_SetVFlip( struct GDS_Device* Device, bool On ) { if (Device->SetVFlip) Device->SetVFlip( Device, On ); }
|
|
||||||
void GDS_SetDirty( struct GDS_Device* Device ) { Device->Dirty = true; }
|
void GDS_SetDirty( struct GDS_Device* Device ) { Device->Dirty = true; }
|
||||||
int GDS_GetWidth( struct GDS_Device* Device ) { return Device->Width; }
|
int GDS_GetWidth( struct GDS_Device* Device ) { return Device->Width; }
|
||||||
int GDS_GetHeight( struct GDS_Device* Device ) { return Device->Height; }
|
int GDS_GetHeight( struct GDS_Device* Device ) { return Device->Height; }
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ void GDS_SetContrast( struct GDS_Device* Device, uint8_t Contrast );
|
|||||||
void GDS_DisplayOn( struct GDS_Device* Device );
|
void GDS_DisplayOn( struct GDS_Device* Device );
|
||||||
void GDS_DisplayOff( struct GDS_Device* Device );
|
void GDS_DisplayOff( struct GDS_Device* Device );
|
||||||
void GDS_Update( struct GDS_Device* Device );
|
void GDS_Update( struct GDS_Device* Device );
|
||||||
void GDS_SetHFlip( struct GDS_Device* Device, bool On );
|
void GDS_SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate );
|
||||||
void GDS_SetVFlip( struct GDS_Device* Device, bool On );
|
|
||||||
void GDS_SetDirty( struct GDS_Device* Device );
|
void GDS_SetDirty( struct GDS_Device* Device );
|
||||||
int GDS_GetWidth( struct GDS_Device* Device );
|
int GDS_GetWidth( struct GDS_Device* Device );
|
||||||
int GDS_GetHeight( struct GDS_Device* Device );
|
int GDS_GetHeight( struct GDS_Device* Device );
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ struct GDS_Device {
|
|||||||
|
|
||||||
uint8_t Alloc;
|
uint8_t Alloc;
|
||||||
uint8_t* Framebuffer;
|
uint8_t* Framebuffer;
|
||||||
uint16_t FramebufferSize;
|
uint32_t FramebufferSize;
|
||||||
bool Dirty;
|
bool Dirty;
|
||||||
|
|
||||||
// default fonts when using direct draw
|
// default fonts when using direct draw
|
||||||
@@ -117,8 +117,7 @@ struct GDS_Device {
|
|||||||
void (*SetContrast)( struct GDS_Device* Device, uint8_t Contrast );
|
void (*SetContrast)( struct GDS_Device* Device, uint8_t Contrast );
|
||||||
void (*DisplayOn)( struct GDS_Device* Device );
|
void (*DisplayOn)( struct GDS_Device* Device );
|
||||||
void (*DisplayOff)( struct GDS_Device* Device );
|
void (*DisplayOff)( struct GDS_Device* Device );
|
||||||
void (*SetHFlip)( struct GDS_Device* Device, bool On );
|
void (*SetLayout)( struct GDS_Device* Device, bool HFlip, bool VFlip, bool Rotate );
|
||||||
void (*SetVFlip)( struct GDS_Device* Device, bool On );
|
|
||||||
// must provide for depth other than 1 (vertical) and 4 (may provide for optimization)
|
// must provide for depth other than 1 (vertical) and 4 (may provide for optimization)
|
||||||
void (*DrawPixelFast)( struct GDS_Device* Device, int X, int Y, int Color );
|
void (*DrawPixelFast)( struct GDS_Device* Device, int X, int Y, int Color );
|
||||||
void (*DrawBitmapCBR)(struct GDS_Device* Device, uint8_t *Data, int Width, int Height, int Color );
|
void (*DrawBitmapCBR)(struct GDS_Device* Device, uint8_t *Data, int Width, int Height, int Color );
|
||||||
@@ -130,8 +129,8 @@ struct GDS_Device {
|
|||||||
WriteCommandProc WriteCommand;
|
WriteCommandProc WriteCommand;
|
||||||
WriteDataProc WriteData;
|
WriteDataProc WriteData;
|
||||||
|
|
||||||
// 16 bytes for whatever the driver wants (should be aligned as it's 32 bits)
|
// 32 bytes for whatever the driver wants (should be aligned as it's 32 bits)
|
||||||
uint32_t Private[4];
|
uint32_t Private[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
bool GDS_Reset( struct GDS_Device* Device );
|
bool GDS_Reset( struct GDS_Device* Device );
|
||||||
|
|||||||
@@ -119,8 +119,7 @@ void display_init(char *welcome) {
|
|||||||
static DRAM_ATTR StaticTask_t xTaskBuffer __attribute__ ((aligned (4)));
|
static DRAM_ATTR StaticTask_t xTaskBuffer __attribute__ ((aligned (4)));
|
||||||
static EXT_RAM_ATTR StackType_t xStack[DISPLAYER_STACK_SIZE] __attribute__ ((aligned (4)));
|
static EXT_RAM_ATTR StackType_t xStack[DISPLAYER_STACK_SIZE] __attribute__ ((aligned (4)));
|
||||||
|
|
||||||
GDS_SetHFlip(display, strcasestr(config, "HFlip") ? true : false);
|
GDS_SetLayout( display, strcasestr(config, "HFlip"), strcasestr(config, "VFlip"), strcasestr(config, "rotate"));
|
||||||
GDS_SetVFlip(display, strcasestr(config, "VFlip") ? true : false);
|
|
||||||
GDS_SetFont(display, &Font_droid_sans_fallback_15x17 );
|
GDS_SetFont(display, &Font_droid_sans_fallback_15x17 );
|
||||||
GDS_TextPos(display, GDS_FONT_MEDIUM, GDS_TEXT_CENTERED, GDS_TEXT_CLEAR | GDS_TEXT_UPDATE, welcome);
|
GDS_TextPos(display, GDS_FONT_MEDIUM, GDS_TEXT_CENTERED, GDS_TEXT_CLEAR | GDS_TEXT_UPDATE, welcome);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ extern struct buffer *outputbuf;
|
|||||||
// this is the only system-wide loglevel variable
|
// this is the only system-wide loglevel variable
|
||||||
extern log_level loglevel;
|
extern log_level loglevel;
|
||||||
|
|
||||||
|
|
||||||
static bool enable_bt_sink;
|
static bool enable_bt_sink;
|
||||||
static bool enable_airplay;
|
static bool enable_airplay;
|
||||||
|
|
||||||
|
|||||||
@@ -69,10 +69,11 @@ static void * squeezelite_thread(){
|
|||||||
ESP_LOGV(TAG ,"Freeing argv pointer");
|
ESP_LOGV(TAG ,"Freeing argv pointer");
|
||||||
free(thread_parms.argv);
|
free(thread_parms.argv);
|
||||||
isRunning=false;
|
isRunning=false;
|
||||||
ESP_LOGE(TAG, "Exited from squeezelite thread, something's wrong ... rebooting");
|
ESP_LOGE(TAG, "Exited from squeezelite thread, something's wrong ... rebooting (wait 30s for user to take action)");
|
||||||
if(!wait_for_commit()){
|
if(!wait_for_commit()){
|
||||||
ESP_LOGW(TAG,"Unable to commit configuration. ");
|
ESP_LOGW(TAG,"Unable to commit configuration. ");
|
||||||
}
|
}
|
||||||
|
vTaskDelay( pdMS_TO_TICKS( 30*1000 ) );
|
||||||
esp_restart();
|
esp_restart();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user