Mercurial > public > ostc4
diff Discovery/Src/gfx_engine.c @ 981:c6c781a2e85b default tip
Merge into default
author | heinrichsweikamp |
---|---|
date | Tue, 11 Feb 2025 18:12:00 +0100 (4 days ago) |
parents | 8d3f3a635397 |
children |
line wrap: on
line diff
--- a/Discovery/Src/gfx_engine.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/gfx_engine.c Tue Feb 11 18:12:00 2025 +0100 @@ -36,7 +36,8 @@ /* Private types -------------------------------------------------------------*/ -#define RING_BUF_SIZE (5u) +#define RING_BUF_SIZE (5u) +#define MAX_COLOR_STRING_LENGTH (100u) typedef struct { @@ -251,7 +252,6 @@ backgroundHwStatus = LOGOSTOP; } - void GFX_build_hw_background_frame(void) { GFX_DrawCfgScreen tLogoTemp; @@ -319,7 +319,6 @@ */ } - void GFX_init(uint32_t * pDestinationOut) { frame[0].StartAddress = FBGlobalStart; @@ -361,6 +360,57 @@ DMA2D_at_work = 255; } +void GFX_init1_no_DMA(uint32_t * pDestinationOut, uint8_t blockFrames) +{ + frame[0].StartAddress = FBGlobalStart; + GFX_clear_frame_immediately(frame[0].StartAddress); + frame[0].status = CLEAR; + frame[0].caller = 0; + + for(int i=1;i<MAXFRAMES;i++) + { + frame[i].StartAddress = frame[i-1].StartAddress + FBOffsetEachIndex; + GFX_clear_frame_immediately(frame[i].StartAddress); + frame[i].status = CLEAR; + frame[i].caller = 0; + } + + for(int i=0;i<blockFrames;i++) + { + frame[i].status = BLOCKED; + frame[i].caller = 1; + } + + pInvisibleFrame = getFrame(2); + *pDestinationOut = pInvisibleFrame; + + GFX_build_logo_frame(); + GFX_build_hw_background_frame(); +} + + +void GFX_init2_DMA(void) +{ + /* Register to memory mode with ARGB8888 as color Mode */ + Dma2dHandle.Init.Mode = DMA2D_R2M; + Dma2dHandle.Init.ColorMode = DMA2D_ARGB4444;//to fake AL88, before: DMA2D_ARGB8888; + Dma2dHandle.Init.OutputOffset = 0; + + /* DMA2D Callbacks Configuration */ + Dma2dHandle.XferCpltCallback = GFX_Dma2d_TransferComplete; + Dma2dHandle.XferErrorCallback = GFX_Dma2d_TransferError; + + Dma2dHandle.Instance = DMA2D; + + /* DMA2D Initialisation */ + if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK) + GFX_Error_Handler(); + + if(HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1) != HAL_OK) + GFX_Error_Handler(); + + DMA2D_at_work = 255; +} void GFX_SetFrameTop(uint32_t pDestination) @@ -533,6 +583,7 @@ } else if (backgroundHwStatus != LOGOOFF) { + switch(backgroundHwStatus) { case LOGOSTART: @@ -567,6 +618,7 @@ FrameHandler.NextBottomRead = nextBottomBackup; break; } + return; } else @@ -976,7 +1028,6 @@ } } - static void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image) { uint16_t* pDestination; @@ -1766,7 +1817,8 @@ /** ****************************************************************************** - * @brief GFX writeGfx_write_label_varstring. / Write string with all parameters and font color options heinrichs weikamp gmbh + * @brief GFX writeGfx_write_label_varstring. / Write string with all parameters and font color options + heinrichs weikamp gmbh * @version V0.0.1 * @date 22-April-2014 ****************************************************************************** @@ -2006,7 +2058,10 @@ minimal = 0; if(Font == &FontT144) + { settings.TinyFont = (uint32_t)&FontT84; + settings.Ydelta = 12; + } else if(Font == &FontT105) settings.TinyFont = (uint32_t)&FontT54; @@ -2102,6 +2157,7 @@ settings.actualFont = (tFont *)settings.font; } else +#ifndef BOOTLOADER_STANDALONE if((*pText == '\005') && !minimal) { newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48); @@ -2114,6 +2170,7 @@ settings.Xdelta = newXdelta; } else +#endif if((*pText >= '\020') && (*pText <= '\032') && !minimal) settings.color = *pText - '\020'; else @@ -2190,15 +2247,13 @@ uint32_t found; uint32_t pText; uint16_t decodeUTF8; - uint8_t gfx_selected_language; #ifndef BOOTLOADER_STANDALONE + uint8_t gfx_selected_language = 0; SSettings *pSettings; pSettings = settingsGetPointer(); gfx_selected_language = pSettings->selected_language; - if(gfx_selected_language >= LANGUAGE_END) + if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; #endif - gfx_selected_language = 0; - // ----------------------------- if(textId != (uint8_t)TXT_2BYTE) @@ -2207,23 +2262,27 @@ j = 0; for(i=(uint8_t)TXT_Language;i<(uint8_t)TXT_END;i++) { +#ifndef BOOTLOADER_STANDALONE if(text_array[j].code == textId) { found = 1; break; } +#endif j++; } if(!found) return cfg->Xdelta; // ----------------------------- +#ifndef BOOTLOADER_STANDALONE pText = (uint32_t)text_array[j].text[gfx_selected_language]; if(!pText) pText = (uint32_t)text_array[j].text[0]; else if(*(char*)pText == 0) pText = (uint32_t)text_array[j].text[0]; +#endif } // ----------------------------- else @@ -2234,14 +2293,17 @@ found = 0; for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++) { +#ifndef BOOTLOADER_STANDALONE if((uint8_t)text_array2[j].code == (uint8_t)nextCharFor2Byte) { found = 1; break; } +#endif } if(!found) return cfg->Xdelta; +#ifndef BOOTLOADER_STANDALONE // ----------------------------- pText = (uint32_t)text_array2[j].text[gfx_selected_language]; if(!pText) @@ -2249,6 +2311,7 @@ else if(*(char*)pText == 0) pText = (uint32_t)text_array2[j].text[0]; +#endif } // ----------------------------- @@ -2687,7 +2750,10 @@ static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font) { + +#ifndef BOOTLOADER_STANDALONE Font = GFX_Check_Extra_Font(character, Font); +#endif if(cfg->doubleSize) { return GFX_write_char_doubleSize(hgfx, cfg, character, Font); @@ -3008,6 +3074,7 @@ return cfg->Xdelta + width; } +#ifndef BOOTLOADER_STANDALONE /** ****************************************************************************** @@ -3107,7 +3174,7 @@ return counter; } - +#endif /** ****************************************************************************** * @brief GFX write Modify Ydelta for align. / calc Ydelta for start @@ -3128,23 +3195,22 @@ uint32_t result; uint32_t Xsum; uint32_t j; - uint8_t gfx_selected_language; uint32_t pText; uint16_t decodeUTF8; uint8_t tinyState = 0; /* used to identify the usage of tiny font */ tFont* ptargetFont; #ifndef BOOTLOADER_STANDALONE + uint8_t gfx_selected_language = 0; SSettings *pSettings; pSettings = settingsGetPointer(); gfx_selected_language = pSettings->selected_language; - if(gfx_selected_language >= LANGUAGE_END) + if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; #endif - gfx_selected_language = 0; // ----------------------------- - +#ifndef BOOTLOADER_STANDALONE GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); - +#endif pText = (uint32_t)&cText[0]; Xsum = 0; j = 0; @@ -3221,28 +3287,29 @@ static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput) { - char cText[101]; uint32_t result; uint32_t Xsum; uint32_t j; tFont *font; - uint8_t gfx_selected_language; + char cText[101]; uint32_t pText; uint16_t decodeUTF8; uint8_t tinyState = 0; /* used to identify the usage of tiny font */ #ifndef BOOTLOADER_STANDALONE + uint8_t gfx_selected_language = 0; SSettings *pSettings; pSettings = settingsGetPointer(); gfx_selected_language = pSettings->selected_language; - if(gfx_selected_language >= LANGUAGE_END) + if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; +#else + cText[0] = 0; #endif - gfx_selected_language = 0; // ----------------------------- - +#ifndef BOOTLOADER_STANDALONE GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); +#endif pText = (uint32_t)&cText[0]; - // ----------------------------- font = (tFont *)cfg->font; @@ -3325,48 +3392,48 @@ void GFX_LTDC_Init(void) { - if (hardwareDisplay == 1) - { + if (isNewDisplay()) + { GFX_LTDC_Init_display1(); - } - else - { + } + else + { GFX_LTDC_Init_display0(); - } + } } void GFX_LTDC_Init_display0(void) { /* Timing configuration */ -#define ActiveH 800 -#define ActiveW 480 - -#define Hsync 10 -#define HFP 8 -#define HBP 10 - -#define Vsync 2 -#define VFP 2 -#define VBP 2 +#define ActiveH_d0 800 +#define ActiveW_d0 480 + +#define Hsync_d0 10 +#define HFP_d0 8 +#define HBP_d0 10 + +#define Vsync_d0 2 +#define VFP_d0 2 +#define VBP_d0 2 /* Horizontal synchronization width = Hsync - 1 */ - LtdcHandle.Init.HorizontalSync = Hsync - 1; + LtdcHandle.Init.HorizontalSync = Hsync_d0 - 1; /* Vertical synchronization height = Vsync - 1 */ - LtdcHandle.Init.VerticalSync = Vsync -1; + LtdcHandle.Init.VerticalSync = Vsync_d0 - 1; /* Accumulated horizontal back porch = Hsync + HBP - 1 */ - LtdcHandle.Init.AccumulatedHBP = Hsync + HBP - 1; + LtdcHandle.Init.AccumulatedHBP = Hsync_d0 + HBP_d0 - 1; /* Accumulated vertical back porch = Vsync + VBP - 1 */ - LtdcHandle.Init.AccumulatedVBP = Vsync + VBP - 1; + LtdcHandle.Init.AccumulatedVBP = Vsync_d0 + VBP_d0 - 1; /* Accumulated active width = Hsync + HBP + Active Width - 1 */ - LtdcHandle.Init.AccumulatedActiveW = Hsync + HBP + ActiveW- 1; + LtdcHandle.Init.AccumulatedActiveW = Hsync_d0 + HBP_d0 + ActiveW_d0 - 1; /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ - LtdcHandle.Init.AccumulatedActiveH = Vsync + VBP + ActiveH - 1; + LtdcHandle.Init.AccumulatedActiveH = Vsync_d0 + VBP_d0 + ActiveH_d0 - 1; /* Total width = Hsync + HBP + Active Width + HFP - 1 */ - LtdcHandle.Init.TotalWidth = Hsync + HBP + ActiveW + HFP - 1; + LtdcHandle.Init.TotalWidth = Hsync_d0 + HBP_d0 + ActiveW_d0 + HFP_d0 - 1; /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ - LtdcHandle.Init.TotalHeigh = Vsync + VBP + ActiveH + VFP - 1; + LtdcHandle.Init.TotalHeigh = Vsync_d0 + VBP_d0 + ActiveH_d0 + VFP_d0 - 1; /* Configure R,G,B component values for LCD background color */ LtdcHandle.Init.Backcolor.Red= 0; @@ -4000,6 +4067,7 @@ */ } +#ifndef BOOTLOADER_STANDALONE tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font) { uint32_t i; @@ -4029,11 +4097,13 @@ return Font; } - +#endif uint32_t GFX_Character_Width(uint8_t character, tFont *Font) { uint32_t i; +#ifndef BOOTLOADER_STANDALONE uint32_t found; +#endif for(i=0;i<Font->length;i++) { @@ -4043,6 +4113,7 @@ } } +#ifndef BOOTLOADER_STANDALONE found = 0; if (Font == &FontT54) { @@ -4070,6 +4141,30 @@ } } } - +#endif return 0; } + +void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor) +{ + char *p = text; + uint8_t index = 0; + + while ((*p) && (index < MAX_COLOR_STRING_LENGTH)) + { + if (*p == '\020') + { + if(!GFX_is_colorschemeDiveStandard()) + { + *p = '\027'; + } + else if(alternativeColor != 0) + { + *p += alternativeColor; + } + } + p++; + index++; + } +} +