From 2fbea79a5bb8a373ac642d23146556418961bec6 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Thu, 2 Dec 2021 11:04:52 -0800 Subject: [PATCH] Add offset for ST7735 --- components/display/ST77xx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/display/ST77xx.c b/components/display/ST77xx.c index 78d59d87..eef6c6fc 100644 --- a/components/display/ST77xx.c +++ b/components/display/ST77xx.c @@ -199,8 +199,8 @@ static void SetLayout( struct GDS_Device* Device, bool HFlip, bool VFlip, bool R 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; + if (Rotate) Private->Offset.Width += HFlip ? 320 - Device->Width : 0; + else Private->Offset.Height += HFlip ? 320 - Device->Height : 0; } #ifdef SHADOW_BUFFER @@ -283,8 +283,14 @@ struct GDS_Device* ST77xx_Detect(char *Driver, struct GDS_Device* Device) { *Device = ST77xx; sscanf(Driver, "%*[^:]:%u", &Depth); + struct PrivateSpace* Private = (struct PrivateSpace*) Device->Private; Private->Model = Model; + + if (Model == ST7735) { + sscanf(Driver, "%*[^:]%*[^x]%*[^=]=%hu", &Private->Offset.Height); + sscanf(Driver, "%*[^:]%*[^y]%*[^=]=%hu", &Private->Offset.Width); + } if (Depth == 18) { Device->Mode = GDS_RGB666;