Mercurial > public > ostc4
annotate Discovery/Src/gfx_engine.c @ 1053:36fa1c44e597 Icon_Integration
Added upload command for icon:
It is now possible to upload a custom icon which is shown during startup and while writing settings (instead of the HW string). The icons are limited to 256 colors and 800x480 pixels. The icon may not be larger than 200kByte because of storage avability. For upload the same CRC functions as for the common firmware updates are in use,
| author | Ideenmodellierer |
|---|---|
| date | Wed, 31 Dec 2025 17:49:05 +0100 |
| parents | 65d35e66efb9 |
| children |
| rev | line source |
|---|---|
| 38 | 1 /** |
| 2 ****************************************************************************** | |
| 3 * @file gfx_engine.c | |
| 4 * @author heinrichs weikamp gmbh | |
| 5 * @version V0.0.2 | |
| 6 * @date 30-April-2014 | |
| 7 * @brief Main source file of GFX Graphic Engine | |
| 8 * This file provides firmware functions to manage the following | |
| 9 * functions to draw on the screen: | |
| 10 * + write string to display | |
| 11 * | |
| 12 ****************************************************************************** | |
| 13 * @attention | |
| 14 * | |
| 15 * <h2><center>© COPYRIGHT(c) 2014 heinrichs weikamp</center></h2> | |
| 16 * | |
| 17 ****************************************************************************** | |
| 18 */ | |
| 19 | |
| 20 /* Includes ------------------------------------------------------------------*/ | |
| 21 | |
| 22 #include <stdlib.h> | |
| 23 #include <stdint.h> | |
| 24 | |
| 25 #include "stm32f4xx_hal.h" | |
| 26 | |
| 27 #include "gfx.h" | |
| 28 #include "gfx_engine.h" | |
| 29 #include "gfx_fonts.h" | |
| 30 #include "gfx_colors.h" | |
| 31 #include "ostc.h" | |
| 32 #include "settings.h" | |
| 33 #include "text_multilanguage.h" | |
| 34 | |
| 35 /* Exported variables --------------------------------------------------------*/ | |
| 36 | |
| 37 /* Private types -------------------------------------------------------------*/ | |
| 38 | |
| 870 | 39 #define RING_BUF_SIZE (5u) |
| 40 #define MAX_COLOR_STRING_LENGTH (100u) | |
| 698 | 41 |
| 38 | 42 typedef struct |
| 43 { | |
| 44 uint32_t Xdelta; | |
| 45 uint32_t Ydelta; | |
| 46 uint8_t invert; | |
| 47 uint8_t color; | |
| 48 uint8_t dualFont; | |
| 49 uint8_t resize; | |
| 50 uint32_t font; | |
| 51 uint8_t spaceMode; | |
| 52 uint8_t singleSpaceWithSizeOfNextChar; | |
| 53 uint8_t useTinyFont; | |
| 54 uint32_t TinyFont; | |
| 55 int8_t TinyFontExtraYdelta; | |
| 56 tFont *actualFont; | |
| 57 uint8_t doubleSize; | |
| 58 } GFX_CfgWriteString; | |
| 59 | |
| 60 typedef struct | |
| 61 { | |
| 62 uint32_t pBuffer; | |
| 63 uint32_t height; | |
| 64 uint32_t width; | |
| 65 uint32_t leftStart; | |
| 66 uint32_t bottomStart; | |
| 67 } GFX_layerSingle; | |
| 68 /* | |
| 69 typedef struct | |
| 70 { | |
| 71 GFX_layerSingle top; | |
| 72 GFX_layerSingle bottom; | |
| 73 } GFX_layersTopBottom; | |
| 74 */ | |
| 75 typedef struct | |
| 76 { | |
| 77 uint32_t pActualTopBuffer; | |
| 698 | 78 uint32_t pNextTopBuffer[RING_BUF_SIZE]; |
| 38 | 79 GFX_layerSingle actualBottom; |
| 698 | 80 GFX_layerSingle nextBottom[RING_BUF_SIZE]; |
| 81 uint8_t NextTopWrite; | |
| 82 uint8_t NextBottomWrite; | |
| 83 uint8_t NextTopRead; | |
| 84 uint8_t NextBottomRead; | |
| 38 | 85 } GFX_layerControl; |
| 86 | |
| 87 typedef struct | |
| 88 { | |
| 89 uint32_t StartAddress; | |
| 90 int8_t status; | |
| 91 uint8_t caller; | |
| 92 } SFrameList; | |
| 93 | |
| 94 enum FRAMESTATE | |
| 95 { | |
| 96 CLEAR = 0, | |
| 97 BLOCKED, | |
| 98 RELEASED | |
| 99 }; | |
| 100 | |
| 101 enum LOGOSTATE | |
| 102 { | |
| 103 LOGOOFF = 0, | |
| 104 LOGOSTART = 1, | |
| 105 LOGOSTOP = 255 | |
| 106 }; | |
| 107 | |
| 108 // should be 43 | |
| 109 #define MAXFRAMES 39 | |
| 110 | |
| 111 #define SDRAM_BANK_ADDR ((uint32_t)0xD0000000) | |
| 112 #define FBGlobalStart SDRAM_BANK_ADDR | |
| 113 #define FBOffsetEachIndex (800*480*2) | |
| 114 | |
| 115 #define SDRAM_DOUBLE_BUFFER_ONE ((uint32_t)(FBGlobalStart + (MAXFRAMES * FBOffsetEachIndex))) | |
| 116 #define SDRAM_DOUBLE_BUFFER_TWO ((uint32_t)(SDRAM_DOUBLE_BUFFER_ONE + (2 * FBOffsetEachIndex))) | |
| 117 #define SDRAM_DOUBLE_BUFFER_END ((uint32_t)(SDRAM_DOUBLE_BUFFER_TWO + (2 * FBOffsetEachIndex))) | |
| 118 | |
| 119 /* Semi Private variables ---------------------------------------------------------*/ | |
| 120 | |
| 121 DMA2D_HandleTypeDef Dma2dHandle; | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
122 static LTDC_HandleTypeDef LtdcHandle; |
| 38 | 123 |
| 124 /* Private variables ---------------------------------------------------------*/ | |
| 125 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
126 static uint8_t DMA2D_at_work = 0; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
127 |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
128 static GFX_layerControl FrameHandler = { 0 }; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
129 |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
130 static uint32_t pInvisibleFrame = 0; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
131 static uint32_t pLogoFrame = 0; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
132 static uint8_t logoStatus; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
133 static uint32_t pBackgroundHwFrame = 0; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
134 static uint8_t backgroundHwStatus; |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
135 |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
136 static SFrameList frame[MAXFRAMES]; |
| 38 | 137 |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
138 static void GFX_clear_frame_immediately(uint32_t pDestination); |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
139 static void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image); |
| 38 | 140 /* ITM Trace-----------------------------------------------------------------*/ |
| 141 | |
| 142 #include "stdio.h" | |
| 143 | |
| 144 #define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n))) | |
| 145 #define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n))) | |
| 146 #define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n))) | |
| 147 | |
| 148 #define DEMCR (*((volatile unsigned long *)(0xE000EDFC))) | |
| 149 #define TRCENA 0x01000000 | |
| 150 | |
| 151 struct __FILE { int handle; /* Add whatever needed */ }; | |
| 152 FILE __stdout; | |
| 153 FILE __stdin; | |
| 154 | |
| 155 int fputc(int ch, FILE *f) { | |
| 156 if (DEMCR & TRCENA) { | |
| 157 while (ITM_Port32(0) == 0); | |
| 158 ITM_Port8(0) = ch; | |
| 159 } | |
| 160 return(ch); | |
| 161 } | |
| 162 | |
| 163 uint32_t MinU32GFX(uint32_t a, uint32_t b) | |
| 164 { | |
| 165 return ((a<b)?a:b); | |
| 166 } | |
| 167 | |
| 168 | |
| 169 uint32_t MaxU32GFX(uint32_t a, uint32_t b) | |
| 170 { | |
| 171 return((a>b)?a:b); | |
| 172 } | |
| 173 | |
| 174 /* Private function prototypes -----------------------------------------------*/ | |
| 175 | |
| 176 static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font); | |
| 177 static uint32_t GFX_write_substring(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, uint8_t textId, int8_t nextCharFor2Byte); | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
178 static uint32_t GFX_write__Modify_Xdelta__Centered(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pText); |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
179 static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput); |
| 38 | 180 static void GFX_Error_Handler(void); |
| 181 static void GFX_Dma2d_TransferComplete(DMA2D_HandleTypeDef* Dma2dHandle); | |
| 182 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle); | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
183 static void GFX_clear_frame_dma2d(uint8_t frameId); |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
184 |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
185 static uint32_t GFX_doubleBufferOne(void); |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
186 static uint32_t GFX_doubleBufferTwo(void); |
| 38 | 187 |
| 871 | 188 static void GFX_LTDC_Init_display0(void); |
| 189 static void GFX_LTDC_Init_display1(void); | |
| 190 | |
| 38 | 191 |
| 192 /* Exported functions --------------------------------------------------------*/ | |
| 193 | |
| 194 uint8_t GFX_logoStatus(void) | |
| 195 { | |
| 196 return logoStatus; | |
| 197 } | |
| 198 | |
| 199 void GFX_SetWindowLayer0(uint32_t pDestination, int16_t XleftGimpStyle, int16_t XrightGimpStyle, int16_t YtopGimpStyle, int16_t YbottomGimpStyle) | |
| 200 { | |
| 201 int16_t XSize, YSize, X0, Y0; | |
| 202 | |
| 203 if(XleftGimpStyle < 0) XleftGimpStyle = 0; | |
| 204 if(XrightGimpStyle < 0) XrightGimpStyle = 0; | |
| 205 if(XleftGimpStyle > 799) XleftGimpStyle = 800; | |
| 206 if(XrightGimpStyle > 799) XrightGimpStyle = 800; | |
| 207 | |
| 208 if(YtopGimpStyle < 0) YtopGimpStyle = 0; | |
| 209 if(YbottomGimpStyle < 0) YbottomGimpStyle = 0; | |
| 210 if(YtopGimpStyle > 479) YtopGimpStyle = 480; | |
| 211 if(YbottomGimpStyle > 479) YbottomGimpStyle = 480; | |
| 212 | |
| 213 /* | |
| 214 XSize = YbottomGimpStyle - YtopGimpStyle; | |
| 215 YSize = XrightGimpStyle - XleftGimpStyle; | |
| 216 if((XSize <= 0) || (YSize <= 0)) | |
| 217 return; | |
| 218 X0 = 479 - YbottomGimpStyle; | |
| 219 Y0 = XleftGimpStyle; | |
| 220 while((LTDC->CPSR & LTDC_CPSR_CYPOS) <= (uint32_t)800); | |
| 221 HAL_LTDC_SetWindowSize(&LtdcHandle, XSize, YSize, LayerIdx); | |
| 222 HAL_LTDC_SetWindowPosition(&LtdcHandle, X0, Y0,LayerIdx); | |
| 223 HAL_LTDC_SetAddress(&LtdcHandle, pDestination, LayerIdx); | |
| 224 */ | |
| 225 | |
| 226 XSize = XrightGimpStyle - XleftGimpStyle; | |
| 227 YSize = YbottomGimpStyle - YtopGimpStyle; | |
| 228 if((XSize <= 0) || (YSize <= 0)) | |
| 229 return; | |
| 230 Y0 = 479 - YbottomGimpStyle; | |
| 231 X0 = XleftGimpStyle; | |
| 232 | |
| 233 GFX_SetFrameBottom(pDestination, X0, Y0, XSize, YSize); | |
| 234 } | |
| 235 | |
| 236 | |
| 237 void GFX_logoAutoOff(void) | |
| 238 { | |
| 239 if(logoStatus == LOGOOFF) | |
| 240 logoStatus = LOGOSTART; | |
| 241 } | |
| 242 | |
| 243 | |
| 244 void GFX_hwBackgroundOn(void) | |
| 245 { | |
| 246 backgroundHwStatus = LOGOSTART; | |
| 247 } | |
| 248 | |
| 249 | |
| 250 void GFX_hwBackgroundOff(void) | |
| 251 { | |
| 252 backgroundHwStatus = LOGOSTOP; | |
| 253 } | |
| 254 | |
| 314 | 255 void GFX_build_hw_background_frame(void) |
| 38 | 256 { |
| 257 GFX_DrawCfgScreen tLogoTemp; | |
| 258 SWindowGimpStyle windowGimp; | |
| 259 | |
| 260 pBackgroundHwFrame = getFrame(1); | |
| 261 backgroundHwStatus = 0; | |
| 262 | |
| 263 tLogoTemp.FBStartAdress = pBackgroundHwFrame; | |
| 264 tLogoTemp.ImageHeight = 480; | |
| 265 tLogoTemp.ImageWidth = 800; | |
| 266 tLogoTemp.LayerIndex = 1; | |
| 267 | |
| 268 windowGimp.left = (800 - 400) / 2; | |
| 269 windowGimp.top = 0;//(480 - 46) / 2; | |
| 270 | |
| 271 GFX_draw_image_color(&tLogoTemp, windowGimp, &ImgHWcolor); | |
| 272 /* | |
| 273 char localtext[256]; | |
| 274 uint8_t ptr = 0; | |
| 275 | |
| 276 localtext[ptr++] = ' '; | |
| 277 localtext[ptr++] = ' '; | |
| 278 localtext[ptr++] = 'O'; | |
| 279 localtext[ptr++] = 'S'; | |
| 280 localtext[ptr++] = ' '; | |
| 281 ptr += GFX_printf_firmware(&localtext[ptr]); | |
| 282 localtext[ptr] = 0; | |
| 283 | |
| 284 write_content_simple(&tLogoTemp, 0, 800, 240-24, &FontT24,localtext,CLUT_Font020); | |
| 285 */ | |
| 286 } | |
| 287 | |
| 288 | |
| 314 | 289 void GFX_build_logo_frame(void) |
| 38 | 290 { |
| 291 GFX_DrawCfgScreen tLogoTemp; | |
| 292 SWindowGimpStyle windowGimp; | |
| 293 | |
| 1053 | 294 SIconHeader* pIconHeader = (SIconHeader*) ICON_HEADER_ADDR; |
| 295 tImage Image; | |
| 296 Image.data= (uint8_t*) (ICON_HEADER_ADDR + 12 + (256 * 4)); /* Offset Header + CLUT */ | |
| 297 | |
| 298 Image.width = ((pIconHeader->dummy7 & 0x0F) << 8) | pIconHeader->dummy5; | |
| 299 Image.height = ((pIconHeader->dummy7 & 0xF0) << 4) | pIconHeader->dummy6; | |
| 300 | |
| 301 | |
| 38 | 302 pLogoFrame = getFrame(1); |
| 303 logoStatus = LOGOOFF; | |
| 304 | |
| 305 tLogoTemp.FBStartAdress = pLogoFrame; | |
| 306 tLogoTemp.ImageHeight = 480; | |
| 307 tLogoTemp.ImageWidth = 800; | |
| 308 tLogoTemp.LayerIndex = 1; | |
| 309 | |
| 1053 | 310 if(pIconHeader->type == 0x20) |
| 311 { | |
| 312 windowGimp.left = (800 - Image.width) / 2; | |
| 313 windowGimp.top = (480 - Image.height) / 2; | |
| 314 | |
| 315 GFX_draw_image_color(&tLogoTemp, windowGimp, &Image); | |
| 316 } | |
| 317 else | |
| 318 { | |
| 319 windowGimp.left = (800 - ImgHWcolor.width) / 2; | |
| 320 windowGimp.top = (480 - ImgHWcolor.height) / 2; | |
| 321 GFX_draw_image_color(&tLogoTemp, windowGimp, &ImgHWcolor); | |
| 322 } | |
| 323 | |
| 324 | |
| 38 | 325 /* |
| 326 char localtext[256]; | |
| 327 uint8_t ptr = 0; | |
| 328 | |
| 329 localtext[ptr++] = ' '; | |
| 330 localtext[ptr++] = ' '; | |
| 331 localtext[ptr++] = 'O'; | |
| 332 localtext[ptr++] = 'S'; | |
| 333 localtext[ptr++] = ' '; | |
| 334 ptr += GFX_printf_firmware(&localtext[ptr]); | |
| 335 localtext[ptr] = 0; | |
| 336 | |
| 337 write_content_simple(&tLogoTemp, 0, 800, 240-24, &FontT24,localtext,CLUT_Font020); | |
| 338 */ | |
| 339 } | |
| 340 | |
| 341 void GFX_init(uint32_t * pDestinationOut) | |
| 342 { | |
| 343 frame[0].StartAddress = FBGlobalStart; | |
| 344 GFX_clear_frame_immediately(frame[0].StartAddress); | |
| 345 frame[0].status = CLEAR; | |
| 346 frame[0].caller = 0; | |
| 347 | |
| 348 for(int i=1;i<MAXFRAMES;i++) | |
| 349 { | |
| 350 frame[i].StartAddress = frame[i-1].StartAddress + FBOffsetEachIndex; | |
| 351 GFX_clear_frame_immediately(frame[i].StartAddress); | |
| 352 frame[i].status = CLEAR; | |
| 353 frame[i].caller = 0; | |
| 354 } | |
| 355 | |
| 356 pInvisibleFrame = getFrame(2); | |
| 357 *pDestinationOut = pInvisibleFrame; | |
| 358 | |
| 359 GFX_build_logo_frame(); | |
| 360 GFX_build_hw_background_frame(); | |
| 361 | |
| 362 /* Register to memory mode with ARGB8888 as color Mode */ | |
| 363 Dma2dHandle.Init.Mode = DMA2D_R2M; | |
| 364 Dma2dHandle.Init.ColorMode = DMA2D_ARGB4444;//to fake AL88, before: DMA2D_ARGB8888; | |
| 365 Dma2dHandle.Init.OutputOffset = 0; | |
| 366 | |
| 367 /* DMA2D Callbacks Configuration */ | |
| 368 Dma2dHandle.XferCpltCallback = GFX_Dma2d_TransferComplete; | |
| 369 Dma2dHandle.XferErrorCallback = GFX_Dma2d_TransferError; | |
| 370 | |
| 371 Dma2dHandle.Instance = DMA2D; | |
| 372 | |
| 373 /* DMA2D Initialisation */ | |
| 374 if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK) | |
| 375 GFX_Error_Handler(); | |
| 376 | |
| 377 if(HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1) != HAL_OK) | |
| 378 GFX_Error_Handler(); | |
| 379 | |
| 380 DMA2D_at_work = 255; | |
| 381 } | |
| 870 | 382 void GFX_init1_no_DMA(uint32_t * pDestinationOut, uint8_t blockFrames) |
| 383 { | |
| 384 frame[0].StartAddress = FBGlobalStart; | |
| 385 GFX_clear_frame_immediately(frame[0].StartAddress); | |
| 386 frame[0].status = CLEAR; | |
| 387 frame[0].caller = 0; | |
| 388 | |
| 389 for(int i=1;i<MAXFRAMES;i++) | |
| 390 { | |
| 391 frame[i].StartAddress = frame[i-1].StartAddress + FBOffsetEachIndex; | |
| 392 GFX_clear_frame_immediately(frame[i].StartAddress); | |
| 393 frame[i].status = CLEAR; | |
| 394 frame[i].caller = 0; | |
| 395 } | |
| 396 | |
| 397 for(int i=0;i<blockFrames;i++) | |
| 398 { | |
| 399 frame[i].status = BLOCKED; | |
| 400 frame[i].caller = 1; | |
| 401 } | |
| 402 | |
| 403 pInvisibleFrame = getFrame(2); | |
| 404 *pDestinationOut = pInvisibleFrame; | |
| 405 | |
| 406 GFX_build_logo_frame(); | |
| 407 GFX_build_hw_background_frame(); | |
| 408 } | |
| 409 | |
| 410 | |
| 411 void GFX_init2_DMA(void) | |
| 412 { | |
| 413 /* Register to memory mode with ARGB8888 as color Mode */ | |
| 414 Dma2dHandle.Init.Mode = DMA2D_R2M; | |
| 415 Dma2dHandle.Init.ColorMode = DMA2D_ARGB4444;//to fake AL88, before: DMA2D_ARGB8888; | |
| 416 Dma2dHandle.Init.OutputOffset = 0; | |
| 417 | |
| 418 /* DMA2D Callbacks Configuration */ | |
| 419 Dma2dHandle.XferCpltCallback = GFX_Dma2d_TransferComplete; | |
| 420 Dma2dHandle.XferErrorCallback = GFX_Dma2d_TransferError; | |
| 421 | |
| 422 Dma2dHandle.Instance = DMA2D; | |
| 423 | |
| 424 /* DMA2D Initialisation */ | |
| 425 if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK) | |
| 426 GFX_Error_Handler(); | |
| 427 | |
| 428 if(HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1) != HAL_OK) | |
| 429 GFX_Error_Handler(); | |
| 430 | |
| 431 DMA2D_at_work = 255; | |
| 432 } | |
| 38 | 433 |
| 434 | |
| 435 void GFX_SetFrameTop(uint32_t pDestination) | |
| 436 { | |
| 698 | 437 uint8_t NextTopWork = FrameHandler.NextTopWrite + 1; |
| 438 | |
| 439 if(NextTopWork == RING_BUF_SIZE) | |
| 440 { | |
| 441 NextTopWork = 0; | |
| 442 } | |
| 38 | 443 |
| 444 if(pDestination == 0) | |
| 445 pDestination = pInvisibleFrame; | |
| 446 | |
| 698 | 447 FrameHandler.pNextTopBuffer[NextTopWork] = pDestination; |
| 448 FrameHandler.NextTopWrite = NextTopWork; | |
| 38 | 449 } |
| 450 | |
| 451 | |
| 452 void GFX_SetFrameBottom(uint32_t pDestination, uint32_t x0, uint32_t y0, uint32_t width, uint32_t height) | |
| 453 { | |
| 698 | 454 uint8_t NextBottomWork = FrameHandler.NextBottomWrite + 1; |
| 455 | |
| 456 if(NextBottomWork == RING_BUF_SIZE) | |
| 457 { | |
| 458 NextBottomWork = 0; | |
| 459 } | |
| 38 | 460 |
| 461 if(pDestination == 0) | |
| 462 pDestination = pInvisibleFrame; | |
| 463 | |
| 698 | 464 FrameHandler.nextBottom[NextBottomWork].pBuffer = pDestination; |
| 465 FrameHandler.nextBottom[NextBottomWork].height = height; | |
| 466 FrameHandler.nextBottom[NextBottomWork].width = width; | |
| 467 FrameHandler.nextBottom[NextBottomWork].leftStart = x0; | |
| 468 FrameHandler.nextBottom[NextBottomWork].bottomStart = y0; | |
| 469 FrameHandler.NextBottomWrite = NextBottomWork; | |
| 38 | 470 } |
| 471 | |
| 472 | |
| 473 void GFX_SetFramesTopBottom(uint32_t pTop, uint32_t pBottom, uint32_t heightBottom) | |
| 474 { | |
| 475 GFX_SetFrameTop(pTop); | |
| 476 GFX_SetFrameBottom(pBottom, 0, 0, 800, heightBottom); | |
| 477 } | |
| 478 | |
| 479 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
480 static uint32_t GFX_get_pActualFrameTop(void) |
| 38 | 481 { |
| 482 return FrameHandler.pActualTopBuffer; | |
| 483 } | |
| 484 | |
| 485 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
486 static uint32_t GFX_get_pActualFrameBottom(void) |
| 38 | 487 { |
| 488 return FrameHandler.actualBottom.pBuffer; | |
| 489 } | |
| 490 | |
| 491 | |
| 492 void GFX_start_VSYNC_IRQ(void) | |
| 493 { | |
| 494 GPIO_InitTypeDef GPIO_InitStructure; | |
| 495 | |
| 496 GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING; | |
| 497 GPIO_InitStructure.Pull = GPIO_NOPULL; | |
| 498 GPIO_InitStructure.Speed = GPIO_SPEED_LOW; | |
| 499 GPIO_InitStructure.Pin = VSYNC_IRQ_PIN; | |
| 500 HAL_GPIO_Init(VSYNC_IRQ_GPIO_PORT, &GPIO_InitStructure); | |
| 501 | |
| 502 HAL_NVIC_SetPriority(VSYNC_IRQ_EXTI_IRQn, 1, 0); | |
| 503 HAL_NVIC_EnableIRQ(VSYNC_IRQ_EXTI_IRQn); | |
| 504 } | |
| 505 | |
| 506 | |
| 507 void GFX_change_LTDC(void) | |
| 508 { | |
| 509 uint32_t pTop = 0; | |
| 510 uint32_t pBot = 0; | |
| 511 uint32_t heightBot = 0; | |
| 512 uint32_t widthBot = 0; | |
| 513 uint32_t leftStartBot = 0; | |
| 514 uint32_t bottomStartBot = 0; | |
| 515 uint8_t change_position = 0; | |
| 516 uint8_t change_size = 0; | |
| 698 | 517 uint8_t nextBottomBackup = FrameHandler.NextBottomRead; /* Restore entry value in case off logo handling */ |
| 38 | 518 |
| 1053 | 519 SIconHeader* pIconHeader = (SIconHeader*) ICON_HEADER_ADDR; |
| 520 uint32_t* pCLUT; | |
| 521 pCLUT = (uint32_t *)indexHWcolor; | |
| 522 | |
| 523 | |
| 38 | 524 // Top Frame |
| 698 | 525 if(FrameHandler.NextTopRead != FrameHandler.NextTopWrite) |
| 526 { | |
| 527 FrameHandler.NextTopRead++; | |
| 528 if(FrameHandler.NextTopRead == RING_BUF_SIZE) | |
| 529 { | |
| 530 FrameHandler.NextTopRead = 0; | |
| 531 } | |
| 532 } | |
| 533 pTop = FrameHandler.pNextTopBuffer[FrameHandler.NextTopRead]; | |
| 534 | |
| 38 | 535 if(FrameHandler.pActualTopBuffer != pTop) |
| 536 { | |
| 537 HAL_LTDC_SetAddress(&LtdcHandle, pTop, 1); | |
| 538 FrameHandler.pActualTopBuffer = pTop; | |
| 539 } | |
| 540 | |
| 541 // Bottom Frame | |
| 698 | 542 if(FrameHandler.NextBottomRead != FrameHandler.NextBottomWrite) |
| 543 { | |
| 544 FrameHandler.NextBottomRead++; | |
| 545 if(FrameHandler.NextBottomRead == RING_BUF_SIZE) | |
| 546 { | |
| 547 FrameHandler.NextBottomRead = 0; | |
| 548 } | |
| 549 } | |
| 38 | 550 if(logoStatus != LOGOOFF) |
| 551 { | |
| 552 switch(logoStatus) | |
| 553 { | |
| 554 case LOGOSTART: | |
| 1053 | 555 if(pIconHeader->type == 0x20) |
| 556 { | |
| 557 pCLUT = (uint32_t *)(pIconHeader + 1); /* First address behind the header */ | |
| 558 } | |
| 38 | 559 HAL_LTDC_SetAlpha(&LtdcHandle, 0, 1); |
| 560 HAL_LTDC_SetAlpha(&LtdcHandle, 34, 0); | |
| 1053 | 561 HAL_LTDC_ConfigCLUT(&LtdcHandle, pCLUT, indexHWcolorSIZE, 0); |
| 38 | 562 HAL_LTDC_SetAddress(&LtdcHandle, pLogoFrame, 0); |
| 563 HAL_LTDC_SetWindowSize(&LtdcHandle, 480, 800, 0); | |
| 564 HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, 0, 0); | |
| 565 logoStatus = 2; | |
| 698 | 566 FrameHandler.NextBottomRead = nextBottomBackup; |
| 38 | 567 break; |
| 568 | |
| 569 case LOGOSTOP: | |
| 570 HAL_LTDC_SetAlpha(&LtdcHandle, 255, 1); | |
| 571 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 0); | |
| 572 | |
| 698 | 573 pBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].pBuffer; |
| 574 heightBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].height; | |
| 575 widthBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].width; | |
| 576 leftStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].leftStart; | |
| 577 bottomStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].bottomStart; | |
| 38 | 578 HAL_LTDC_SetWindowSize(&LtdcHandle, heightBot, widthBot, 0); |
| 579 HAL_LTDC_SetWindowPosition(&LtdcHandle, bottomStartBot, leftStartBot, 0); | |
| 580 HAL_LTDC_SetAddress(&LtdcHandle, pBot, 0); | |
| 581 HAL_LTDC_SetAlpha(&LtdcHandle, 255, 0); | |
| 582 FrameHandler.actualBottom.height = heightBot; | |
| 583 FrameHandler.actualBottom.width = widthBot; | |
| 584 FrameHandler.actualBottom.leftStart = leftStartBot; | |
| 585 FrameHandler.actualBottom.bottomStart = bottomStartBot; | |
| 586 FrameHandler.actualBottom.pBuffer = pBot; | |
| 587 | |
| 588 logoStatus = LOGOOFF; | |
| 589 if(backgroundHwStatus == 2) | |
| 590 { | |
| 591 backgroundHwStatus = LOGOSTART; | |
| 592 } | |
| 593 break; | |
| 594 default: | |
| 595 if(logoStatus < 35) | |
| 596 { | |
| 597 logoStatus++; | |
| 598 if(logoStatus <= 15) | |
| 599 HAL_LTDC_SetAlpha(&LtdcHandle, 17*logoStatus, 0); | |
| 600 } | |
| 601 else | |
| 602 { | |
| 603 logoStatus +=20; | |
| 604 HAL_LTDC_SetAlpha(&LtdcHandle, logoStatus-55, 1); | |
| 605 HAL_LTDC_SetAlpha(&LtdcHandle, 255+55-logoStatus, 0); | |
| 606 } | |
| 698 | 607 FrameHandler.NextBottomRead = nextBottomBackup; |
| 38 | 608 break; |
| 609 } | |
| 610 return; | |
| 611 } | |
| 612 else if (backgroundHwStatus != LOGOOFF) | |
| 613 { | |
| 870 | 614 |
| 38 | 615 switch(backgroundHwStatus) |
| 616 { | |
| 617 case LOGOSTART: | |
| 1053 | 618 HAL_LTDC_ConfigCLUT(&LtdcHandle, pCLUT, indexHWcolorSIZE, 0); |
| 38 | 619 HAL_LTDC_SetAddress(&LtdcHandle, pBackgroundHwFrame, 0); |
| 620 HAL_LTDC_SetWindowSize(&LtdcHandle, 480, 800, 0); | |
| 621 HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, 0, 0); | |
| 622 backgroundHwStatus = 2; | |
| 698 | 623 FrameHandler.NextBottomRead = nextBottomBackup; |
| 38 | 624 break; |
| 625 | |
| 626 case LOGOSTOP: | |
| 627 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 0); | |
| 698 | 628 pBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].pBuffer; |
| 629 heightBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].height; | |
| 630 widthBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].width; | |
| 631 leftStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].leftStart; | |
| 632 bottomStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].bottomStart; | |
| 38 | 633 HAL_LTDC_SetWindowSize(&LtdcHandle, heightBot, widthBot, 0); |
| 634 HAL_LTDC_SetWindowPosition(&LtdcHandle, bottomStartBot, leftStartBot, 0); | |
| 635 HAL_LTDC_SetAddress(&LtdcHandle, pBot, 0); | |
| 636 HAL_LTDC_SetAlpha(&LtdcHandle, 255, 0); | |
| 637 FrameHandler.actualBottom.height = heightBot; | |
| 638 FrameHandler.actualBottom.width = widthBot; | |
| 639 FrameHandler.actualBottom.leftStart = leftStartBot; | |
| 640 FrameHandler.actualBottom.bottomStart = bottomStartBot; | |
| 641 FrameHandler.actualBottom.pBuffer = pBot; | |
| 642 backgroundHwStatus = LOGOOFF; | |
| 643 break; | |
| 644 | |
| 645 default: | |
| 698 | 646 FrameHandler.NextBottomRead = nextBottomBackup; |
| 38 | 647 break; |
| 648 } | |
| 870 | 649 |
| 38 | 650 return; |
| 651 } | |
| 652 else | |
| 653 { | |
| 698 | 654 pBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].pBuffer; |
| 655 heightBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].height; | |
| 656 widthBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].width; | |
| 657 leftStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].leftStart; | |
| 658 bottomStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].bottomStart; | |
| 38 | 659 |
| 660 if(FrameHandler.actualBottom.pBuffer == pBot) | |
| 661 pBot = 0; | |
| 662 | |
| 663 if((FrameHandler.actualBottom.height != heightBot) || (FrameHandler.actualBottom.width != widthBot)) | |
| 664 change_size = 1; | |
| 665 | |
| 666 if((FrameHandler.actualBottom.leftStart != leftStartBot) || (FrameHandler.actualBottom.bottomStart != bottomStartBot)) | |
| 667 change_position = 1; | |
| 668 | |
| 669 if(pBot || change_size || change_position) | |
| 670 { | |
| 671 if(heightBot && widthBot) | |
| 672 HAL_LTDC_SetWindowSize(&LtdcHandle, heightBot, widthBot, 0); | |
| 673 | |
| 674 if(change_position || leftStartBot || bottomStartBot) | |
| 675 HAL_LTDC_SetWindowPosition(&LtdcHandle, bottomStartBot, leftStartBot, 0); | |
| 676 | |
| 677 if(pBot) | |
| 678 HAL_LTDC_SetAddress(&LtdcHandle, pBot, 0); | |
| 679 | |
| 680 if(change_size) | |
| 681 { | |
| 682 FrameHandler.actualBottom.height = heightBot; | |
| 683 FrameHandler.actualBottom.width = widthBot; | |
| 684 } | |
| 685 if(change_position) | |
| 686 { | |
| 687 FrameHandler.actualBottom.leftStart = leftStartBot; | |
| 688 FrameHandler.actualBottom.bottomStart = bottomStartBot; | |
| 689 } | |
| 690 if(pBot) | |
| 691 FrameHandler.actualBottom.pBuffer = pBot; | |
| 692 } | |
| 693 } | |
| 694 } | |
| 695 | |
| 696 uint8_t GFX_is_colorschemeDiveStandard(void) | |
| 697 { | |
| 698 return (ColorLUT[CLUT_Font027] == 0x00FFFFFF); | |
| 699 } | |
| 700 | |
| 701 | |
| 702 void change_CLUT_entry(uint8_t entryToChange, uint8_t entryUsedForChange) | |
| 703 { | |
| 704 /* bug fix | |
| 705 static uint8_t counter = 0; | |
| 706 | |
| 707 if(entryToChange == 0x1C) | |
| 708 counter++; | |
| 709 */ | |
| 710 ColorLUT[entryToChange] = ColorLUT[entryUsedForChange]; | |
| 711 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 1); | |
| 712 if(logoStatus == LOGOOFF) | |
| 713 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 0); | |
| 714 } | |
| 715 | |
| 716 | |
| 717 void GFX_use_colorscheme(uint8_t colorscheme) | |
| 718 { | |
| 719 uint8_t ColorSchemeStart; | |
| 720 | |
| 721 if(colorscheme > 3) | |
| 722 colorscheme = 0; | |
| 723 | |
| 724 ColorSchemeStart = CLUT_Colorscheme0 + (8 * colorscheme); | |
| 725 for(int i=1; i<8; i++) | |
| 726 { | |
| 727 ColorLUT[CLUT_Font027 + i] = ColorLUT[ColorSchemeStart + i]; | |
| 728 } | |
| 729 change_CLUT_entry(CLUT_Font027, ColorSchemeStart); | |
| 730 } | |
| 731 | |
| 732 | |
| 733 void GFX_VGA_transform(uint32_t pSource, uint32_t pDestination) | |
| 734 { | |
| 735 int h, v; | |
| 736 uint32_t offsetSource, offsetSourceStartOfLine; | |
| 737 | |
| 738 offsetSourceStartOfLine = 480 + 480 - 2; | |
| 739 for(v=0;v<480;v++) | |
| 740 { | |
| 741 offsetSource = offsetSourceStartOfLine; | |
| 742 for(h=0;h<640;h++) | |
| 743 { | |
| 744 *(__IO uint8_t*)pDestination = *(uint8_t*)(pSource + offsetSource); | |
| 745 pDestination++; | |
| 746 offsetSource += 1; | |
| 747 *(__IO uint8_t*)pDestination = *(uint8_t*)(pSource + offsetSource); | |
| 748 pDestination++; | |
| 749 offsetSource += 480 + 479; | |
| 750 } | |
| 751 offsetSourceStartOfLine -= 2; | |
| 752 } | |
| 753 } | |
| 754 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
755 |
|
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
756 static void GFX_clear_frame_immediately(uint32_t pDestination) |
| 38 | 757 { |
| 758 uint32_t i; | |
| 121 | 759 uint32_t* pfill = (uint32_t*) pDestination; |
| 760 | |
| 38 | 761 |
| 762 for(i = 200*480; i > 0; i--) | |
| 763 { | |
| 121 | 764 *pfill++ = 0; |
| 765 *pfill++ = 0; | |
| 38 | 766 } |
| 767 } | |
| 768 | |
| 769 | |
| 770 void GFX_clear_window_immediately(GFX_DrawCfgWindow* hgfx) | |
| 771 { | |
| 772 uint32_t pDestination, i, j; | |
| 773 uint16_t left, width, bottom, height, nextlineStep; | |
| 774 | |
| 775 pDestination = (uint32_t)hgfx->Image->FBStartAdress; | |
| 776 | |
| 777 left = hgfx->WindowX0; | |
| 778 width = 1 + hgfx->WindowX1 - left; | |
| 779 bottom = hgfx->WindowY0; | |
| 780 height = 1 + hgfx->WindowY1 - bottom; | |
| 781 nextlineStep = hgfx->Image->ImageHeight - height; | |
| 782 nextlineStep *= 2; | |
| 783 | |
| 784 pDestination += 2 * bottom; | |
| 785 pDestination += 2 * hgfx->Image->ImageHeight * left; | |
| 786 | |
| 787 for(j = width; j > 0; j--) | |
| 788 { | |
| 789 for(i = height; i > 0; i--) | |
| 790 { | |
| 791 *(__IO uint16_t*)pDestination = 0; | |
| 792 pDestination += 2; | |
| 793 } | |
| 794 pDestination += nextlineStep; | |
| 795 } | |
| 796 } | |
| 797 | |
| 798 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
799 static void GFX_clear_frame_dma2d(uint8_t frameId) |
| 38 | 800 { |
| 801 if(frameId >= MAXFRAMES) | |
| 802 return; | |
| 803 | |
| 804 DMA2D_at_work = frameId; | |
| 805 | |
| 806 if (HAL_DMA2D_Start_IT(&Dma2dHandle, 0x0000000000, frame[frameId].StartAddress, 480, 800) != HAL_OK) | |
| 807 GFX_Error_Handler(); | |
| 808 } | |
| 809 | |
| 810 | |
| 811 void GFX_fill_buffer(uint32_t pDestination, uint8_t alpha, uint8_t color) | |
| 812 { | |
| 813 | |
| 121 | 814 union al88_u |
| 38 | 815 { |
| 816 uint8_t al8[2]; | |
| 817 uint16_t al88; | |
| 818 }; | |
| 819 union al88_u colorcombination; | |
| 820 uint32_t i; | |
| 121 | 821 uint32_t* pfill = (uint32_t*) pDestination; |
| 822 uint32_t fillpattern; | |
| 38 | 823 |
| 824 colorcombination.al8[0] = color; | |
| 825 colorcombination.al8[1] = alpha; | |
| 826 | |
| 121 | 827 fillpattern = (colorcombination.al88 << 16) | colorcombination.al88; |
| 828 for(i = 800*480/2; i > 0; i--) | |
| 38 | 829 { |
| 121 | 830 *pfill++ = fillpattern; |
| 38 | 831 } |
| 832 } | |
| 833 | |
| 834 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
835 static void gfx_flip(point_t *p1, point_t *p2) |
| 38 | 836 { |
| 837 point_t temp; | |
| 838 | |
| 839 temp = *p1; | |
| 840 *p1 = *p2; | |
| 841 *p2 = temp; | |
| 842 } | |
| 843 | |
| 844 | |
| 845 static inline void gfx_brush(uint8_t thickness, GFX_DrawCfgScreen *hgfx, uint16_t x0, uint16_t y0, uint8_t color) | |
| 846 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
847 uint16_t* pDestination; |
| 38 | 848 uint8_t offset = thickness/2; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
849 int16_t stepdir; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
850 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
851 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
852 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
853 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
854 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
855 { |
| 114 | 856 pDestination = (uint16_t*)hgfx->FBStartAdress; |
| 857 pDestination += (hgfx->ImageHeight * (hgfx->ImageWidth - x0 + offset)) + (480 - y0+offset); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
858 stepdir = -1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
859 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
860 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
861 { |
| 114 | 862 pDestination = (uint16_t*)hgfx->FBStartAdress; |
| 863 pDestination += (x0 - offset)*hgfx->ImageHeight + (y0-offset); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
864 stepdir = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
865 } |
| 38 | 866 for(int x=thickness;x>0;x--) |
| 867 { | |
| 868 for(int y=thickness;y>0;y--) | |
| 869 { | |
| 870 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
871 pDestination += stepdir; |
| 38 | 872 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
873 pDestination += stepdir * (hgfx->ImageHeight - thickness); |
| 38 | 874 } |
| 875 } | |
| 876 | |
| 877 | |
| 878 void GFX_draw_thick_line(uint8_t thickness, GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) | |
| 879 { | |
| 880 if(thickness < 2) | |
| 881 GFX_draw_line(hgfx, start, stop, color); | |
| 882 | |
| 883 int x0 = start.x; | |
| 884 int y0 = start.y; | |
| 885 int x1 = stop.x; | |
| 886 int y1 = stop.y; | |
| 887 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; | |
| 888 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; | |
| 889 int err = (dx>dy ? dx : -dy)/2, e2; | |
| 890 | |
| 891 | |
| 892 if(start.x == stop.x) | |
| 893 { | |
| 894 if(start.y > stop.y) gfx_flip(&start,&stop); | |
| 895 for (int j = stop.y - start.y; j > 0; j--) | |
| 896 { | |
| 897 gfx_brush(thickness,hgfx,start.x,start.y++,color); | |
| 898 } | |
| 899 } | |
| 900 else | |
| 901 if(start.y == stop.y) | |
| 902 { | |
| 903 if(start.x > stop.x) gfx_flip(&start,&stop); | |
| 904 | |
| 905 for (int j = stop.x - start.x; j > 0; j--) | |
| 906 { | |
| 907 gfx_brush(thickness,hgfx,start.x++,start.y,color); | |
| 908 } | |
| 909 } | |
| 910 else // diagonal | |
| 911 { | |
| 912 for(;;) | |
| 913 { | |
| 914 gfx_brush(thickness,hgfx,x0,y0,color); | |
| 915 if (x0==x1 && y0==y1) break; | |
| 916 e2 = err; | |
| 917 if (e2 >-dx) { err -= dy; x0 += sx; } | |
| 918 if (e2 < dy) { err += dx; y0 += sy; } | |
| 919 } | |
| 920 } | |
| 921 } | |
| 922 | |
| 923 | |
| 924 void GFX_draw_line(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) | |
| 925 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
926 uint16_t* pDestination; |
| 38 | 927 uint32_t j; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
928 int16_t stepdir; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
929 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
930 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
931 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
932 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
933 /* horizontal line */ |
| 38 | 934 if(start.x == stop.x) |
| 935 { | |
| 936 if(start.y > stop.y) gfx_flip(&start,&stop); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
937 |
| 114 | 938 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
939 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
940 { |
| 622 | 941 pDestination += (799 - start.x) * hgfx->ImageHeight; |
| 942 pDestination += (479 - start.y); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
943 stepdir = -1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
944 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
945 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
946 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
947 pDestination += start.x * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
948 pDestination += start.y; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
949 stepdir = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
950 } |
| 38 | 951 for (j = stop.y - start.y; j > 0; j--) |
| 952 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
953 *(__IO uint16_t*)pDestination = 0xFF00 + color; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
954 pDestination += stepdir; |
| 38 | 955 } |
| 956 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
957 else /* vertical line ? */ |
| 38 | 958 if(start.y == stop.y) |
| 959 { | |
| 960 if(start.x > stop.x) gfx_flip(&start,&stop); | |
| 114 | 961 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
962 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
963 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
964 { |
| 622 | 965 pDestination += (799 - start.x) * hgfx->ImageHeight; |
| 966 pDestination += (479 - start.y); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
967 stepdir = -1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
968 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
969 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
970 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
971 pDestination += start.x * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
972 pDestination += start.y; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
973 stepdir = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
974 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
975 |
| 38 | 976 for (j = stop.x - start.x; j > 0; j--) |
| 977 { | |
| 978 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
979 pDestination += stepdir * hgfx->ImageHeight; |
| 38 | 980 } |
| 981 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
982 else /* diagonal */ |
| 38 | 983 { |
| 984 int x0 = start.x; | |
| 985 int y0 = start.y; | |
| 986 int x1 = stop.x; | |
| 987 int y1 = stop.y; | |
| 988 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; | |
| 989 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; | |
| 990 int err = (dx>dy ? dx : -dy)/2, e2; | |
| 991 | |
| 992 for(;;) | |
| 993 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
994 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
995 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
996 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
997 { |
| 622 | 998 pDestination += (((799 - x0) * hgfx->ImageHeight) + (479 - y0)); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
999 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1000 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1001 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1002 pDestination += ((x0 * hgfx->ImageHeight) + y0); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1003 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1004 |
| 38 | 1005 *(__IO uint16_t*)pDestination = 0xFF00 + color; |
| 1006 if (x0==x1 && y0==y1) break; | |
| 1007 e2 = err; | |
| 1008 if (e2 >-dx) { err -= dy; x0 += sx; } | |
| 1009 if (e2 < dy) { err += dx; y0 += sy; } | |
| 1010 } | |
| 1011 } | |
| 1012 } | |
| 1013 | |
| 1014 | |
| 1015 void GFX_draw_image_monochrome(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image, uint8_t color) | |
| 1016 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1017 uint16_t* pDestination; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1018 uint32_t j; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1019 point_t start, stop; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1020 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1021 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1022 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1023 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1024 start.x = window.left; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1025 start.y = (hgfx->ImageHeight - image->height - window.top); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1026 stop.y = start.y + image->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1027 stop.x = start.x + image->width; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1028 j = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1029 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1030 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1031 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1032 for(int xx = start.x; xx < stop.x; xx++) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1033 { |
| 114 | 1034 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1035 pDestination += (hgfx->ImageHeight - start.y) + (stop.x * hgfx->ImageHeight) ; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1036 pDestination -= (xx - start.x) * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1037 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1038 for(int yy = start.y; yy < stop.y; yy++) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1039 { |
| 114 | 1040 *(__IO uint16_t*)pDestination-- = (image->data[j++] << 8) + color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1041 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1042 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1043 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1044 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1045 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1046 for(int xx = start.x; xx < stop.x; xx++) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1047 { |
| 114 | 1048 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1049 pDestination += xx * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1050 pDestination += start.y; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1051 for(int yy = start.y; yy < stop.y; yy++) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1052 { |
| 114 | 1053 *(__IO uint16_t*)pDestination++ = (image->data[j++] << 8) + color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1054 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1055 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1056 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1057 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1058 |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
1059 static void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image) |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1060 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1061 uint16_t* pDestination; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1062 |
| 38 | 1063 uint32_t j; |
| 1064 point_t start, stop; | |
| 1065 | |
| 1066 start.x = window.left; | |
| 1067 start.y = (hgfx->ImageHeight - image->height - window.top); | |
| 1068 stop.y = start.y + image->height; | |
| 1069 stop.x = start.x + image->width; | |
| 1070 j = 0; | |
| 1071 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1072 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1073 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1074 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1075 if(pSettings->FlipDisplay) |
| 38 | 1076 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1077 for(int xx = start.x; xx < stop.x; xx++) |
| 38 | 1078 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1079 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1080 pDestination += (hgfx->ImageHeight - start.y) + (stop.x * hgfx->ImageHeight); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1081 pDestination -= (xx - start.x) * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1082 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1083 for(int yy = start.y; yy < stop.y; yy++) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1084 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1085 *(__IO uint16_t*)pDestination-- = 0xFF << 8 | image->data[j++]; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1086 } |
| 38 | 1087 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1088 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1089 else |
| 38 | 1090 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1091 for(int xx = start.x; xx < stop.x; xx++) |
| 38 | 1092 { |
| 114 | 1093 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1094 pDestination += xx * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1095 pDestination += start.y; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1096 for(int yy = start.y; yy < stop.y; yy++) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1097 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1098 *(__IO uint16_t*)pDestination++ = 0xFF << 8 | image->data[j++]; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1099 } |
| 38 | 1100 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1101 } |
| 38 | 1102 } |
| 1103 | |
| 1104 | |
| 1105 /* this is NOT fast nor optimized */ | |
| 1007 | 1106 void GFX_draw_pixel(GFX_DrawCfgScreen *hgfx, int16_t x, int16_t y, uint8_t color) |
| 38 | 1107 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1108 uint16_t* pDestination; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1109 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1110 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1111 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1112 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1113 pDestination = (uint16_t*)hgfx->FBStartAdress; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1114 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1115 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1116 pDestination += (800 - x) * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1117 pDestination += (480 - y); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1118 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1119 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1120 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1121 pDestination += x * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1122 pDestination += y; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1123 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1124 *(__IO uint16_t*)pDestination = 0xFF << 8 | color; |
| 38 | 1125 } |
| 1126 | |
| 1127 /* this is NOT fast nor optimized */ | |
| 1128 void GFX_draw_circle(GFX_DrawCfgScreen *hgfx, point_t center, uint8_t radius, int8_t color) | |
| 1129 { | |
| 1130 int x, y; | |
| 1131 int l; | |
| 1132 int r2, y2; | |
| 1133 int y2_new; | |
| 1134 int ty; | |
| 1135 | |
| 1136 /* cos pi/4 = 185363 / 2^18 (approx) */ | |
| 1137 l = (radius * 185363) >> 18; | |
| 1138 | |
| 1139 /* hw */ | |
| 1140 l += 1; | |
| 1141 | |
| 1142 /* At x=0, y=radius */ | |
| 1143 y = radius; | |
| 1144 | |
| 1145 r2 = y2 = y * y; | |
| 1146 ty = (2 * y) - 1; | |
| 1147 y2_new = r2 + 3; | |
| 1148 | |
| 1149 for (x = 0; x <= l; x++) { | |
| 1150 y2_new -= (2 * x) - 3; | |
| 1151 | |
| 1152 if ((y2 - y2_new) >= ty) { | |
| 1153 y2 -= ty; | |
| 1154 y -= 1; | |
| 1155 ty -= 2; | |
| 1156 } | |
| 1157 | |
| 1158 GFX_draw_pixel (hgfx, x + center.x, y + center.y, color); | |
| 1159 GFX_draw_pixel (hgfx, x + center.x, -y + center.y, color); | |
| 1160 GFX_draw_pixel (hgfx, -x + center.x, y + center.y, color); | |
| 1161 GFX_draw_pixel (hgfx, -x + center.x, -y + center.y, color); | |
| 1162 | |
| 1163 GFX_draw_pixel (hgfx, y + center.x, x + center.y, color); | |
| 1164 GFX_draw_pixel (hgfx, y + center.x, -x + center.y, color); | |
| 1165 GFX_draw_pixel (hgfx, -y + center.x, x + center.y, color); | |
| 1166 GFX_draw_pixel (hgfx, -y + center.x, -x + center.y, color); | |
| 1167 } | |
| 1168 } | |
| 1169 | |
| 1170 | |
| 1171 void GFX_draw_colorline(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) | |
| 1172 { | |
| 1173 uint32_t pDestination; | |
| 1174 uint32_t j; | |
| 1175 uint32_t temp; | |
| 1176 | |
| 1177 if(start.x == stop.x) | |
| 1178 { | |
| 1179 if(stop.y < start.y) | |
| 1180 { | |
| 1181 temp = stop.y; | |
| 1182 stop.y = start.y; | |
| 1183 start.y = temp; | |
| 1184 } | |
| 1185 pDestination = (uint32_t)hgfx->FBStartAdress; | |
| 1186 pDestination += start.x * hgfx->ImageHeight * 2; | |
| 1187 pDestination += start.y * 2; | |
| 1188 for (j = stop.y - start.y; j > 0; j--) | |
| 1189 { | |
| 1190 *(__IO uint8_t*)pDestination = color; | |
| 1191 pDestination += 1; | |
| 1192 *(__IO uint8_t*)pDestination = 0xFF; | |
| 1193 pDestination += 1; | |
| 1194 } | |
| 1195 } | |
| 1196 else | |
| 1197 if(start.y == stop.y) | |
| 1198 { | |
| 1199 if(stop.x < start.x) | |
| 1200 { | |
| 1201 temp = stop.x; | |
| 1202 stop.x = start.x; | |
| 1203 start.x = temp; | |
| 1204 } | |
| 1205 pDestination = (uint32_t)hgfx->FBStartAdress; | |
| 1206 pDestination += start.x * hgfx->ImageHeight * 2; | |
| 1207 pDestination += start.y * 2; | |
| 1208 for (j = stop.x - start.x; j > 0; j--) | |
| 1209 { | |
| 1210 *(__IO uint8_t*)pDestination = color; | |
| 1211 pDestination += 1; | |
| 1212 *(__IO uint8_t*)pDestination = 0xFF; | |
| 1213 pDestination -= 1; | |
| 1214 pDestination += hgfx->ImageHeight * 2; | |
| 1215 } | |
| 1216 } | |
| 1217 else // diagonal Bresenham's_line_algorithm | |
| 1218 { | |
| 1219 int x0 = start.x; | |
| 1220 int y0 = start.y; | |
| 1221 int x1 = stop.x; | |
| 1222 int y1 = stop.y; | |
| 1223 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; | |
| 1224 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; | |
| 1225 int err = (dx>dy ? dx : -dy)/2, e2; | |
| 1226 | |
| 1227 for(;;) | |
| 1228 { | |
| 1229 pDestination = (uint32_t)hgfx->FBStartAdress; | |
| 1230 pDestination += ((x0 * hgfx->ImageHeight) + y0) * 2; | |
| 1231 *(__IO uint8_t*)pDestination = color; | |
| 1232 pDestination += 1; | |
| 1233 *(__IO uint8_t*)pDestination = 0xFF; | |
| 1234 if (x0==x1 && y0==y1) break; | |
| 1235 e2 = err; | |
| 1236 if (e2 >-dx) { err -= dy; x0 += sx; } | |
| 1237 if (e2 < dy) { err += dx; y0 += sy; } | |
| 1238 } | |
| 1239 } | |
| 1240 } | |
| 1241 | |
| 1242 | |
| 1243 void GFX_draw_Grid(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, int vlines, float vdeltaline, int hlines, float hdeltalines, uint8_t color) | |
| 1244 { | |
| 1245 point_t p1; | |
| 1246 point_t p2; | |
| 1247 int winthight = window.bottom - window.top; | |
| 1248 int winwidth = window.right - window.left; | |
| 1249 float deltaline = 0; | |
| 1250 | |
| 1251 if(vlines > 0) | |
| 1252 { | |
| 1253 deltaline = ((float)winwidth) /vlines; | |
| 1254 | |
| 1255 p1.y = 479 - window.top; | |
| 1256 p2.y = 479 - window.bottom; | |
| 1257 for(int i = 0; i <= vlines; i++) | |
| 1258 { | |
| 1259 p1.x = window.left + (int)(i * deltaline + 0.5f); | |
| 1260 p2.x = p1.x ; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1261 //GFX_draw_colorline(hgfx, p1,p2, color ); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1262 GFX_draw_line(hgfx, p1,p2, color ); |
| 38 | 1263 } |
| 1264 } | |
| 1265 if(vdeltaline > 0) | |
| 1266 { | |
| 1267 p1.y = 479 - window.top; | |
| 1268 p2.y = 479 - window.bottom; | |
| 1269 for(int i = 0; i < winwidth/vdeltaline; i++) | |
| 1270 { | |
| 1271 p1.x = window.left + (int)(i * vdeltaline + 0.5f); | |
| 1272 p2.x = p1.x ; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1273 // GFX_draw_colorline(hgfx, p1,p2, color ); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1274 GFX_draw_line(hgfx, p1,p2, color ); |
| 38 | 1275 } |
| 1276 } | |
| 1277 if(hlines > 0) | |
| 1278 { | |
| 1279 deltaline = ((float)winthight)/hlines; | |
| 1280 p1.x = window.left; | |
| 1281 p2.x = window.right; | |
| 1282 for(int i = 0; i <= hlines; i++) | |
| 1283 { | |
| 1284 p1.y = 479 - window.top - (int)(i * deltaline + 0.5f); | |
| 1285 p2.y = p1.y; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1286 // GFX_draw_colorline(hgfx, p1,p2, color ); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1287 GFX_draw_line(hgfx, p1,p2, color ); |
| 38 | 1288 } |
| 1289 } | |
| 1290 } | |
| 1291 | |
| 1292 // =============================================================================== | |
| 1293 // GFX_graph_print | |
| 1294 /// @brief Print all those nice curves, especially in logbook und miniLiveLogGraph | |
| 1295 /// @version 0.0.2 hw 160519 | |
| 1296 /// | |
| 1297 /// 151022 hw -bug fix | |
| 1298 /// - die aktuelle Version macht keine Linien mehr �ber die gesamte Bildschirmh�he. | |
| 1299 /// - daf�r sind L�cher in der Kurve (z.B. Temperaturgraph Tauchgang Matthias 17.10.15 15:19) | |
| 1300 /// | |
| 1301 /// more details about range can be found in show_logbook_logbook_show_log_page2() - temperature graph | |
| 1302 /// | |
| 1303 /// @param window: top and bottom is only the range used by the data of the graph, not the entire screen / scale | |
| 1304 /// @param drawVeilUntil: ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe | |
| 1305 /// @param Xdivide: wird bisher nichr benutzt. | |
| 1306 // =============================================================================== | |
| 1307 | |
| 1308 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1309 void GFX_graph_print(GFX_DrawCfgScreen *hgfx, const SWindowGimpStyle *window, const int16_t drawVeilUntil, uint8_t Xdivide, uint16_t dataMin, uint16_t dataMax, uint16_t *data, uint16_t datalength, uint8_t color, uint8_t *colour_data) |
| 38 | 1310 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1311 uint16_t* pDestination_tmp; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1312 uint16_t* pDestination_start; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1313 uint16_t* pDestination_end; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1314 uint16_t* pDestination_zero_veil; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1315 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1316 SSettings* pSettings; |
| 38 | 1317 |
| 1318 uint32_t max = 0; | |
| 1319 int windowheight = -1; | |
| 1320 int windowwidth = -1; | |
| 1321 int i = -1; | |
| 1322 int w1 = -1; | |
| 1323 int w2 = -1; | |
| 1324 | |
| 1325 uint32_t h_ulong = 0; | |
| 1326 uint32_t h_ulong_old = 0; | |
| 1327 _Bool invert = 0; | |
| 1328 | |
| 1329 uint16_t dataDelta = 0; | |
| 1330 uint16_t dataDeltaHalve = 0; | |
| 1331 uint16_t dataTemp = 0; | |
| 1332 | |
| 1333 uint8_t colorDataTemp; | |
| 1334 uint8_t colormask = 0; | |
| 1335 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1336 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1337 pDestination_zero_veil = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1338 |
| 38 | 1339 if(dataMin > dataMax) |
| 1340 { | |
| 1341 uint16_t dataFlip; | |
| 1342 dataFlip = dataMin; | |
| 1343 dataMin = dataMax; | |
| 1344 dataMax = dataFlip; | |
| 1345 invert = 1; | |
| 1346 } | |
| 1347 else | |
| 1348 invert = 0; | |
| 1349 | |
| 1350 colormask = color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1351 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1352 pSettings = settingsGetPointer(); |
| 38 | 1353 |
| 1354 if(window->bottom > 479) | |
| 1355 return; | |
| 1356 if(window->top > 479) | |
| 1357 return; | |
| 1358 if(window->right > 799) | |
| 1359 return; | |
| 1360 if(window->left > 799) | |
| 1361 return; | |
| 1362 if(window->bottom < 0) | |
| 1363 return; | |
| 1364 if(window->top < 0) | |
| 1365 return; | |
| 1366 if(window->right < 0) | |
| 1367 return; | |
| 1368 if(window->left < 0) | |
| 1369 return; | |
| 1370 if(window->bottom <= window->top) | |
| 1371 return; | |
| 1372 if(window->right <= window->left) | |
| 1373 return; | |
| 1374 | |
| 1375 windowheight = window->bottom - window->top ; | |
| 1376 windowwidth = window->right - window->left; | |
| 1377 w1 = 0; | |
| 1378 w2 = 0; | |
| 1379 if(dataMax == dataMin) | |
| 1380 dataMax++; | |
| 1381 dataDelta = (unsigned long)(dataMax - dataMin); | |
| 1382 dataDeltaHalve = dataDelta / 2; | |
|
296
87f83879cecb
Possible bugfix: do not use bitwise and (&)
Jan Mulder <jlmulder@xs4all.nl>
parents:
121
diff
changeset
|
1383 while((w1 <= windowwidth) && (w2 < datalength)) |
| 38 | 1384 { |
| 1385 int tmp = (10 * w1 * (long)datalength)/windowwidth; | |
| 1386 w2 = tmp/10; | |
| 1387 int rest = tmp - w2*10; | |
| 1388 if(rest >= 5) | |
| 1389 w2++; | |
| 1390 | |
| 1391 if((datalength - 1) < w2) | |
| 1392 w2 = datalength-1; | |
| 1393 | |
| 1394 if(colour_data != NULL) | |
| 1395 { | |
| 1396 colorDataTemp = colour_data[w2]; | |
| 1397 colormask = color + colorDataTemp; | |
| 1398 } | |
| 1399 | |
| 1400 dataTemp = data[w2]; | |
| 1401 if(Xdivide > 1) | |
| 1402 { | |
| 1403 w2++; | |
| 1404 for(i=1;i<Xdivide;i++) | |
| 1405 { | |
| 1406 if(data[w2]>dataTemp) | |
| 1407 dataTemp = data[w2]; | |
| 1408 w2++; | |
| 1409 } | |
| 1410 } | |
| 1411 | |
| 1412 if(dataTemp > dataMin) | |
| 1413 dataTemp -= dataMin; | |
| 1414 else | |
| 1415 dataTemp = 0; | |
| 1416 | |
| 1417 if(invert) | |
| 1418 { | |
| 1419 if(dataTemp < dataDelta) | |
| 1420 dataTemp = dataDelta - dataTemp; | |
| 1421 else | |
| 1422 dataTemp = 0; | |
| 1423 } | |
| 1424 | |
| 1425 h_ulong = (unsigned long)dataTemp; | |
| 1426 h_ulong *= windowheight; | |
| 1427 h_ulong += dataDeltaHalve; | |
| 1428 h_ulong /= dataDelta; | |
| 1429 | |
| 1430 if(h_ulong > (window->bottom - window->top)) | |
| 1431 h_ulong = (window->bottom - window->top); | |
| 1432 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1433 if(!pSettings->FlipDisplay) |
| 38 | 1434 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1435 if(drawVeilUntil > 0) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1436 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1437 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1438 pDestination_zero_veil += ((479 - (drawVeilUntil - 2) ) + ((w1 + window->left) * hgfx->ImageHeight) ); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1439 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1440 else if(drawVeilUntil < 0 ) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1441 { |
| 114 | 1442 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1443 pDestination_zero_veil += ((479 + (drawVeilUntil)) + ((w1 + window->left) * hgfx->ImageHeight) ); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1444 } |
| 38 | 1445 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1446 else |
| 38 | 1447 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1448 if(drawVeilUntil > 0) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1449 { |
| 114 | 1450 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1451 pDestination_zero_veil += (((drawVeilUntil) ) + ( (window->right - w1) * hgfx->ImageHeight) ); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1452 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1453 else if(drawVeilUntil < 0 ) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1454 { |
| 114 | 1455 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1456 pDestination_zero_veil += 479 - drawVeilUntil + ( (window->right - w1 -1) * hgfx->ImageHeight); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1457 } |
| 38 | 1458 } |
| 1459 if(h_ulong + window->top > max) | |
| 1460 { | |
| 1461 max = h_ulong + window->top; | |
| 1462 } | |
| 1463 | |
| 1464 // hw 160519 wof�r ist das? Damit funktioniert Temperatur 25,5�C nicht! | |
| 1465 // if((dataMax == 255) || (data[w2] != 255)) | |
| 1466 // { | |
| 1467 //output_content[pointer] = colormask; | |
| 1468 //output_mask[pointer] = true; | |
|
593
3a6f922b73ea
Added PrintGraph option to skip invalid data entries:
Ideenmodellierer
parents:
583
diff
changeset
|
1469 if(dataTemp != 0xFFFF) /* do not draw invalid data pixels */ |
|
3a6f922b73ea
Added PrintGraph option to skip invalid data entries:
Ideenmodellierer
parents:
583
diff
changeset
|
1470 { |
| 38 | 1471 if(w1 > 0) |
| 1472 { | |
| 114 | 1473 pDestination_start = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1474 if(!pSettings->FlipDisplay) |
| 38 | 1475 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1476 pDestination_start += (((479 - (window->top)) + ((w1 + window->left) * hgfx->ImageHeight))); |
| 38 | 1477 } |
| 1478 else | |
| 1479 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1480 pDestination_start += (((window->top) + ((window->right - w1) * hgfx->ImageHeight))); |
| 38 | 1481 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1482 pDestination_end = pDestination_start; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1483 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1484 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1485 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1486 if(h_ulong >= h_ulong_old) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1487 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1488 pDestination_start -= h_ulong_old; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1489 pDestination_end -= h_ulong; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1490 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1491 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1492 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1493 pDestination_start -= h_ulong; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1494 pDestination_end -= h_ulong_old; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1495 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1496 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1497 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1498 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1499 if(h_ulong < h_ulong_old) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1500 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1501 pDestination_start += h_ulong_old; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1502 pDestination_end += h_ulong; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1503 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1504 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1505 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1506 pDestination_start += h_ulong; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1507 pDestination_end += h_ulong_old; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1508 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1509 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1510 |
| 38 | 1511 |
| 1512 // deco stops | |
| 1513 if(drawVeilUntil < 0) | |
| 1514 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1515 if(!pSettings->FlipDisplay) |
| 38 | 1516 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1517 pDestination_tmp = pDestination_end; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1518 while(pDestination_tmp <= pDestination_zero_veil) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1519 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1520 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1521 pDestination_tmp++; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1522 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1523 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1524 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1525 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1526 pDestination_tmp = pDestination_zero_veil; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1527 while(pDestination_tmp <= pDestination_end) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1528 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1529 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1530 pDestination_tmp++; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1531 } |
| 38 | 1532 } |
| 1533 } | |
| 1534 else | |
| 1535 { | |
| 1536 // regular graph with veil underneath if requested | |
| 1537 // von oben nach unten | |
| 1538 // von grossen pDestination Werten zu kleinen pDestination Werten | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1539 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1540 pDestination_tmp = pDestination_start; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1541 while(pDestination_tmp >= pDestination_end) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1542 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1543 *(__IO uint16_t*)pDestination_tmp = (0xFF << 8) | colormask ; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1544 pDestination_tmp--; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1545 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1546 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1547 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1548 if(!pSettings->FlipDisplay) |
| 38 | 1549 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1550 while((drawVeilUntil > 0) && (pDestination_tmp >= pDestination_zero_veil)) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1551 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1552 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1553 pDestination_tmp--; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1554 } |
| 38 | 1555 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1556 else |
| 38 | 1557 { |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1558 pDestination_tmp = pDestination_start; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1559 while((drawVeilUntil > 0) && (pDestination_tmp <= pDestination_zero_veil)) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1560 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1561 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1562 pDestination_tmp++; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1563 } |
| 38 | 1564 } |
| 1565 } | |
| 1566 } | |
| 1567 h_ulong_old = h_ulong; | |
|
593
3a6f922b73ea
Added PrintGraph option to skip invalid data entries:
Ideenmodellierer
parents:
583
diff
changeset
|
1568 } |
| 38 | 1569 w1++; |
| 1570 w2++; | |
| 1571 } | |
| 1572 } | |
| 1573 | |
| 1574 | |
| 1575 void GFX_draw_header(GFX_DrawCfgScreen *hgfx, uint8_t colorId) | |
| 1576 { | |
| 1577 uint32_t pDestination; | |
| 1578 point_t start, stop, now; | |
| 1579 uint8_t alpha; | |
| 1580 | |
| 1581 /* display coordinate system */ | |
| 1582 start.y = 400; | |
| 1583 stop.y = 479; | |
| 1584 | |
| 1585 start.x = 0; | |
| 1586 stop.x = 799; | |
| 1587 | |
| 1588 now.y = start.y; | |
| 1589 now.x = start.x; | |
| 1590 | |
| 1591 while (now.x <= stop.x) | |
| 1592 { | |
| 1593 now.y = start.y; | |
| 1594 pDestination = (uint32_t)hgfx->FBStartAdress; | |
| 1595 pDestination += now.x * hgfx->ImageHeight * 2; | |
| 1596 pDestination += now.y * 2; | |
| 1597 now.x += 1; | |
| 1598 | |
| 1599 alpha = 27; | |
| 1600 while(alpha < 246) | |
| 1601 { | |
| 1602 alpha += 9; | |
| 1603 *(__IO uint8_t*)pDestination = colorId; | |
| 1604 pDestination += 1; | |
| 1605 *(__IO uint8_t*)pDestination = alpha; | |
| 1606 pDestination += 1; | |
| 1607 now.y += 1; | |
| 1608 } | |
| 1609 | |
| 1610 while(now.y <= stop.y) | |
| 1611 { | |
| 1612 *(__IO uint8_t*)pDestination = colorId; | |
| 1613 pDestination += 1; | |
| 1614 *(__IO uint8_t*)pDestination = 0xFF; | |
| 1615 pDestination += 1; | |
| 1616 now.y += 1; | |
| 1617 } | |
| 1618 } | |
| 1619 } | |
| 1620 | |
| 1621 void GFX_draw_box2(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color, uint8_t roundCorners) | |
| 1622 { | |
| 1623 point_t point2, point4; | |
| 1624 | |
| 1625 if(roundCorners) | |
| 1626 { | |
| 1627 point2.x = stop.x - start.x; | |
| 1628 point2.y = stop.y - start.y; | |
| 1629 GFX_draw_box(hgfx,start,point2,1,color); | |
| 1630 } | |
| 1631 else | |
| 1632 { | |
| 1633 point2.x = stop.x; | |
| 1634 point2.y = start.y; | |
| 1635 | |
| 1636 point4.x = start.x; | |
| 1637 point4.y = stop.y; | |
| 1638 | |
| 1639 GFX_draw_line(hgfx,start,point2,color); | |
| 1640 GFX_draw_line(hgfx,point2,stop,color); | |
| 1641 GFX_draw_line(hgfx,stop,point4,color); | |
| 1642 GFX_draw_line(hgfx,point4,start,color); | |
| 1643 } | |
| 1644 } | |
| 1645 | |
| 1646 void GFX_draw_box(GFX_DrawCfgScreen *hgfx, point_t LeftLow, point_t WidthHeight, uint8_t Style, uint8_t color) | |
| 1647 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1648 uint16_t* pDestination; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1649 uint16_t* pStart; |
| 38 | 1650 uint32_t j; |
| 1651 uint32_t lineWidth, lineHeight; | |
| 1652 int x, y; | |
| 1653 uint8_t intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1654 int stepdir; |
| 38 | 1655 |
| 1656 typedef struct { | |
| 1657 int x; | |
| 1658 int y; | |
| 1659 uint8_t intensity; | |
| 1660 } corner_t; | |
| 1661 const corner_t corner[16] = { | |
| 1662 {3,3,255}, // nur einmal | |
| 1663 {9,0,242}, | |
| 1664 {8,0,194}, | |
| 1665 {7,0,115}, | |
| 1666 {6,0,36}, | |
| 1667 {9,1,33}, | |
| 1668 {8,1,84}, | |
| 1669 {7,1,161}, | |
| 1670 {6,1,255}, | |
| 1671 {5,1,242}, | |
| 1672 {4,1,36}, | |
| 1673 {6,2,33}, | |
| 1674 {5,2,84}, | |
| 1675 {4,2,255}, | |
| 1676 {3,2,84}, | |
| 1677 {4,3,110} | |
| 1678 }; | |
| 1679 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1680 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1681 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1682 |
| 38 | 1683 lineWidth = WidthHeight.x; |
| 1684 lineHeight = WidthHeight.y; | |
| 114 | 1685 pStart = (uint16_t*)hgfx->FBStartAdress; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1686 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1687 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1688 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1689 pStart += LeftLow.x * hgfx->ImageHeight; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1690 pStart += LeftLow.y; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1691 stepdir = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1692 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1693 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1694 { |
| 622 | 1695 pStart += (799 - LeftLow.x) * hgfx->ImageHeight; |
| 1696 pStart += (479 - LeftLow.y); | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1697 stepdir = -1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1698 } |
| 38 | 1699 |
| 1700 // Untere Linie | |
| 1701 pDestination = pStart; | |
| 1702 if(Style) | |
| 1703 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1704 pDestination += stepdir * 10 * hgfx->ImageHeight; |
| 38 | 1705 lineWidth -= 18; |
| 1706 } | |
| 1707 for (j = lineWidth; j > 0; j--) | |
| 1708 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1709 |
| 38 | 1710 *(__IO uint16_t*)pDestination = 0xFF00 + color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1711 pDestination += stepdir * hgfx->ImageHeight; |
| 38 | 1712 } |
| 1713 | |
| 1714 // Obere Linie | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1715 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1716 pDestination = pStart + stepdir * WidthHeight.y; |
| 38 | 1717 if(Style) |
| 1718 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1719 pDestination += stepdir * 10 * hgfx->ImageHeight; |
| 38 | 1720 } |
| 1721 | |
| 1722 for (j = lineWidth; j > 0; j--) | |
| 1723 { | |
| 1724 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1725 pDestination += stepdir * hgfx->ImageHeight; |
| 38 | 1726 } |
| 1727 | |
| 1728 // Linke Linie | |
| 1729 pDestination = pStart; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1730 |
| 38 | 1731 if(Style) |
| 1732 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1733 pDestination += stepdir * 10; |
| 38 | 1734 lineHeight -= 18; |
| 1735 } | |
| 1736 | |
| 1737 for (j = lineHeight; j > 0; j--) | |
| 1738 { | |
| 1739 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1740 pDestination += stepdir; |
| 38 | 1741 } |
| 1742 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1743 |
| 38 | 1744 // Rechte Linie |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1745 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1746 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight; |
| 38 | 1747 if(Style) |
| 1748 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1749 pDestination += stepdir * 10; |
| 38 | 1750 } |
| 1751 | |
| 1752 for (j = lineHeight; j > 0; j--) | |
| 1753 { | |
| 1754 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1755 pDestination += stepdir; |
| 38 | 1756 } |
| 1757 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1758 |
| 38 | 1759 // Ecken wenn notwendig == Style |
| 1760 if(Style) | |
| 1761 { | |
| 1762 // links unten | |
| 1763 pDestination = pStart; | |
| 1764 x = corner[0].x; | |
| 1765 y = corner[0].y; | |
| 1766 intensity = corner[0].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1767 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1768 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1769 |
| 1770 for(j = 15; j > 0; j--) | |
| 1771 { | |
| 1772 x = corner[j].x; | |
| 1773 y = corner[j].y; | |
| 1774 intensity = corner[j].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1775 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1776 *(__IO uint16_t*)(pDestination + stepdir * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1777 } |
| 1778 // links oben | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1779 pDestination = pStart + stepdir * WidthHeight.y; |
| 38 | 1780 x = corner[0].x; |
| 1781 y = corner[0].y; | |
| 1782 intensity = corner[0].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1783 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1784 |
| 1785 for(j = 15; j > 0; j--) | |
| 1786 { | |
| 1787 x = corner[j].x; | |
| 1788 y = corner[j].y; | |
| 1789 intensity = corner[j].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1790 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1791 *(__IO uint16_t*)(pDestination + stepdir * (-x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1792 } |
| 1793 // rechts unten | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1794 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight; |
| 38 | 1795 x = corner[0].x; |
| 1796 y = corner[0].y; | |
| 1797 intensity = corner[0].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1798 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1799 |
| 1800 for(j = 15; j > 0; j--) | |
| 1801 { | |
| 1802 x = corner[j].x; | |
| 1803 y = corner[j].y; | |
| 1804 intensity = corner[j].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1805 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1806 *(__IO uint16_t*)(pDestination + stepdir * (x - (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1807 } |
| 1808 // rechts oben | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1809 pDestination = pStart + stepdir * WidthHeight.y + stepdir * WidthHeight.x * hgfx->ImageHeight; |
| 38 | 1810 x = corner[0].x; |
| 1811 y = corner[0].y; | |
| 1812 intensity = corner[0].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1813 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1814 |
| 1815 for(j = 15; j > 0; j--) | |
| 1816 { | |
| 1817 x = corner[j].x; | |
| 1818 y = corner[j].y; | |
| 1819 intensity = corner[j].intensity; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1820 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1821 *(__IO uint16_t*)(pDestination + stepdir * -1 * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
| 38 | 1822 } |
| 1823 } | |
| 1824 } | |
| 1825 | |
| 1826 | |
| 1827 /** | |
| 1828 ****************************************************************************** | |
| 1829 * @brief GFX write label. / Write string with defined color | |
| 1830 * @author heinrichs weikamp gmbh | |
| 1831 * @version V0.0.1 | |
| 1832 * @date 07-July-2014 | |
| 1833 ****************************************************************************** | |
| 1834 * | |
| 1835 * @param hgfx: check gfx_engine.h. | |
| 1836 * @param color: 16bit Alpha+CLUT. | |
| 1837 * @retval None | |
| 1838 */ | |
| 1839 | |
| 1840 uint32_t GFX_write_label(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint8_t color) | |
| 1841 { | |
| 1842 return GFX_write_string_color(Font, hgfx, pText, 0, color); | |
| 1843 } | |
| 1844 | |
| 1845 | |
| 1846 /** | |
| 1847 ****************************************************************************** | |
| 870 | 1848 * @brief GFX writeGfx_write_label_varstring. / Write string with all parameters and font color options |
| 1849 heinrichs weikamp gmbh | |
| 38 | 1850 * @version V0.0.1 |
| 1851 * @date 22-April-2014 | |
| 1852 ****************************************************************************** | |
| 1853 * | |
| 1854 * @param XleftGimpStyle: | |
| 1855 * @param XrightGimpStyle: | |
| 1856 * @param YtopGimpStyle: | |
| 1857 * @param color: | |
| 1858 * @param tFont: | |
| 1859 * @param text: text to be printed | |
| 1860 * @retval None | |
| 1861 */ | |
| 1862 | |
| 1863 void Gfx_write_label_var(GFX_DrawCfgScreen *screenInput, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const uint8_t color, const char *text) | |
| 1864 { | |
| 1865 | |
| 1866 GFX_DrawCfgWindow hgfx; | |
| 1867 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1868 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1869 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1870 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1871 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1872 |
| 38 | 1873 if(XrightGimpStyle > 799) |
| 1874 XrightGimpStyle = 799; | |
| 1875 if(XleftGimpStyle >= XrightGimpStyle) | |
| 1876 XleftGimpStyle = 0; | |
| 1877 if(YtopGimpStyle > 479) | |
| 1878 YtopGimpStyle = 479; | |
| 1879 hgfx.Image = screenInput; | |
| 1880 hgfx.WindowNumberOfTextLines = 1; | |
| 1881 hgfx.WindowLineSpacing = 0; | |
| 1882 hgfx.WindowTab = 0; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1883 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1884 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1885 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1886 hgfx.WindowX0 = XleftGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1887 hgfx.WindowX1 = XrightGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1888 hgfx.WindowY1 = 479 - YtopGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1889 if(hgfx.WindowY1 < Font->height) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1890 hgfx.WindowY0 = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1891 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1892 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1893 } |
| 38 | 1894 else |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1895 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1896 hgfx.WindowX0 = 800 - XrightGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1897 hgfx.WindowX1 = 800 - XleftGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1898 hgfx.WindowY0 = YtopGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1899 if(hgfx.WindowY0 + Font->height > 480) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1900 hgfx.WindowY1 = 480; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1901 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1902 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1903 } |
| 38 | 1904 GFX_write_label(Font, &hgfx, text, color); |
| 1905 } | |
| 1906 | |
| 1907 /** | |
| 1908 ****************************************************************************** | |
| 1909 * @brief GFX write string. / Write string with all parameters and font options | |
| 1910 * @author heinrichs weikamp gmbh | |
| 1911 * @version V0.0.1 | |
| 1912 * @date 22-April-2014 | |
| 1913 ****************************************************************************** | |
| 1914 * | |
| 1915 * @param hgfx: check gfx_engine.h. | |
| 1916 * @param color: 32bit ARGB8888. | |
| 1917 * @retval None | |
| 1918 */ | |
| 1919 | |
| 1920 uint16_t GFX_return_offset(const tFont *Font, char *pText, uint8_t position) | |
| 1921 { | |
| 1922 char character; | |
| 1923 uint16_t digit, i; | |
| 1924 uint8_t found; | |
| 1925 uint16_t distance; | |
| 1926 | |
| 1927 if(position == 0) | |
| 1928 return 0; | |
| 1929 | |
| 1930 distance = 0; | |
| 1931 for(digit = 0; digit < position; digit++) | |
| 1932 { | |
| 1933 character = pText[digit]; | |
| 1934 if(character == 0) | |
| 1935 return 0; | |
| 1936 | |
| 1937 found = 0; | |
| 1938 for(i=0;i<Font->length;i++) | |
| 1939 { | |
| 1940 if(Font->chars[i].code == character) | |
| 1941 { | |
| 1942 found = 1; | |
| 1943 break; | |
| 1944 } | |
| 1945 } | |
| 1946 if(found) | |
| 1947 { | |
| 1948 distance += (uint16_t)(Font->chars[i].image->width); | |
| 1949 if(Font == &FontT144) | |
| 1950 distance += 3; | |
| 1951 else | |
| 1952 if(Font == &FontT105) | |
| 1953 distance += 2; | |
| 1954 } | |
| 1955 } | |
| 1956 return distance; | |
| 1957 | |
| 1958 /* FEHLT: | |
| 1959 if(*pText < ' ') | |
| 1960 if((*pText) & 0x80) | |
| 1961 | |
| 1962 if(((tFont *)settings.font == &FontT105) && settings.dualFont && ((*pText == '.') || (*pText == ':'))) | |
| 1963 settings.font = (uint32_t)&FontT54; | |
| 1964 */ | |
| 1965 } | |
| 1966 | |
| 1967 void GFX_clean_line(GFX_DrawCfgWindow* hgfx, uint32_t line_number) | |
| 1968 { | |
| 1969 uint16_t height; | |
| 1970 uint32_t pDestination, i, j; | |
| 1971 uint16_t left, width, bottom, nextlineStep; | |
| 1972 | |
| 1973 bottom = hgfx->WindowY0; | |
| 1974 | |
| 1975 if(hgfx->WindowNumberOfTextLines && line_number && (line_number <= hgfx->WindowNumberOfTextLines)) | |
| 1976 { | |
| 1977 bottom += hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number); | |
| 1978 height = hgfx->WindowLineSpacing; | |
| 1979 } | |
| 1980 else | |
| 1981 { | |
| 1982 height = 1 + hgfx->WindowY1 - bottom; | |
| 1983 } | |
| 1984 | |
| 1985 pDestination = (uint32_t)hgfx->Image->FBStartAdress; | |
| 1986 | |
| 1987 left = hgfx->WindowX0; | |
| 1988 width = 1 + hgfx->WindowX1 - left; | |
| 1989 nextlineStep = hgfx->Image->ImageHeight - height; | |
| 1990 nextlineStep *= 2; | |
| 1991 pDestination += 2 * bottom; | |
| 1992 pDestination += 2 * hgfx->Image->ImageHeight * left; | |
| 1993 | |
| 1994 for(j = width; j > 0; j--) | |
| 1995 { | |
| 1996 for(i = height; i > 0; i--) | |
| 1997 { | |
| 1998 *(__IO uint16_t*)pDestination = 0; | |
| 1999 pDestination += 2; | |
| 2000 } | |
| 2001 pDestination += nextlineStep; | |
| 2002 } | |
| 2003 } | |
| 2004 | |
| 2005 | |
| 2006 void GFX_clean_area(GFX_DrawCfgScreen *tMscreen, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, uint16_t YBottomGimpStyle) | |
| 2007 { | |
| 2008 uint16_t height; | |
| 2009 uint32_t pDestination, i, j; | |
| 2010 int32_t left, width, bottom, nextlineStep; | |
| 2011 | |
| 2012 bottom = tMscreen->ImageHeight - YBottomGimpStyle; | |
| 2013 height = 1 + YBottomGimpStyle - YtopGimpStyle; | |
| 2014 | |
| 2015 if(bottom < 0) | |
| 2016 bottom = 0; | |
| 2017 if(height > tMscreen->ImageHeight) | |
| 2018 height = tMscreen->ImageHeight; | |
| 2019 | |
| 2020 pDestination = tMscreen->FBStartAdress; | |
| 2021 | |
| 2022 left = XleftGimpStyle; | |
| 2023 width = 1 + XrightGimpStyle - left; | |
| 2024 if(width < 1) | |
| 2025 width = 1; | |
| 2026 | |
| 2027 if(width > tMscreen->ImageWidth) | |
| 2028 width = tMscreen->ImageWidth; | |
| 2029 | |
| 2030 nextlineStep = tMscreen->ImageHeight - height; | |
| 2031 nextlineStep *= 2; | |
| 2032 pDestination += 2 * bottom; | |
| 2033 pDestination += 2 * tMscreen->ImageHeight * left; | |
| 2034 | |
| 2035 for(j = width; j > 0; j--) | |
| 2036 { | |
| 2037 for(i = height; i > 0; i--) | |
| 2038 { | |
| 2039 *(__IO uint16_t*)pDestination = 0; | |
| 2040 pDestination += 2; | |
| 2041 } | |
| 2042 pDestination += nextlineStep; | |
| 2043 } | |
| 2044 } | |
| 2045 | |
| 2046 | |
| 2047 uint32_t GFX_write_string(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint32_t line_number) | |
| 2048 { | |
| 2049 return GFX_write_string_color(Font, hgfx, pText, line_number, 0); | |
| 2050 } | |
| 2051 | |
| 2052 uint32_t GFX_write_string_color(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint32_t line_number, uint8_t color) | |
| 2053 { | |
| 2054 if(hgfx->Image->FBStartAdress < FBGlobalStart) | |
| 2055 return 0; | |
| 2056 | |
| 2057 GFX_CfgWriteString settings; | |
| 2058 uint32_t newXdelta; | |
| 2059 uint8_t minimal = 0; | |
| 2060 // uint32_t try_again; | |
| 2061 | |
| 2062 if(hgfx->WindowNumberOfTextLines && line_number && (line_number <= hgfx->WindowNumberOfTextLines)) | |
| 2063 { | |
| 2064 settings.Ydelta = hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number); | |
| 2065 } | |
| 2066 else | |
| 2067 { | |
| 2068 settings.Ydelta = 0; | |
| 2069 } | |
| 2070 settings.font = (uint32_t)Font; | |
| 2071 settings.Xdelta = 0; | |
| 2072 settings.color = color; | |
| 2073 settings.invert = 0; | |
| 2074 settings.resize = 0; | |
| 2075 settings.dualFont = 0; | |
| 2076 settings.spaceMode = 0; | |
| 2077 settings.singleSpaceWithSizeOfNextChar = 0; | |
| 2078 settings.useTinyFont = 0; | |
| 2079 settings.TinyFontExtraYdelta = 0; | |
| 2080 settings.TinyFont = (uint32_t)Font; | |
| 2081 settings.doubleSize = 0; | |
| 2082 | |
| 2083 if((*pText) == TXT_MINIMAL) // for customtext and anything with Sonderzeichen | |
| 2084 minimal = 1; | |
| 2085 else | |
| 2086 minimal = 0; | |
| 2087 | |
| 2088 if(Font == &FontT144) | |
| 884 | 2089 { |
| 38 | 2090 settings.TinyFont = (uint32_t)&FontT84; |
| 884 | 2091 settings.Ydelta = 12; |
| 2092 } | |
| 38 | 2093 else |
| 2094 if(Font == &FontT105) | |
| 2095 settings.TinyFont = (uint32_t)&FontT54; | |
| 2096 else | |
| 2097 if(Font == &FontT54) | |
| 2098 { | |
| 2099 settings.TinyFont = (uint32_t)&FontT48; | |
| 2100 settings.TinyFontExtraYdelta = -9; | |
| 2101 } | |
| 2102 else | |
| 2103 if(Font == &FontT48) | |
| 2104 { | |
| 2105 settings.TinyFont = (uint32_t)&FontT24; | |
| 2106 settings.TinyFontExtraYdelta = 6; | |
| 2107 } | |
| 2108 else | |
| 2109 if(Font == &FontT42) | |
| 2110 { | |
| 2111 settings.TinyFont = (uint32_t)&FontT24; | |
| 2112 settings.TinyFontExtraYdelta = 2; | |
| 2113 } | |
| 2114 | |
| 2115 settings.actualFont = (tFont *)settings.font; | |
| 2116 | |
| 2117 while ((*pText != 0) && (settings.Xdelta != 0x0000FFFF))// und fehlend: Abfrage window / image size | |
| 2118 { | |
| 2119 // try_again = 0; | |
| 2120 | |
| 2121 if((*pText == '\177') && !minimal) | |
| 2122 { | |
| 2123 if(settings.singleSpaceWithSizeOfNextChar) | |
| 2124 { | |
| 2125 settings.singleSpaceWithSizeOfNextChar = 0; | |
| 2126 pText++; | |
| 2127 settings.Xdelta += *pText; | |
| 2128 } | |
| 2129 else | |
| 2130 settings.singleSpaceWithSizeOfNextChar = 1; | |
| 2131 } | |
| 2132 else | |
| 2133 if(*pText < ' ') | |
| 2134 { | |
| 2135 /* Xdelta -inline- changes */ | |
| 2136 if((*pText == '\t') && !minimal) | |
| 2137 settings.Xdelta = hgfx->WindowTab - hgfx->WindowX0; | |
| 2138 else | |
| 2139 if(*pText == '\r') // carriage return, no newline | |
| 2140 settings.Xdelta = 0; | |
| 2141 else | |
|
537
0ad0b26ec56b
Added center / right alignment option to custom text display:
Ideenmodellierer
parents:
509
diff
changeset
|
2142 if((*pText == '\001')) // center |
| 38 | 2143 settings.Xdelta = GFX_write__Modify_Xdelta__Centered(&settings, hgfx, pText+1); |
| 2144 else | |
|
537
0ad0b26ec56b
Added center / right alignment option to custom text display:
Ideenmodellierer
parents:
509
diff
changeset
|
2145 if((*pText == '\002')) // right |
| 38 | 2146 settings.Xdelta = GFX_write__Modify_Xdelta__RightAlign(&settings, hgfx, pText+1); |
| 2147 else | |
| 2148 if((*pText == '\003') && !minimal) // doubleSize | |
| 2149 settings.doubleSize = 1; | |
| 2150 else | |
| 2151 /* Xdelta -up/down changes */ | |
| 2152 if((*pText == '\f') && !minimal) // form feed = top align | |
| 2153 { | |
| 2154 if((hgfx->WindowY1 - hgfx->WindowY0) >= ((tFont *)settings.font)->height) | |
| 2155 { | |
| 2156 settings.Ydelta = hgfx->WindowY1 - hgfx->WindowY0; | |
| 2157 settings.Ydelta -= ((tFont *)settings.font)->height; | |
| 2158 } | |
| 2159 } | |
| 2160 else | |
| 2161 if(*pText == '\n') // newline, no carriage return | |
| 2162 { | |
| 2163 if(hgfx->WindowNumberOfTextLines && (line_number < hgfx->WindowNumberOfTextLines)) | |
| 2164 { | |
| 2165 line_number++; | |
| 2166 settings.Ydelta = hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number); | |
| 2167 } | |
| 2168 } | |
| 2169 else | |
| 2170 /* Font style changes */ | |
| 2171 if(*pText == '\a') | |
|
737
5071d554aaa5
NEW: Add mini compass with marker declination indication
heinrichsweikamp
parents:
705
diff
changeset
|
2172 settings.invert = settings.invert ? 0 : 1; |
| 38 | 2173 else |
| 2174 if((*pText == '\016') && !minimal) | |
| 2175 { | |
| 2176 if(settings.dualFont == 0) | |
| 2177 settings.dualFont = 1; | |
| 2178 else | |
| 2179 settings.actualFont = (tFont *)settings.TinyFont; | |
| 2180 } | |
| 2181 else | |
| 2182 if((*pText == '\017') && !minimal) | |
| 2183 { | |
| 2184 settings.dualFont = 0; | |
| 2185 settings.actualFont = (tFont *)settings.font; | |
| 2186 } | |
| 2187 else | |
| 874 | 2188 #ifndef BOOTLOADER_STANDALONE |
| 38 | 2189 if((*pText == '\005') && !minimal) |
| 2190 { | |
| 2191 newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48); | |
| 2192 settings.Xdelta = newXdelta; | |
| 2193 } | |
| 2194 else | |
| 2195 if((*pText == '\006') && !minimal) | |
| 2196 { | |
| 2197 newXdelta = GFX_write_char(hgfx, &settings, 'b', (tFont *)&Awe48); | |
| 2198 settings.Xdelta = newXdelta; | |
| 2199 } | |
| 2200 else | |
| 874 | 2201 #endif |
| 38 | 2202 if((*pText >= '\020') && (*pText <= '\032') && !minimal) |
| 2203 settings.color = *pText - '\020'; | |
| 2204 else | |
| 2205 if((*pText == '\034') && !minimal) | |
| 2206 settings.spaceMode = 1; | |
| 2207 else | |
| 2208 if((*pText == '\035') && !minimal) | |
| 2209 settings.spaceMode = 0; | |
| 2210 } | |
| 2211 else | |
| 2212 if(((*pText) == TXT_2BYTE) && !minimal) | |
| 2213 { | |
| 2214 pText++; | |
| 2215 settings.Xdelta = GFX_write_substring(&settings, hgfx, (uint8_t)TXT_2BYTE, (int8_t)*pText); | |
| 2216 } | |
| 2217 else | |
| 2218 if(((*pText) & 0x80) && !minimal) | |
| 2219 settings.Xdelta = GFX_write_substring(&settings, hgfx, (uint8_t)*pText, 0); | |
| 2220 else | |
| 2221 if(!settings.invert && (*pText == ' ')) | |
| 2222 { | |
| 2223 if(settings.spaceMode == 0) | |
| 2224 settings.Xdelta += ((tFont *)settings.font)->spacesize; | |
| 2225 else | |
| 2226 settings.Xdelta += ((tFont *)settings.font)->spacesize2Monospaced; | |
| 2227 } | |
| 2228 else | |
| 2229 if((settings.spaceMode == 1) && (*pText == ' ')) | |
| 2230 settings.Xdelta += ((tFont *)settings.font)->spacesize2Monospaced; | |
| 2231 else | |
| 2232 { | |
| 2233 if(((tFont *)settings.font == &FontT144) && ((*pText == '.') || (*pText == ':'))) | |
| 2234 settings.actualFont = (tFont *)settings.TinyFont; | |
| 2235 else | |
| 2236 if(((tFont *)settings.font == &FontT105) && settings.dualFont && ((*pText == '.') || (*pText == ':'))) | |
| 2237 settings.actualFont = (tFont *)settings.TinyFont; | |
| 2238 | |
| 2239 if(settings.actualFont == (tFont *)settings.TinyFont) | |
| 2240 settings.Ydelta += settings.TinyFontExtraYdelta; | |
| 2241 | |
| 2242 newXdelta = GFX_write_char(hgfx, &settings, *(uint8_t *)pText, settings.actualFont); | |
| 2243 settings.Xdelta = newXdelta; | |
| 2244 | |
| 2245 if(settings.actualFont == (tFont *)settings.TinyFont) | |
| 2246 settings.Ydelta -= settings.TinyFontExtraYdelta; | |
| 2247 } | |
| 2248 if(pText != 0) /* for TXT_2BYTE */ | |
| 2249 pText++; | |
| 2250 } | |
| 2251 return settings.Ydelta; | |
| 2252 } | |
| 2253 | |
| 2254 /* Private functions ---------------------------------------------------------*/ | |
| 2255 /****************************************************************************** | |
| 2256 Static Function | |
| 2257 *******************************************************************************/ | |
| 2258 | |
| 2259 /** | |
| 2260 ****************************************************************************** | |
| 2261 * @brief GFX write substring. / Write string without parameters | |
| 2262 * @author heinrichs weikamp gmbh | |
| 2263 * @version V0.0.1 | |
| 2264 * @date 22-April-2014 | |
| 2265 ****************************************************************************** | |
| 2266 * | |
| 2267 * @param hgfx: check gfx_engine.h. | |
| 2268 * @param color: 32bit ARGB8888. | |
| 2269 * @retval None | |
| 2270 */ | |
| 2271 | |
| 2272 static uint32_t GFX_write_substring(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, uint8_t textId, int8_t nextCharFor2Byte) | |
| 2273 { | |
| 2274 uint8_t i, j; | |
| 2275 uint32_t found; | |
| 2276 uint32_t pText; | |
| 58 | 2277 uint16_t decodeUTF8; |
| 38 | 2278 #ifndef BOOTLOADER_STANDALONE |
| 870 | 2279 uint8_t gfx_selected_language = 0; |
| 38 | 2280 SSettings *pSettings; |
| 2281 pSettings = settingsGetPointer(); | |
| 2282 gfx_selected_language = pSettings->selected_language; | |
| 870 | 2283 if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; |
| 38 | 2284 #endif |
| 58 | 2285 |
| 38 | 2286 // ----------------------------- |
| 58 | 2287 if(textId != (uint8_t)TXT_2BYTE) |
| 38 | 2288 { |
| 2289 found = 0; | |
| 2290 j = 0; | |
| 2291 for(i=(uint8_t)TXT_Language;i<(uint8_t)TXT_END;i++) | |
| 2292 { | |
| 870 | 2293 #ifndef BOOTLOADER_STANDALONE |
| 38 | 2294 if(text_array[j].code == textId) |
| 2295 { | |
| 2296 found = 1; | |
| 2297 break; | |
| 2298 } | |
| 870 | 2299 #endif |
| 38 | 2300 j++; |
| 2301 } | |
| 2302 if(!found) | |
| 2303 return cfg->Xdelta; | |
| 58 | 2304 |
| 38 | 2305 // ----------------------------- |
| 870 | 2306 #ifndef BOOTLOADER_STANDALONE |
| 38 | 2307 pText = (uint32_t)text_array[j].text[gfx_selected_language]; |
| 2308 if(!pText) | |
| 2309 pText = (uint32_t)text_array[j].text[0]; | |
| 2310 else | |
| 2311 if(*(char*)pText == 0) | |
| 2312 pText = (uint32_t)text_array[j].text[0]; | |
| 870 | 2313 #endif |
| 38 | 2314 } |
| 2315 // ----------------------------- | |
| 2316 else | |
| 2317 { | |
| 2318 if(!nextCharFor2Byte) | |
| 2319 return cfg->Xdelta; | |
| 2320 | |
| 2321 found = 0; | |
| 2322 for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++) | |
| 2323 { | |
| 870 | 2324 #ifndef BOOTLOADER_STANDALONE |
| 38 | 2325 if((uint8_t)text_array2[j].code == (uint8_t)nextCharFor2Byte) |
| 2326 { | |
| 2327 found = 1; | |
| 2328 break; | |
| 2329 } | |
| 870 | 2330 #endif |
| 38 | 2331 } |
| 2332 if(!found) | |
| 2333 return cfg->Xdelta; | |
| 870 | 2334 #ifndef BOOTLOADER_STANDALONE |
| 38 | 2335 // ----------------------------- |
| 2336 pText = (uint32_t)text_array2[j].text[gfx_selected_language]; | |
| 2337 if(!pText) | |
| 2338 pText = (uint32_t)text_array2[j].text[0]; | |
| 2339 else | |
| 2340 if(*(char*)pText == 0) | |
| 2341 pText = (uint32_t)text_array2[j].text[0]; | |
| 870 | 2342 #endif |
| 38 | 2343 } |
| 2344 // ----------------------------- | |
| 2345 | |
| 2346 if(cfg->actualFont == (tFont *)cfg->TinyFont) | |
| 2347 cfg->Ydelta += cfg->TinyFontExtraYdelta; | |
| 2348 | |
| 2349 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size | |
| 2350 { | |
| 2351 if(*(char*)pText == '\t') | |
| 2352 cfg->Xdelta = hgfx->WindowTab - hgfx->WindowX0; | |
| 2353 else | |
| 612 | 2354 if((*(char*)pText == ' ') && (cfg->invert == 0)) /* bypass drawing of white space only for not inverted mode */ |
| 2355 { | |
| 38 | 2356 cfg->Xdelta += ((tFont *)cfg->actualFont)->spacesize; |
| 612 | 2357 } |
| 38 | 2358 else |
| 58 | 2359 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ |
| 2360 { | |
| 2361 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ | |
| 2362 pText++; | |
| 2363 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */ | |
| 2364 if (decodeUTF8 <= 0xff) /* The following function has a uint8 input parameter ==> no UNICODEs > 0xff supported */ | |
| 2365 { | |
| 2366 cfg->Xdelta = GFX_write_char(hgfx, cfg, (uint8_t)decodeUTF8, (tFont *)cfg->actualFont); | |
| 2367 } | |
| 2368 } | |
| 2369 else | |
| 38 | 2370 cfg->Xdelta = GFX_write_char(hgfx, cfg, *(uint8_t *)pText, (tFont *)cfg->actualFont); |
| 2371 | |
| 2372 pText++; | |
| 2373 } | |
| 2374 | |
| 2375 if(cfg->actualFont == (tFont *)cfg->TinyFont) | |
| 2376 cfg->Ydelta -= cfg->TinyFontExtraYdelta; | |
| 2377 | |
| 2378 return cfg->Xdelta; | |
| 2379 } | |
| 2380 | |
| 2381 | |
| 2382 /** | |
| 2383 ****************************************************************************** | |
| 2384 * @brief GFX write char. / Write non-inverted, non-colored with entire 8 bit range | |
| 2385 * @author heinrichs weikamp gmbh | |
| 2386 * @version V0.0.1 | |
| 2387 * @date 22-April-2014 | |
| 2388 ****************************************************************************** | |
| 2389 * | |
| 2390 * @param hgfx: check gfx_engine.h. | |
| 2391 * @param Ydelta: input | |
| 2392 * @param character: character | |
| 2393 * @param *Font: pointer to font to be used for this char | |
| 2394 * @retval Ydelta: 0x0000FFFF if not successful or char_truncated | |
| 2395 */ | |
| 2396 | |
| 2397 static uint32_t GFX_write_char_doubleSize(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font) | |
| 2398 { | |
| 2399 uint32_t i, j; | |
| 2400 uint32_t width, height; | |
| 2401 uint32_t found; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2402 uint16_t* pDestination; |
| 38 | 2403 uint32_t pSource; |
| 2404 uint32_t OffsetDestination; | |
| 2405 uint32_t width_left; | |
| 2406 uint32_t height_left; | |
| 2407 uint32_t char_truncated_WidthFlag; | |
| 2408 uint32_t char_truncated_Height; | |
| 2409 uint8_t fill; | |
| 2410 uint32_t widthFont, heightFont; | |
| 2411 uint32_t nextLine; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2412 int32_t stepdir; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2413 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2414 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2415 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2416 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2417 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2418 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2419 stepdir = -1; /* decrement address while putting pixels */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2420 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2421 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2422 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2423 stepdir = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2424 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2425 |
| 38 | 2426 |
| 2427 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta)) | |
| 2428 return 0x0000FFFF; | |
| 2429 | |
| 2430 // ----------------------------- | |
| 2431 found = 0; | |
| 2432 for(i=0;i<Font->length;i++) | |
| 2433 { | |
| 2434 if(Font->chars[i].code == character) | |
| 2435 { | |
| 2436 found = 1; | |
| 2437 break; | |
| 2438 } | |
| 2439 } | |
| 2440 if(!found) | |
| 2441 return cfg->Xdelta; | |
| 2442 | |
| 2443 pSource = ((uint32_t)Font->chars[i].image->data); | |
| 119 | 2444 pDestination = (uint16_t*)(hgfx->Image->FBStartAdress); |
| 38 | 2445 |
| 2446 heightFont = Font->chars[i].image->height; | |
| 2447 widthFont = Font->chars[i].image->width; | |
| 2448 | |
| 2449 height = heightFont*2; | |
| 2450 width = widthFont*2; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2451 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2452 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2453 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2454 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2455 pDestination += (uint32_t)(hgfx->WindowX1 - cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2456 pDestination += (hgfx->WindowY1 - cfg->Ydelta); /* set pointer to delta colum */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2457 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2458 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2459 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2460 pDestination += (uint32_t)(hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2461 pDestination += (hgfx->WindowY0 + cfg->Ydelta); /* set pointer to delta colum */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2462 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2463 OffsetDestination = (hgfx->Image->ImageHeight - height); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2464 nextLine = hgfx->Image->ImageHeight; |
| 38 | 2465 |
| 2466 // ----------------------------- | |
| 2467 char_truncated_WidthFlag = 0; | |
|
772
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2468 if(!pSettings->FlipDisplay) |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2469 { |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2470 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta); |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2471 } |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2472 else |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2473 { |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2474 width_left = (hgfx->WindowX1 - cfg->Xdelta); |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2475 } |
| 38 | 2476 if(width_left < width) |
| 2477 { | |
| 2478 char_truncated_WidthFlag = 1; | |
| 2479 width = width_left; | |
| 2480 widthFont = width/2; | |
| 2481 } | |
| 2482 // ----------------------------- | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2483 |
| 38 | 2484 char_truncated_Height = 0; |
| 2485 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta); | |
| 2486 if(height_left < height) | |
| 2487 { | |
| 2488 char_truncated_Height = height - height_left; | |
| 2489 if((char_truncated_Height & 1) != 0) | |
| 2490 { | |
| 2491 height_left -= 1; | |
| 2492 char_truncated_Height += 1; | |
| 2493 } | |
| 2494 height = height_left; | |
| 2495 heightFont = height/2; | |
| 2496 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2497 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2498 OffsetDestination += char_truncated_Height; |
| 38 | 2499 // ----------------------------- |
| 2500 if(height == 0) | |
| 2501 return 0x0000FFFF; | |
| 2502 // ----------------------------- | |
| 2503 | |
| 2504 if(cfg->singleSpaceWithSizeOfNextChar) | |
| 2505 { | |
| 2506 cfg->singleSpaceWithSizeOfNextChar = 0; | |
| 2507 | |
| 2508 if(cfg->invert) | |
| 2509 fill = 0xFF; | |
| 2510 else | |
| 2511 fill = 0; | |
| 2512 | |
| 2513 height /= 2; | |
| 2514 for(i = width; i > 0; i--) | |
| 2515 { | |
| 2516 for (j = height; j > 0; j--) | |
| 2517 { | |
| 119 | 2518 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2519 pDestination += stepdir; |
| 119 | 2520 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2521 pDestination += stepdir; |
| 38 | 2522 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2523 pDestination += stepdir * OffsetDestination; |
| 38 | 2524 } |
| 2525 } | |
| 2526 else | |
| 2527 if(cfg->invert) | |
| 2528 { | |
| 2529 if((heightFont & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ | |
| 2530 { | |
| 2531 heightFont /= 4; | |
| 2532 for(i = widthFont; i > 0; i--) | |
| 2533 { | |
| 2534 if(*(uint8_t*)pSource != 0x01) | |
| 2535 { | |
| 2536 for (j = heightFont; j > 0; j--) | |
| 2537 { | |
| 119 | 2538 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2539 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2540 pDestination += stepdir; |
| 119 | 2541 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2542 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2543 pDestination += stepdir; |
| 38 | 2544 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2545 |
| 119 | 2546 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2547 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2548 pDestination += stepdir; |
| 119 | 2549 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2550 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2551 pDestination += stepdir; |
| 38 | 2552 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2553 |
| 119 | 2554 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2555 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2556 pDestination += stepdir; |
| 119 | 2557 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2558 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2559 pDestination += stepdir; |
| 38 | 2560 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2561 |
| 119 | 2562 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2563 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2564 pDestination += stepdir; |
| 119 | 2565 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2566 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2567 pDestination += stepdir; |
| 38 | 2568 pSource++; |
| 2569 } | |
| 2570 pSource += char_truncated_Height; | |
| 2571 } | |
| 2572 else | |
| 2573 { | |
| 2574 pSource++; | |
| 612 | 2575 for (j = heightFont; j > 0; j--) |
| 38 | 2576 { |
| 119 | 2577 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 612 | 2578 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2579 pDestination += stepdir; |
| 119 | 2580 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2581 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2582 pDestination += stepdir; |
| 119 | 2583 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2584 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2585 pDestination += stepdir; |
| 612 | 2586 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 119 | 2587 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2588 pDestination += stepdir; |
| 119 | 2589 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2590 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2591 pDestination += stepdir; |
| 119 | 2592 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2593 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2594 pDestination += stepdir; |
| 119 | 2595 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2596 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2597 pDestination += stepdir; |
| 119 | 2598 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2599 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2600 pDestination += stepdir; |
| 38 | 2601 } |
| 2602 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2603 pDestination += (OffsetDestination + nextLine) * stepdir; |
| 38 | 2604 } |
| 2605 } | |
| 2606 else | |
| 2607 { | |
| 2608 heightFont /= 2; | |
| 2609 for(i = widthFont; i > 0; i--) | |
| 2610 { | |
| 2611 if(*(uint8_t*)pSource != 0x01) | |
| 2612 { | |
| 2613 for (j = heightFont; j > 0; j--) | |
| 2614 { | |
| 119 | 2615 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2616 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2617 pDestination += stepdir; |
| 119 | 2618 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2619 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2620 pDestination += stepdir; |
| 38 | 2621 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2622 |
| 119 | 2623 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2624 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2625 pDestination += stepdir; |
| 119 | 2626 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
| 2627 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2628 pDestination += stepdir; |
| 38 | 2629 pSource++; |
| 2630 } | |
| 2631 pSource += char_truncated_Height; | |
| 2632 } | |
| 2633 else | |
| 2634 { | |
| 2635 pSource++; | |
| 2636 for (j = heightFont; j > 0; j--) | |
| 2637 { | |
| 119 | 2638 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2639 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2640 pDestination += stepdir; |
| 119 | 2641 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2642 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2643 pDestination += stepdir; |
| 119 | 2644 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2645 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2646 pDestination += stepdir; |
| 119 | 2647 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
| 2648 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2649 pDestination += stepdir; |
| 38 | 2650 } |
| 2651 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2652 pDestination += (OffsetDestination + nextLine) * stepdir; |
| 38 | 2653 } |
| 2654 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2655 } /* inverted */ |
| 38 | 2656 else |
| 2657 { | |
| 2658 if((heightFont & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ | |
| 2659 { | |
| 2660 heightFont /= 4; | |
| 2661 for(i = widthFont; i > 0; i--) | |
| 2662 { | |
| 2663 if(*(uint8_t*)pSource != 0x01) | |
| 2664 { | |
| 2665 for (j = heightFont; j > 0; j--) | |
| 2666 { | |
| 119 | 2667 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2668 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2669 pDestination += stepdir; |
| 119 | 2670 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2671 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2672 pDestination += stepdir; |
| 38 | 2673 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2674 |
| 119 | 2675 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2676 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2677 pDestination += stepdir; |
| 119 | 2678 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2679 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2680 pDestination += stepdir; |
| 38 | 2681 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2682 |
| 119 | 2683 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2684 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2685 pDestination += stepdir; |
| 119 | 2686 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2687 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2688 pDestination += stepdir; |
| 38 | 2689 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2690 |
| 119 | 2691 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2692 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2693 pDestination += stepdir; |
| 119 | 2694 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2695 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2696 pDestination += stepdir; |
| 38 | 2697 pSource++; |
| 2698 } | |
| 2699 pSource += char_truncated_Height; | |
| 2700 } | |
| 2701 else | |
| 2702 { | |
| 2703 pSource++; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2704 pDestination += stepdir * height; |
| 38 | 2705 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2706 pDestination += stepdir * (OffsetDestination + nextLine); |
| 38 | 2707 } |
| 2708 } | |
| 2709 else | |
| 2710 { | |
| 2711 heightFont /= 2; | |
| 2712 for(i = widthFont; i > 0; i--) | |
| 2713 { | |
| 2714 if(*(uint8_t*)pSource != 0x01) | |
| 2715 { | |
| 2716 for (j = heightFont; j > 0; j--) | |
| 2717 { | |
| 119 | 2718 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2719 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2720 pDestination += stepdir; |
| 119 | 2721 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2722 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2723 pDestination += stepdir; |
| 38 | 2724 pSource++; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2725 |
| 119 | 2726 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2727 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2728 pDestination += stepdir; |
| 119 | 2729 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
| 2730 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2731 pDestination += stepdir; |
| 38 | 2732 pSource++; |
| 2733 } | |
| 2734 pSource += char_truncated_Height; | |
| 2735 } | |
| 2736 else | |
| 2737 { | |
| 2738 pSource++; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2739 pDestination += stepdir * height; |
| 38 | 2740 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2741 pDestination += stepdir * (OffsetDestination + nextLine); |
| 38 | 2742 } |
| 2743 } | |
| 2744 } | |
| 2745 | |
| 2746 // ----------------------------- | |
| 2747 | |
| 2748 if(Font == &FontT144) | |
| 2749 width += 6; | |
| 2750 else | |
| 2751 if(Font == &FontT105) | |
| 2752 width += 4; | |
| 2753 | |
| 2754 // ----------------------------- | |
| 2755 | |
| 2756 if(char_truncated_WidthFlag) | |
| 2757 return 0x0000FFFF; | |
| 2758 else | |
| 2759 return cfg->Xdelta + width; | |
| 2760 | |
| 2761 } | |
| 2762 | |
| 2763 | |
| 2764 /** | |
| 2765 ****************************************************************************** | |
| 2766 * @brief GFX write char. / Write non-inverted, non-colored with entire 8 bit range | |
| 2767 * @author heinrichs weikamp gmbh | |
| 2768 * @version V0.0.1 | |
| 2769 * @date 22-April-2014 | |
| 2770 ****************************************************************************** | |
| 2771 * | |
| 2772 * @param hgfx: check gfx_engine.h. | |
| 2773 * @param Ydelta: input | |
| 2774 * @param character: character | |
| 2775 * @param *Font: pointer to font to be used for this char | |
| 2776 * @retval Ydelta: 0x0000FFFF if not successful or char_truncated | |
| 2777 */ | |
| 2778 | |
| 2779 static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font) | |
| 2780 { | |
| 870 | 2781 |
| 2782 #ifndef BOOTLOADER_STANDALONE | |
| 567 | 2783 Font = GFX_Check_Extra_Font(character, Font); |
| 870 | 2784 #endif |
| 38 | 2785 if(cfg->doubleSize) |
| 2786 { | |
| 2787 return GFX_write_char_doubleSize(hgfx, cfg, character, Font); | |
| 2788 } | |
| 2789 | |
| 2790 uint32_t i, j; | |
| 2791 uint32_t width, height; | |
| 2792 uint32_t found; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2793 uint16_t* pDestination; |
| 38 | 2794 uint32_t pSource; |
| 2795 uint32_t OffsetDestination; | |
| 2796 uint32_t width_left; | |
| 2797 uint32_t height_left; | |
| 2798 uint32_t char_truncated_WidthFlag; | |
| 2799 uint32_t char_truncated_Height; | |
| 2800 uint8_t fill; | |
| 121 | 2801 uint32_t fillpattern; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2802 int16_t stepdir; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2803 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2804 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2805 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2806 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2807 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2808 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2809 stepdir = -1; /* decrement address while putting pixels */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2810 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2811 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2812 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2813 stepdir = 1; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2814 } |
| 38 | 2815 |
| 2816 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta)) | |
| 2817 return 0x0000FFFF; | |
| 2818 | |
| 2819 // ----------------------------- | |
| 2820 found = 0; | |
| 2821 for(i=0;i<Font->length;i++) | |
| 2822 { | |
| 2823 if(Font->chars[i].code == character) | |
| 2824 { | |
| 2825 found = 1; | |
| 2826 break; | |
| 2827 } | |
| 2828 } | |
| 2829 if(!found) | |
| 2830 return cfg->Xdelta; | |
| 2831 // ----------------------------- | |
| 2832 /* | |
| 2833 if(Font == &Font144) | |
| 2834 cfg->Xdelta += 3; | |
| 2835 else | |
| 2836 if(Font == &Font84) | |
| 2837 cfg->Xdelta += 2; | |
| 2838 */ | |
| 2839 // ----------------------------- | |
| 2840 | |
| 2841 | |
| 2842 pSource = ((uint32_t)Font->chars[i].image->data); | |
| 119 | 2843 pDestination = (uint16_t*)(hgfx->Image->FBStartAdress); |
| 2844 | |
| 38 | 2845 |
| 2846 height = Font->chars[i].image->height; | |
| 2847 width = Font->chars[i].image->width; | |
| 2848 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2849 OffsetDestination = hgfx->Image->ImageHeight - height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2850 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2851 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2852 /* Xyyyyy y= height */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2853 /* Xyyyyy x= width */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2854 /* Xyyyyy */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2855 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2856 if(pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2857 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2858 pDestination += (hgfx->WindowX1 - cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2859 pDestination += (hgfx->WindowY1 - cfg->Ydelta); /* set pointer to delta colum */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2860 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2861 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2862 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2863 pDestination += (hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2864 pDestination += (hgfx->WindowY0 + cfg->Ydelta); /* set pointer to delta colum */ |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2865 } |
| 38 | 2866 |
| 2867 | |
| 2868 // ----------------------------- | |
| 2869 char_truncated_WidthFlag = 0; | |
|
772
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2870 if(!pSettings->FlipDisplay) |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2871 { |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2872 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta); |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2873 } |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2874 else |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2875 { |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2876 width_left = (hgfx->WindowX1 - cfg->Xdelta); |
|
b7e43b28bee1
Fix character truncation when screen is flipped. This was causing the dive computer to lock up when in English Units with the screen flipped when the first decompression stop is shown using FONT_105.
izzni
parents:
763
diff
changeset
|
2877 } |
| 38 | 2878 if(width_left < width) |
| 2879 { | |
| 2880 char_truncated_WidthFlag = 1; | |
| 2881 width = width_left; | |
| 2882 } | |
| 2883 // ----------------------------- | |
| 2884 char_truncated_Height = 0; | |
|
681
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2885 if(!pSettings->FlipDisplay) |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2886 { |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2887 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta); |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2888 } |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2889 else |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2890 { |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2891 height_left = (hgfx->WindowY1 - cfg->Ydelta); |
|
7fa5ef6ae419
Bugfix screen clipping (Flipdisplay mode):
Ideenmodellierer
parents:
649
diff
changeset
|
2892 } |
| 38 | 2893 if(height_left < height) |
| 2894 { | |
| 2895 char_truncated_Height = height - height_left; | |
| 2896 if((char_truncated_Height & 1) != 0) | |
| 2897 { | |
| 2898 height_left -= 1; | |
| 2899 char_truncated_Height += 1; | |
| 2900 } | |
| 2901 height = height_left; | |
| 2902 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2903 OffsetDestination += char_truncated_Height; |
| 38 | 2904 // ----------------------------- |
| 2905 if(height == 0) | |
| 2906 return 0x0000FFFF; | |
| 2907 // ----------------------------- | |
| 2908 | |
| 2909 if(cfg->singleSpaceWithSizeOfNextChar) | |
| 2910 { | |
| 2911 cfg->singleSpaceWithSizeOfNextChar = 0; | |
| 2912 | |
| 2913 if(cfg->invert) | |
| 2914 fill = 0xFF; | |
| 2915 else | |
| 2916 fill = 0; | |
| 2917 | |
| 2918 height /= 2; | |
| 2919 for(i = width; i > 0; i--) | |
| 2920 { | |
| 2921 for (j = height; j > 0; j--) | |
| 2922 { | |
| 119 | 2923 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2924 pDestination += stepdir; |
| 119 | 2925 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2926 pDestination += stepdir; |
| 38 | 2927 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2928 pDestination += stepdir * OffsetDestination; |
| 38 | 2929 } |
| 2930 } | |
| 2931 else | |
| 2932 if(cfg->invert) | |
| 2933 { | |
| 2934 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ | |
| 2935 { | |
| 2936 height /= 4; | |
| 2937 for(i = width; i > 0; i--) | |
| 2938 { | |
| 2939 if(*(uint8_t*)pSource != 0x01) | |
| 2940 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2941 |
| 38 | 2942 for (j = height; j > 0; j--) |
| 2943 { | |
| 119 | 2944 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2945 pDestination += stepdir; |
| 119 | 2946 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2947 pDestination += stepdir; |
| 119 | 2948 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2949 pDestination += stepdir; |
| 119 | 2950 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2951 pDestination += stepdir; |
| 38 | 2952 } |
| 2953 pSource += char_truncated_Height; | |
| 2954 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2955 else /* empty line => fast fill */ |
| 38 | 2956 { |
| 2957 pSource++; | |
| 121 | 2958 fillpattern = (( 0xFF << 8 | cfg->color) << 16) | ( 0xFF << 8 | cfg->color); |
| 2959 if(pSettings->FlipDisplay) pDestination--; /* address fill from high to low */ | |
| 38 | 2960 for (j = height; j > 0; j--) |
| 2961 { | |
| 121 | 2962 *(__IO uint32_t*)pDestination = fillpattern; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2963 pDestination += stepdir; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2964 pDestination += stepdir; |
| 121 | 2965 *(__IO uint32_t*)pDestination = fillpattern; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2966 pDestination += stepdir; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2967 pDestination += stepdir; |
| 38 | 2968 } |
| 121 | 2969 if(pSettings->FlipDisplay) pDestination++; |
| 38 | 2970 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2971 pDestination += stepdir * OffsetDestination; |
| 38 | 2972 } |
| 2973 } | |
| 2974 else | |
| 2975 { | |
| 2976 height /= 2; | |
| 2977 for(i = width; i > 0; i--) | |
| 2978 { | |
| 2979 if(*(uint8_t*)pSource != 0x01) | |
| 2980 { | |
| 2981 for (j = height; j > 0; j--) | |
| 2982 { | |
| 119 | 2983 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2984 pDestination += stepdir; |
| 119 | 2985 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2986 pDestination += stepdir; |
| 38 | 2987 } |
| 2988 pSource += char_truncated_Height; | |
| 2989 } | |
| 2990 else | |
| 2991 { | |
| 2992 pSource++; | |
| 2993 for (j = height; j > 0; j--) | |
| 2994 { | |
| 119 | 2995 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2996 pDestination += stepdir; |
| 119 | 2997 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2998 pDestination += stepdir; |
| 38 | 2999 } |
| 3000 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3001 pDestination += stepdir * OffsetDestination; |
| 38 | 3002 } |
| 3003 } | |
| 3004 } | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3005 else /* not inverted */ |
| 38 | 3006 { |
| 3007 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ | |
| 3008 { | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3009 |
| 38 | 3010 height /= 4; |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3011 |
| 38 | 3012 for(i = width; i > 0; i--) |
| 3013 { | |
| 3014 if(*(uint8_t*)pSource != 0x01) | |
| 3015 { | |
| 3016 for (j = height; j > 0; j--) | |
| 3017 { | |
| 119 | 3018 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3019 pDestination += stepdir; |
| 119 | 3020 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3021 pDestination += stepdir; |
| 119 | 3022 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3023 pDestination += stepdir; |
| 119 | 3024 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3025 pDestination += stepdir; |
| 38 | 3026 } |
| 121 | 3027 |
| 38 | 3028 pSource += char_truncated_Height; |
| 3029 } | |
| 119 | 3030 else /* clear line */ |
| 38 | 3031 { |
| 3032 pSource++; | |
| 121 | 3033 fillpattern = (cfg->color << 16) | cfg->color; |
| 3034 if(pSettings->FlipDisplay) pDestination--; /* address fill from high to low */ | |
| 3035 | |
| 119 | 3036 for (j = height; j > 0; j--) |
| 3037 { | |
| 121 | 3038 *(__IO uint32_t*)pDestination = fillpattern; |
| 119 | 3039 pDestination += stepdir; |
| 3040 pDestination += stepdir; | |
| 121 | 3041 *(__IO uint32_t*)pDestination = fillpattern; |
| 119 | 3042 pDestination += stepdir; |
| 3043 pDestination += stepdir; | |
| 3044 } | |
| 121 | 3045 if(pSettings->FlipDisplay) pDestination++; |
| 38 | 3046 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3047 pDestination += stepdir * OffsetDestination; |
| 38 | 3048 } |
| 3049 } | |
| 3050 else | |
| 3051 { | |
| 3052 height /= 2; | |
| 3053 for(i = width; i > 0; i--) | |
| 3054 { | |
| 3055 if(*(uint8_t*)pSource != 0x01) | |
| 3056 { | |
| 3057 for (j = height; j > 0; j--) | |
| 3058 { | |
| 119 | 3059 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3060 pDestination += stepdir; |
| 119 | 3061 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3062 pDestination += stepdir; |
| 38 | 3063 } |
| 3064 pSource += char_truncated_Height; | |
| 3065 } | |
| 119 | 3066 else /* clear line */ |
| 38 | 3067 { |
| 3068 pSource++; | |
| 119 | 3069 for (j = height; j > 0; j--) |
| 3070 { | |
| 3071 *(__IO uint16_t*)pDestination = cfg->color; | |
| 3072 pDestination += stepdir; | |
| 3073 *(__IO uint16_t*)pDestination = cfg->color; | |
| 3074 pDestination += stepdir; | |
| 3075 } | |
| 38 | 3076 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3077 pDestination += stepdir * OffsetDestination; |
| 38 | 3078 } |
| 3079 } | |
| 3080 } | |
| 3081 | |
| 3082 // ----------------------------- | |
| 3083 | |
| 3084 if(Font == &FontT144) | |
| 3085 width += 3; | |
| 3086 else | |
| 3087 if(Font == &FontT105) | |
| 3088 width += 2; | |
| 3089 /* | |
| 3090 else | |
| 3091 if(Font == &Font144) | |
| 3092 width += 3; | |
| 3093 else | |
| 3094 if(Font == &Font84) | |
| 3095 width += 1; | |
| 3096 */ | |
| 3097 // ----------------------------- | |
| 3098 | |
| 3099 if(char_truncated_WidthFlag) | |
| 3100 return 0x0000FFFF; | |
| 3101 else | |
| 3102 return cfg->Xdelta + width; | |
| 3103 } | |
| 3104 | |
| 870 | 3105 #ifndef BOOTLOADER_STANDALONE |
| 38 | 3106 |
| 3107 /** | |
| 3108 ****************************************************************************** | |
| 3109 * @brief GFX write Modify helper for center and right align. | |
| 3110 * @author heinrichs weikamp gmbh | |
| 3111 * @version V0.0.1 | |
| 3112 * @date 17-March-2015 | |
| 3113 ****************************************************************************** | |
| 3114 * | |
| 3115 * @param *cText: output | |
| 3116 * @param *pTextInput: input | |
| 3117 * @param gfx_selected_language: gfx_selected_language | |
| 3118 * @retval counter and *cText content | |
| 3119 */ | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
3120 static int8_t GFX_write__Modify_helper(char *cText, const char *pTextInput, uint8_t gfx_selected_language) |
| 38 | 3121 { |
| 3122 uint32_t pText, backup; | |
| 3123 uint8_t textId; | |
| 3124 int8_t counter; | |
| 3125 uint32_t found; | |
| 3126 uint32_t j; | |
| 3127 | |
| 3128 pText = (uint32_t)pTextInput; | |
| 3129 counter = 0; | |
|
537
0ad0b26ec56b
Added center / right alignment option to custom text display:
Ideenmodellierer
parents:
509
diff
changeset
|
3130 while((counter < 100) && (*(char*)pText != 0) && (*(char*)pText != '\r') && (*(char*)pText != '\n')) |
| 38 | 3131 { |
| 3132 if((*(char*)pText) == TXT_2BYTE) | |
| 3133 { | |
| 3134 backup = pText; | |
| 3135 | |
| 3136 found = 0; | |
| 3137 j = 0; | |
| 3138 textId = (int8_t)*(char*)(pText + 1); | |
| 3139 if(textId != 0) | |
| 3140 { | |
| 3141 for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++) | |
| 3142 { | |
| 3143 if((uint8_t)text_array2[j].code == (uint8_t)textId) | |
| 3144 { | |
| 3145 found = 1; | |
| 3146 break; | |
| 3147 } | |
| 3148 } | |
| 3149 if(found) | |
| 3150 { | |
| 3151 pText = (uint32_t)text_array2[j].text[gfx_selected_language]; | |
| 3152 if(!pText) | |
| 3153 pText = (uint32_t)text_array2[j].text[0]; | |
| 3154 else | |
| 3155 if(*(char*)pText == 0) | |
| 3156 pText = (uint32_t)text_array2[j].text[0]; | |
| 3157 | |
| 3158 while((counter < 100) && (*(char*)pText != 0)) | |
| 3159 cText[counter++] = *(char*)pText++; | |
| 3160 } | |
| 3161 pText = backup + 2; | |
| 3162 } | |
| 3163 else | |
| 3164 pText = 0; | |
| 3165 } | |
| 699 | 3166 if(0 != pText && ((*(char*)pText) & 0x80)) |
| 38 | 3167 { |
| 3168 backup = pText; | |
| 3169 | |
| 3170 found = 0; | |
| 3171 j = 0; | |
| 3172 textId = (uint8_t)*(char*)pText; | |
| 3173 for(uint8_t ii=(uint8_t)TXT_Language;ii<(uint8_t)TXT_END;ii++) | |
| 3174 { | |
| 3175 if(text_array[j].code == textId) | |
| 3176 { | |
| 3177 found = 1; | |
| 3178 break; | |
| 3179 } | |
| 3180 j++; | |
| 3181 } | |
| 3182 if(found) | |
| 3183 { | |
| 3184 pText = (uint32_t)text_array[j].text[gfx_selected_language]; | |
| 3185 if(!pText) | |
| 3186 pText = (uint32_t)text_array[j].text[0]; | |
| 3187 else | |
| 3188 if(*(char*)pText == 0) | |
| 3189 pText = (uint32_t)text_array[j].text[0]; | |
| 3190 | |
| 3191 while((counter < 100) && (*(char*)pText != 0)) | |
| 3192 cText[counter++] = *(char*)pText++; | |
| 3193 } | |
| 3194 pText = backup + 1; | |
| 3195 } | |
| 3196 else | |
| 3197 { | |
| 3198 cText[counter++] = *(char*)pText++; | |
| 3199 } | |
| 3200 } | |
| 3201 cText[counter] = 0; | |
| 3202 return counter; | |
| 3203 } | |
| 3204 | |
| 870 | 3205 #endif |
| 38 | 3206 /** |
| 3207 ****************************************************************************** | |
| 3208 * @brief GFX write Modify Ydelta for align. / calc Ydelta for start | |
| 3209 * @author heinrichs weikamp gmbh | |
| 3210 * @version V0.0.1 | |
| 3211 * @date 22-April-2014 | |
| 3212 ****************************************************************************** | |
| 3213 * | |
| 3214 * @param *hgfx: check gfx_engine.h. | |
| 3215 * @param *cfg: Ydelta, Font | |
| 3216 * @param *pText: character | |
| 3217 * @retval Ydelta: 0 if text has to start left ( and probably does not fit) | |
| 3218 */ | |
| 3219 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
3220 static uint32_t GFX_write__Modify_Xdelta__Centered(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput) |
| 38 | 3221 { |
| 3222 char cText[101]; | |
| 3223 uint32_t result; | |
| 3224 uint32_t Xsum; | |
| 583 | 3225 uint32_t j; |
| 38 | 3226 uint32_t pText; |
| 58 | 3227 uint16_t decodeUTF8; |
|
481
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3228 uint8_t tinyState = 0; /* used to identify the usage of tiny font */ |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3229 tFont* ptargetFont; |
| 38 | 3230 |
| 3231 #ifndef BOOTLOADER_STANDALONE | |
| 870 | 3232 uint8_t gfx_selected_language = 0; |
| 38 | 3233 SSettings *pSettings; |
| 3234 pSettings = settingsGetPointer(); | |
| 3235 gfx_selected_language = pSettings->selected_language; | |
|
875
943918a69836
DevBugfix: Added missing default language value
Ideenmodellierer
parents:
874
diff
changeset
|
3236 if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; |
| 38 | 3237 #endif |
| 3238 // ----------------------------- | |
| 870 | 3239 #ifndef BOOTLOADER_STANDALONE |
| 38 | 3240 GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); |
| 870 | 3241 #endif |
| 38 | 3242 pText = (uint32_t)&cText[0]; |
| 3243 Xsum = 0; | |
| 3244 j = 0; | |
|
565
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3245 ptargetFont = (tFont *)cfg->font; |
| 38 | 3246 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size |
| 3247 { | |
|
481
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3248 if(*(char*)pText == '\016') /* request font change */ |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3249 { |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3250 tinyState++; |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3251 } |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3252 if(*(char*)pText == '\017') /* request font reset */ |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3253 { |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3254 tinyState = 0; |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3255 } |
|
565
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3256 |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3257 if((ptargetFont == &FontT105) && ((*(char*)pText == '.') || (*(char*)pText == ':'))) |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3258 { |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3259 tinyState++; |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3260 } |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3261 |
|
481
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3262 if(tinyState > 1) |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3263 { |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3264 ptargetFont = (tFont *)cfg->TinyFont; |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3265 } |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3266 else |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3267 { |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3268 ptargetFont = (tFont *)cfg->font; |
|
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3269 } |
|
649
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3270 |
| 699 | 3271 decodeUTF8 = *(char*)pText; /* place ASCII char */ |
|
649
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3272 if((*(char*)pText == '\005') || (*(char*)pText == '\006')) |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3273 { |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3274 Xsum += 45; |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3275 } |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3276 else |
| 58 | 3277 { |
| 698 | 3278 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ |
| 3279 { | |
| 3280 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ | |
| 3281 pText++; | |
| 3282 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */ | |
| 3283 } | |
| 3284 else | |
| 3285 { | |
| 3286 decodeUTF8 = *(char*)pText; /* place ASCII char */ | |
| 3287 } | |
| 3288 Xsum += GFX_Character_Width(decodeUTF8, ptargetFont); | |
| 58 | 3289 } |
| 567 | 3290 |
| 38 | 3291 pText++; |
| 3292 j++; | |
|
481
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3293 if((ptargetFont == &FontT144) && (*(char*)pText != 0)) |
| 38 | 3294 Xsum += 3; |
| 3295 else | |
|
481
89f6857276f8
Bugfix calculation of string center position:
ideenmodellierer
parents:
314
diff
changeset
|
3296 if((ptargetFont == &FontT105) && (*(char*)pText != 0)) |
| 38 | 3297 Xsum += 2; |
| 3298 } | |
| 3299 pText -= j; | |
| 3300 | |
| 3301 if(cfg->doubleSize) | |
| 3302 Xsum *= 2; | |
| 3303 | |
| 3304 result = hgfx->WindowX1 - hgfx->WindowX0; | |
| 3305 if(Xsum < result) | |
| 3306 { | |
| 3307 result -= Xsum; | |
| 3308 result /= 2; | |
| 3309 } | |
| 3310 else | |
| 3311 result = 0; | |
| 3312 return result; | |
| 3313 } | |
| 3314 | |
| 3315 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
3316 static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput) |
| 38 | 3317 { |
| 3318 uint32_t result; | |
| 3319 uint32_t Xsum; | |
| 583 | 3320 uint32_t j; |
| 38 | 3321 tFont *font; |
| 870 | 3322 char cText[101]; |
| 38 | 3323 uint32_t pText; |
| 58 | 3324 uint16_t decodeUTF8; |
| 485 | 3325 uint8_t tinyState = 0; /* used to identify the usage of tiny font */ |
| 38 | 3326 |
| 3327 #ifndef BOOTLOADER_STANDALONE | |
| 870 | 3328 uint8_t gfx_selected_language = 0; |
| 38 | 3329 SSettings *pSettings; |
| 3330 pSettings = settingsGetPointer(); | |
| 3331 gfx_selected_language = pSettings->selected_language; | |
|
875
943918a69836
DevBugfix: Added missing default language value
Ideenmodellierer
parents:
874
diff
changeset
|
3332 if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; |
| 870 | 3333 #else |
| 3334 cText[0] = 0; | |
| 38 | 3335 #endif |
| 3336 // ----------------------------- | |
| 870 | 3337 #ifndef BOOTLOADER_STANDALONE |
| 38 | 3338 GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); |
| 870 | 3339 #endif |
| 38 | 3340 pText = (uint32_t)&cText[0]; |
| 3341 // ----------------------------- | |
| 3342 | |
| 3343 font = (tFont *)cfg->font; | |
| 3344 Xsum = 0; | |
| 3345 j = 0; | |
| 3346 | |
| 3347 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size | |
| 3348 { | |
| 485 | 3349 if(*(char*)pText == '\016') /* request font change */ |
| 3350 { | |
| 3351 tinyState++; | |
| 3352 } | |
| 3353 if(*(char*)pText == '\017') /* request font reset */ | |
| 3354 { | |
| 3355 tinyState = 0; | |
| 3356 } | |
|
565
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3357 |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3358 if((font == &FontT144) && (*(char*)pText == '.')) |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3359 { |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3360 tinyState++; |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3361 } |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3362 if((font == &FontT105) && ((*(char*)pText == '.') || (*(char*)pText == ':'))) |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3363 { |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3364 tinyState++; |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3365 } |
|
7b56d4eda695
Bugfix center / right alignment if dualfont is used:
Ideenmodellierer
parents:
537
diff
changeset
|
3366 |
| 485 | 3367 if(tinyState > 1) |
| 3368 { | |
| 3369 font = (tFont *)cfg->TinyFont; | |
| 3370 } | |
| 3371 else | |
| 3372 { | |
| 3373 font = (tFont *)cfg->font; | |
| 3374 } | |
| 3375 | |
| 38 | 3376 if(*(char*)pText == ' ') |
| 3377 { | |
| 3378 Xsum += font->spacesize; | |
| 3379 } | |
| 3380 else | |
|
649
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3381 if((*(char*)pText == '\005') || (*(char*)pText == '\006')) |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3382 { |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3383 Xsum += 45; |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3384 } |
|
60162a939c06
Bugfix consider checkbox in calculation of right aligned and centered position:
Ideenmodellierer
parents:
623
diff
changeset
|
3385 else |
| 38 | 3386 { |
| 58 | 3387 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ |
| 3388 { | |
| 3389 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ | |
| 3390 pText++; | |
| 3391 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */ | |
| 3392 } | |
| 3393 else | |
| 3394 { | |
| 3395 decodeUTF8 = *(char*)pText; | |
| 3396 } | |
| 567 | 3397 Xsum += GFX_Character_Width(decodeUTF8, font); /* lookup character and add width */ |
| 38 | 3398 } |
| 3399 pText++; | |
| 3400 j++; | |
| 3401 if((font == &FontT144) && (*(char*)pText != 0)) | |
| 3402 Xsum += 3; | |
| 3403 else | |
| 3404 if((font == &FontT105) && (*(char*)pText != 0)) | |
| 3405 Xsum += 2; | |
| 3406 } | |
| 3407 pText -= j; | |
| 3408 | |
| 3409 if(cfg->doubleSize) | |
| 3410 Xsum *= 2; | |
| 3411 | |
| 3412 result = hgfx->WindowX1 - hgfx->WindowX0 - 1; | |
| 3413 if(Xsum < result) | |
| 3414 result -= Xsum; | |
| 3415 else | |
| 3416 result = 0; | |
| 3417 | |
| 3418 return result; | |
| 3419 } | |
| 3420 | |
| 3421 void GFX_LTDC_Init(void) | |
| 3422 { | |
|
885
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
884
diff
changeset
|
3423 if (isNewDisplay()) |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
884
diff
changeset
|
3424 { |
| 871 | 3425 GFX_LTDC_Init_display1(); |
|
885
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
884
diff
changeset
|
3426 } |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
884
diff
changeset
|
3427 else |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
884
diff
changeset
|
3428 { |
| 871 | 3429 GFX_LTDC_Init_display0(); |
|
885
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
884
diff
changeset
|
3430 } |
| 871 | 3431 } |
| 3432 | |
| 3433 void GFX_LTDC_Init_display0(void) | |
| 3434 { | |
| 3435 /* Timing configuration */ | |
| 3436 | |
| 873 | 3437 #define ActiveH_d0 800 |
| 3438 #define ActiveW_d0 480 | |
| 3439 | |
| 3440 #define Hsync_d0 10 | |
| 3441 #define HFP_d0 8 | |
| 3442 #define HBP_d0 10 | |
| 3443 | |
| 3444 #define Vsync_d0 2 | |
| 3445 #define VFP_d0 2 | |
| 3446 #define VBP_d0 2 | |
| 871 | 3447 |
| 3448 | |
| 38 | 3449 /* Horizontal synchronization width = Hsync - 1 */ |
| 873 | 3450 LtdcHandle.Init.HorizontalSync = Hsync_d0 - 1; |
| 38 | 3451 /* Vertical synchronization height = Vsync - 1 */ |
| 873 | 3452 LtdcHandle.Init.VerticalSync = Vsync_d0 - 1; |
| 38 | 3453 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ |
| 873 | 3454 LtdcHandle.Init.AccumulatedHBP = Hsync_d0 + HBP_d0 - 1; |
| 38 | 3455 /* Accumulated vertical back porch = Vsync + VBP - 1 */ |
| 873 | 3456 LtdcHandle.Init.AccumulatedVBP = Vsync_d0 + VBP_d0 - 1; |
| 38 | 3457 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ |
| 873 | 3458 LtdcHandle.Init.AccumulatedActiveW = Hsync_d0 + HBP_d0 + ActiveW_d0 - 1; |
| 38 | 3459 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ |
| 873 | 3460 LtdcHandle.Init.AccumulatedActiveH = Vsync_d0 + VBP_d0 + ActiveH_d0 - 1; |
| 38 | 3461 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ |
| 873 | 3462 LtdcHandle.Init.TotalWidth = Hsync_d0 + HBP_d0 + ActiveW_d0 + HFP_d0 - 1; |
| 38 | 3463 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ |
| 873 | 3464 LtdcHandle.Init.TotalHeigh = Vsync_d0 + VBP_d0 + ActiveH_d0 + VFP_d0 - 1; |
| 38 | 3465 |
| 3466 /* Configure R,G,B component values for LCD background color */ | |
| 3467 LtdcHandle.Init.Backcolor.Red= 0; | |
| 3468 LtdcHandle.Init.Backcolor.Blue= 0; | |
| 3469 LtdcHandle.Init.Backcolor.Green= 0; | |
| 3470 | |
| 3471 /* LCD clock configuration */ | |
| 3472 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | |
| 3473 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | |
| 3474 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | |
| 3475 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ | |
| 3476 | |
| 871 | 3477 /* done in base.c SystemClockConfig |
| 38 | 3478 |
| 3479 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | |
| 3480 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; | |
| 3481 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; | |
| 3482 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; | |
| 3483 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
| 3484 */ | |
| 3485 /* Polarity */ | |
| 3486 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
| 3487 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL; | |
| 3488 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
| 3489 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC; | |
| 3490 | |
| 3491 LtdcHandle.Instance = LTDC; | |
| 3492 | |
| 3493 /* Configure the LTDC */ | |
| 871 | 3494 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too |
| 3495 { | |
| 3496 /* Initialization Error */ | |
| 3497 GFX_Error_Handler(); | |
| 3498 } | |
| 3499 } | |
| 3500 | |
| 3501 | |
| 3502 void GFX_LTDC_Init_display1(void) | |
| 3503 { | |
| 3504 /* Timing configuration */ | |
| 3505 #define ActiveH_d1 800 | |
| 3506 #define ActiveW_d1 480 | |
| 3507 | |
| 3508 #define Hsync_d1 2 | |
| 3509 #define HFP_d1 8 | |
| 3510 #define HBP_d1 8 | |
| 3511 | |
| 3512 #define Vsync_d1 2 | |
| 3513 #define VFP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VFP_SET | |
| 1006 | 3514 #define VBP_d1 6 // make sure this value * VSYNC is also set in display.c for OLED_VBP_SET |
| 871 | 3515 |
| 3516 /* Horizontal synchronization width = Hsync - 1 */ | |
| 3517 LtdcHandle.Init.HorizontalSync = Hsync_d1 - 1; | |
| 3518 /* Vertical synchronization height = Vsync - 1 */ | |
| 3519 LtdcHandle.Init.VerticalSync = Vsync_d1 -1; | |
| 3520 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ | |
| 3521 LtdcHandle.Init.AccumulatedHBP = Hsync_d1 + HBP_d1 - 1; | |
| 3522 /* Accumulated vertical back porch = Vsync + VBP - 1 */ | |
| 3523 LtdcHandle.Init.AccumulatedVBP = Vsync_d1 + VBP_d1 - 1; | |
| 3524 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ | |
| 3525 LtdcHandle.Init.AccumulatedActiveW = Hsync_d1 + HBP_d1 + ActiveW_d1 - 1; | |
| 3526 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ | |
| 3527 LtdcHandle.Init.AccumulatedActiveH = Vsync_d1 + VBP_d1 + ActiveH_d1 - 1; | |
| 3528 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ | |
| 3529 LtdcHandle.Init.TotalWidth = Hsync_d1 + HBP_d1 + ActiveW_d1 + HFP_d1 - 1; | |
| 3530 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ | |
| 3531 LtdcHandle.Init.TotalHeigh = Vsync_d1 + VBP_d1 + ActiveH_d1 + VFP_d1 - 1; | |
| 3532 | |
| 3533 /* Configure R,G,B component values for LCD background color */ | |
| 3534 LtdcHandle.Init.Backcolor.Red= 0; | |
| 3535 LtdcHandle.Init.Backcolor.Blue= 0; | |
| 3536 LtdcHandle.Init.Backcolor.Green= 0; | |
| 3537 | |
| 3538 /* LCD clock configuration */ | |
| 3539 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | |
| 3540 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | |
| 3541 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | |
| 3542 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ | |
| 3543 | |
| 3544 /* done in base.c SystemClockConfig | |
| 3545 | |
| 3546 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | |
| 3547 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; | |
| 3548 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; | |
| 3549 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; | |
| 3550 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
| 3551 */ | |
| 3552 /* Polarity */ | |
| 3553 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
| 3554 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL; | |
| 3555 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
| 3556 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC; | |
| 3557 | |
| 3558 LtdcHandle.Instance = LTDC; | |
| 3559 | |
| 3560 /* Configure the LTDC */ | |
| 3561 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too | |
| 38 | 3562 { |
| 3563 /* Initialization Error */ | |
| 3564 GFX_Error_Handler(); | |
| 3565 } | |
| 3566 } | |
| 3567 | |
| 3568 void GFX_LTDC_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) | |
| 3569 { | |
| 3570 LTDC_LayerCfgTypeDef Layercfg; | |
| 3571 | |
| 3572 /* Layer Init */ | |
| 3573 Layercfg.WindowX0 = 0; | |
| 3574 Layercfg.WindowX1 = 480; | |
| 3575 Layercfg.WindowY0 = 0; | |
| 3576 Layercfg.WindowY1 = 800; | |
| 3577 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_AL88;//LTDC_PIXEL_FORMAT_ARGB8888; | |
| 3578 Layercfg.FBStartAdress = FB_Address; | |
| 3579 Layercfg.Alpha = 255; | |
| 3580 Layercfg.Alpha0 = 0; | |
| 3581 Layercfg.Backcolor.Blue = 0; | |
| 3582 Layercfg.Backcolor.Green = 0; | |
| 3583 Layercfg.Backcolor.Red = 0; | |
| 3584 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; | |
| 3585 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; | |
| 3586 Layercfg.ImageWidth = 480; | |
| 3587 Layercfg.ImageHeight = 800; | |
| 3588 | |
| 3589 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, LayerIndex); | |
| 3590 HAL_LTDC_ConfigLayer(&LtdcHandle, &Layercfg, LayerIndex); | |
| 3591 HAL_LTDC_EnableCLUT(&LtdcHandle, LayerIndex); | |
| 3592 } | |
| 3593 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
3594 static uint32_t GFX_doubleBufferOne(void) |
| 38 | 3595 { |
| 3596 return SDRAM_DOUBLE_BUFFER_ONE; | |
| 3597 } | |
| 3598 | |
| 3599 | |
|
297
87d54b4fd946
cleanup: remove unused code, make static, remove commented code
Jan Mulder <jlmulder@xs4all.nl>
parents:
296
diff
changeset
|
3600 static uint32_t GFX_doubleBufferTwo(void) |
| 38 | 3601 { |
| 3602 return SDRAM_DOUBLE_BUFFER_TWO; | |
| 3603 } | |
| 3604 | |
| 3605 uint32_t getFrame(uint8_t callerId) | |
| 3606 { | |
| 623 | 3607 static uint8_t lastFrameProvided = 0; |
| 38 | 3608 uint8_t i; |
| 3609 | |
| 623 | 3610 /* first iteration: look for a clear frame */ |
| 3611 i = lastFrameProvided; | |
| 3612 do | |
| 3613 { | |
| 38 | 3614 i++; |
| 623 | 3615 if(i == MAXFRAMES) |
| 3616 { | |
| 3617 i = 0; | |
| 3618 } | |
| 3619 } while((i != lastFrameProvided) && (frame[i].status != CLEAR)); | |
| 38 | 3620 |
| 3621 if((i < MAXFRAMES) && (frame[i].status == CLEAR)) | |
| 3622 { | |
| 3623 frame[i].status = BLOCKED; | |
| 3624 frame[i].caller = callerId; | |
| 623 | 3625 lastFrameProvided = i; |
| 38 | 3626 return frame[i].StartAddress; |
| 3627 } | |
| 3628 | |
| 623 | 3629 /* second iteration: look for a frame which may be reused after clearing */ |
| 3630 i = lastFrameProvided; | |
| 3631 do | |
| 3632 { | |
| 38 | 3633 i++; |
| 623 | 3634 if(i == MAXFRAMES) |
| 3635 { | |
| 3636 i = 0; | |
| 3637 } | |
| 705 | 3638 }while((i != lastFrameProvided) && (frame[i].status != RELEASED)); |
| 623 | 3639 |
| 38 | 3640 |
| 3641 if((i < MAXFRAMES) && (frame[i].status == RELEASED)) | |
| 3642 { | |
| 3643 GFX_clear_frame_immediately(frame[i].StartAddress); | |
| 3644 frame[i].status = BLOCKED; | |
| 623 | 3645 lastFrameProvided = i; |
| 38 | 3646 return frame[i].StartAddress; |
| 3647 } | |
| 3648 return 0; | |
| 3649 } | |
| 3650 | |
| 3651 | |
| 3652 void GFX_forceReleaseFramesWithId(uint8_t callerId) | |
| 3653 { | |
| 3654 for(int i=0; i<MAXFRAMES; i++) | |
| 3655 if((frame[i].caller == callerId) && (frame[i].status == BLOCKED)) | |
| 3656 frame[i].status = RELEASED; | |
| 3657 } | |
| 3658 | |
| 3659 | |
| 3660 void releaseAllFramesExcept(uint8_t callerId, uint32_t frameStartAddress) | |
| 3661 { | |
| 3662 for(int i=0; i<MAXFRAMES; i++) | |
| 3663 if((frame[i].caller == callerId) && (frame[i].status == BLOCKED) && (frame[i].StartAddress != frameStartAddress)) | |
| 3664 frame[i].status = RELEASED; | |
| 3665 } | |
| 3666 | |
| 3667 | |
| 3668 uint8_t releaseFrame(uint8_t callerId, uint32_t frameStartAddress) | |
| 3669 { | |
| 3670 static uint8_t countErrorCalls = 0; | |
| 3671 | |
| 3672 if(frameStartAddress < FBGlobalStart) | |
| 3673 return 2; | |
| 3674 | |
| 3675 | |
| 3676 uint8_t i; | |
| 3677 | |
| 3678 i = 0; | |
| 3679 while((i < MAXFRAMES) && (frame[i].StartAddress != frameStartAddress)) | |
| 3680 i++; | |
| 3681 | |
| 3682 if((i < MAXFRAMES) && (frame[i].StartAddress == frameStartAddress)) | |
| 3683 { | |
| 3684 if(frame[i].caller == callerId) | |
| 3685 { | |
| 3686 frame[i].status = RELEASED; | |
| 3687 return 1; | |
| 3688 } | |
| 3689 else | |
| 3690 countErrorCalls++; | |
| 3691 } | |
| 3692 return 0; | |
| 3693 } | |
| 3694 | |
| 3695 | |
| 3696 uint16_t blockedFramesCount(void) | |
| 3697 { | |
| 3698 uint16_t count = MAXFRAMES; | |
| 3699 | |
| 3700 for(int i = 0;i<MAXFRAMES;i++) | |
| 3701 if(frame[i].status == BLOCKED) | |
| 3702 count--; | |
| 3703 | |
| 3704 return count; | |
| 3705 } | |
| 3706 | |
| 3707 | |
| 623 | 3708 uint8_t housekeepingFrame(void) |
| 38 | 3709 { |
| 3710 static uint8_t countLogClear = 0; | |
| 623 | 3711 uint8_t i; |
| 3712 uint8_t retVal = 1; | |
| 38 | 3713 |
| 623 | 3714 if(DMA2D_at_work == 255) |
| 38 | 3715 { |
| 623 | 3716 i = 0; |
| 3717 /* skip frame cleaning for actual frames which have not yet been replaced by new top/bottom frames */ | |
| 3718 while((i < MAXFRAMES) && ((frame[i].status != RELEASED) || (frame[i].StartAddress == GFX_get_pActualFrameTop()) || (frame[i].StartAddress == GFX_get_pActualFrameBottom()))) | |
| 3719 i++; | |
| 3720 | |
| 3721 if((i < MAXFRAMES) && (frame[i].status == RELEASED)) | |
| 3722 { | |
| 3723 if(frame[i].caller == 15) | |
| 3724 countLogClear++; | |
| 3725 GFX_clear_frame_dma2d(i); | |
| 38 | 3726 } |
| 3727 else | |
| 623 | 3728 { |
| 3729 retVal = 0; /* no more frame to be cleaned found */ | |
| 3730 } | |
| 38 | 3731 } |
| 623 | 3732 return retVal; |
| 38 | 3733 } |
| 3734 | |
| 3735 | |
| 3736 static void GFX_Dma2d_TransferComplete(DMA2D_HandleTypeDef* Dma2dHandle) | |
| 3737 { | |
| 3738 if(DMA2D_at_work < MAXFRAMES) | |
| 3739 frame[DMA2D_at_work].status = CLEAR; | |
| 3740 | |
| 3741 DMA2D_at_work = 255; | |
| 3742 } | |
| 3743 | |
| 3744 | |
| 3745 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle) | |
| 3746 { | |
| 3747 | |
| 3748 } | |
| 3749 | |
| 3750 static void GFX_Error_Handler(void) | |
| 3751 { | |
| 3752 /* Turn LED3 on */ | |
| 3753 // BSP_LED_On(LED3); | |
| 3754 while(1) | |
| 3755 { | |
| 3756 } | |
| 3757 } | |
| 3758 | |
| 3759 void write_content_simple(GFX_DrawCfgScreen *tMscreen, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
| 3760 { | |
| 3761 GFX_DrawCfgWindow hgfx; | |
| 3762 | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3763 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3764 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3765 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3766 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3767 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3768 if(XrightGimpStyle > 799) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3769 XrightGimpStyle = 799; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3770 if(XleftGimpStyle >= XrightGimpStyle) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3771 XleftGimpStyle = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3772 if(YtopGimpStyle > 479) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3773 YtopGimpStyle = 479; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3774 } |
| 38 | 3775 hgfx.Image = tMscreen; |
| 3776 hgfx.WindowNumberOfTextLines = 1; | |
| 3777 hgfx.WindowLineSpacing = 0; | |
| 3778 hgfx.WindowTab = 0; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3779 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3780 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3781 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3782 hgfx.WindowX0 = XleftGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3783 hgfx.WindowX1 = XrightGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3784 hgfx.WindowY1 = 479 - YtopGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3785 if(hgfx.WindowY1 < Font->height) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3786 hgfx.WindowY0 = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3787 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3788 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3789 } |
| 38 | 3790 else |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3791 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3792 hgfx.WindowX0 = 800 - XrightGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3793 hgfx.WindowX1 = 800 - XleftGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3794 hgfx.WindowY0 = YtopGimpStyle; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3795 if(hgfx.WindowY0 + Font->height >= 479) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3796 hgfx.WindowY1 = 479; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3797 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3798 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3799 } |
| 38 | 3800 GFX_write_string_color(Font, &hgfx, text, 0, color); |
| 3801 } | |
| 3802 | |
| 3803 | |
| 3804 void gfx_write_topline_simple(GFX_DrawCfgScreen *tMscreen, const char *text, uint8_t color) | |
| 3805 { | |
| 3806 GFX_DrawCfgWindow hgfx; | |
| 3807 const tFont *Font = &FontT48; | |
| 3808 | |
| 3809 hgfx.Image = tMscreen; | |
| 3810 hgfx.WindowNumberOfTextLines = 1; | |
| 3811 hgfx.WindowLineSpacing = 0; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3812 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3813 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3814 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3815 |
| 38 | 3816 hgfx.WindowTab = 0; |
| 3817 hgfx.WindowX0 = 20; | |
| 3818 hgfx.WindowX1 = 779; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3819 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3820 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3821 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3822 hgfx.WindowY1 = 479; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3823 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3824 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3825 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3826 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3827 hgfx.WindowY0 = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3828 hgfx.WindowY1 = Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3829 } |
| 38 | 3830 GFX_write_label(Font, &hgfx, text, color); |
| 3831 } | |
| 3832 | |
| 3833 | |
| 3834 void gfx_write_page_number(GFX_DrawCfgScreen *tMscreen, uint8_t page, uint8_t total, uint8_t color) | |
| 3835 { | |
| 3836 GFX_DrawCfgWindow hgfx; | |
| 3837 const tFont *Font = &FontT48; | |
| 3838 char text[7]; | |
| 3839 uint8_t i, secondDigitPage, secondDigitTotal; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3840 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3841 SSettings* pSettings; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3842 pSettings = settingsGetPointer(); |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3843 |
|
509
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3844 if(total > 8) |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3845 { |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3846 Font = &FontT24; |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3847 } |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3848 |
| 38 | 3849 hgfx.Image = tMscreen; |
| 3850 hgfx.WindowNumberOfTextLines = 1; | |
| 3851 hgfx.WindowLineSpacing = 0; | |
| 3852 hgfx.WindowTab = 0; | |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3853 |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3854 if(!pSettings->FlipDisplay) |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3855 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3856 hgfx.WindowX1 = 779; |
|
509
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3857 if(Font == &FontT24) |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3858 { |
| 999 | 3859 hgfx.WindowX0 = hgfx.WindowX1 - (Font->spacesize*7); |
|
509
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3860 } |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3861 else |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3862 { |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3863 hgfx.WindowX0 = hgfx.WindowX1 - (Font->spacesize2Monospaced*3); |
|
56824129dd56
Show page number in small letters if more than 8 tabs are active
Ideenmodellierer
parents:
494
diff
changeset
|
3864 } |
|
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3865 hgfx.WindowY1 = 479; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3866 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3867 } |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3868 else |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3869 { |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3870 hgfx.WindowX1 = 25*5; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3871 hgfx.WindowX0 = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3872 hgfx.WindowY1 = Font->height;; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3873 hgfx.WindowY0 = 0; |
|
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3874 } |
| 38 | 3875 if(page > 99) |
| 3876 page = 99; | |
| 3877 if(total > 99) | |
| 3878 total = 99; | |
| 3879 | |
| 3880 i = 0; | |
| 3881 text[i++] = '\002'; | |
| 3882 | |
| 3883 secondDigitPage = page / 10; | |
| 3884 page -= secondDigitPage * 10; | |
| 3885 | |
| 3886 secondDigitTotal = total / 10; | |
| 3887 total -= secondDigitTotal * 10; | |
| 3888 | |
| 3889 if(secondDigitPage) | |
| 3890 text[i++] = '0' + secondDigitPage; | |
| 3891 text[i++] = '0' + page; | |
| 3892 | |
| 3893 text[i++] = '/'; | |
| 3894 | |
| 3895 if(secondDigitTotal) | |
| 3896 text[i++] = '0' + secondDigitTotal; | |
| 3897 text[i++] = '0' + total; | |
| 3898 | |
| 3899 text[i] = 0; | |
| 3900 | |
| 3901 GFX_clear_window_immediately(&hgfx); | |
| 3902 GFX_write_label(Font, &hgfx, text, color); | |
| 3903 } | |
| 3904 | |
| 3905 | |
| 3906 uint8_t gfx_number_to_string(uint8_t max_digits, _Bool fill, char *pText, uint32_t input) | |
| 3907 { | |
| 3908 uint8_t digits[10]; | |
| 3909 uint32_t number, divider; | |
| 3910 int first; | |
| 3911 uint8_t out; | |
| 3912 | |
| 3913 number = input; | |
| 3914 first = 0; | |
| 3915 divider = 1000000000; | |
| 3916 for(int i=9;i>=0;i--) | |
| 3917 { | |
| 3918 digits[i] = (uint8_t)(number / divider); | |
| 3919 number -= digits[i] * divider; | |
| 3920 divider /= 10; | |
| 3921 if((first == 0) && (digits[i] != 0)) | |
| 3922 first = i; | |
| 3923 } | |
| 3924 | |
| 3925 if((first + 1) > max_digits) | |
| 3926 { | |
| 3927 for(int i = 0; i<max_digits; i++) | |
| 3928 pText[i] = '9'; | |
| 3929 out = max_digits; | |
| 3930 } | |
| 3931 else if(fill) | |
| 3932 { | |
| 3933 int i = 0; | |
| 3934 for(int k = max_digits; k>0; k--) | |
| 3935 pText[i++] = digits[k -1] + '0'; | |
| 3936 out = max_digits; | |
| 3937 } | |
| 3938 else | |
| 3939 { | |
| 3940 int i = 0; | |
| 3941 for(int k = first; k>=0; k--) | |
| 3942 pText[i++] = digits[k] + '0'; | |
| 3943 out = i; | |
| 3944 } | |
| 3945 | |
| 3946 return out; | |
| 3947 } | |
| 3948 | |
| 3949 | |
| 3950 /* output is | |
| 3951 * 0-> | |
| 3952 * | | |
| 3953 * v | |
| 3954 * | |
| 3955 * input is | |
| 3956 * | |
| 3957 * -> | |
| 3958 * A | |
| 3959 * | | |
| 3960 * 0 | |
| 3961 */ | |
| 3962 void GFX_screenshot(void) | |
| 3963 { | |
| 3964 uint32_t pSource = GFX_get_pActualFrameTop(); | |
| 3965 uint32_t pSourceBottom =GFX_get_pActualFrameBottom(); | |
| 3966 uint32_t pBottomNew = getFrame(99); | |
| 3967 uint32_t pDestination = GFX_doubleBufferOne(); | |
| 3968 uint32_t sourceNow; | |
| 3969 | |
| 3970 | |
| 3971 uint32_t bot_leftStart = FrameHandler.actualBottom.leftStart; // x0 z.B. 0 | |
| 3972 uint32_t bot_bottomStart = FrameHandler.actualBottom.bottomStart; // y0 z.B. 25 | |
| 3973 uint32_t bot_width = FrameHandler.actualBottom.width; // 800 | |
| 3974 uint32_t bot_height = FrameHandler.actualBottom.height; // 390 | |
| 3975 | |
| 3976 struct split | |
| 3977 { | |
| 3978 uint8_t blue; | |
| 3979 uint8_t green; | |
| 3980 uint8_t red; | |
| 3981 uint8_t alpha; | |
| 3982 }; | |
| 3983 | |
| 3984 union inout_u | |
| 3985 { | |
| 3986 uint32_t in; | |
| 3987 struct split out; | |
| 3988 }; | |
| 3989 | |
| 3990 union inout_u value; | |
| 3991 | |
| 3992 /* test | |
| 3993 uint32_t pSourceTemp = pSource + (2*479); | |
| 3994 for (int j = 0xFFFF; j > 0x00FF; j -= 0x0100) | |
| 3995 { | |
| 3996 *(__IO uint16_t*)pSourceTemp = j; | |
| 3997 pSourceTemp += 480*2; | |
| 3998 } | |
| 3999 */ | |
| 4000 // Top Layer | |
| 4001 const unsigned width = 800, height = 480; | |
| 4002 const uint32_t heightX2 = height*2; | |
| 4003 | |
| 4004 for(unsigned y = 0; y < height; y++) | |
| 4005 { | |
| 4006 sourceNow = pSource + 2 * ((height - 1) - y); | |
| 4007 for(unsigned x = 0; x < width; x++) | |
| 4008 { | |
| 4009 // sourceNow += 2 * height * x + 2 * (height - 1 - y); | |
| 4010 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)]; | |
| 4011 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1); | |
| 4012 | |
| 4013 *(__IO uint8_t*)(pDestination++) = value.out.red; | |
| 4014 *(__IO uint8_t*)(pDestination++) = value.out.green; | |
| 4015 *(__IO uint8_t*)(pDestination++) = value.out.blue; | |
| 4016 *(__IO uint8_t*)(pDestination++) = value.out.alpha; | |
| 4017 sourceNow += heightX2; | |
| 4018 } | |
| 4019 } | |
| 4020 | |
| 4021 // Bottom Layer | |
| 4022 // build newBottom | |
| 4023 pSource = pSourceBottom; | |
| 4024 for(unsigned x = bot_leftStart; x < bot_leftStart+bot_width; x++) | |
| 4025 { | |
| 4026 for(unsigned y = bot_bottomStart; y < bot_bottomStart+bot_height; y++) | |
| 4027 { | |
| 4028 pDestination = pBottomNew + (2 * y); | |
| 4029 pDestination += heightX2 * x; | |
| 4030 *(__IO uint16_t*)(pDestination) = *(__IO uint16_t*)(pSource); | |
| 4031 pSource += 2; | |
| 4032 } | |
| 4033 } | |
| 4034 | |
| 4035 // output Bottom Layer | |
| 4036 pSource = pBottomNew; | |
| 4037 pDestination = GFX_doubleBufferTwo(); | |
| 4038 | |
| 4039 for(unsigned y = 0; y < height; y++) | |
| 4040 { | |
| 4041 sourceNow = pSource + 2 * ((height - 1) - y); | |
| 4042 for(unsigned x = 0; x < width; x++) | |
| 4043 { | |
| 4044 // sourceNow = pSource + 2 * height * x + 2 * (height - 1 - y); | |
| 4045 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)]; | |
| 4046 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1); | |
| 4047 | |
| 4048 *(__IO uint8_t*)(pDestination++) = value.out.red; | |
| 4049 *(__IO uint8_t*)(pDestination++) = value.out.green; | |
| 4050 *(__IO uint8_t*)(pDestination++) = value.out.blue; | |
| 4051 *(__IO uint8_t*)(pDestination++) = value.out.alpha; | |
| 4052 sourceNow += heightX2; | |
| 4053 } | |
| 4054 } | |
| 4055 releaseFrame(99,pBottomNew); | |
| 4056 /* | |
| 4057 // das kommt dazu! | |
| 4058 unsigned yEnd = 480 - FrameHandler.actualBottom.bottomStart; | |
| 4059 unsigned yStart = yEnd - FrameHandler.actualBottom.height; | |
| 4060 | |
| 4061 if(yStart > 0) | |
| 4062 { | |
| 4063 for(unsigned y = 0; y < yStart; y++) | |
| 4064 for(unsigned x = 0; x < width; x++) | |
| 4065 { | |
| 4066 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4067 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4068 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4069 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4070 } | |
| 4071 } | |
| 4072 for(unsigned y = yStart; y < yEnd; y++) | |
| 4073 for(unsigned x = 0; x < width; x++) | |
| 4074 { | |
| 4075 sourceNow = pSource + 2 * height * x + 2 * (height - 1 - y); | |
| 4076 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)]; | |
| 4077 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1); | |
| 4078 | |
| 4079 *(__IO uint8_t*)(pDestination++) = value.out.red; | |
| 4080 *(__IO uint8_t*)(pDestination++) = value.out.green; | |
| 4081 *(__IO uint8_t*)(pDestination++) = value.out.blue; | |
| 4082 *(__IO uint8_t*)(pDestination++) = value.out.alpha; | |
| 4083 } | |
| 4084 if(yEnd < 480) | |
| 4085 { | |
| 4086 for(unsigned y = yEnd; y < 480; y++) | |
| 4087 for(unsigned x = 0; x < width; x++) | |
| 4088 { | |
| 4089 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4090 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4091 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4092 *(__IO uint8_t*)(pDestination++) = 0; | |
| 4093 } | |
| 4094 } | |
| 4095 */ | |
| 4096 } | |
| 567 | 4097 |
| 870 | 4098 #ifndef BOOTLOADER_STANDALONE |
| 567 | 4099 tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font) |
| 4100 { | |
| 4101 uint32_t i; | |
| 4102 uint32_t found; | |
| 4103 | |
| 4104 found = 0; | |
| 4105 for(i=0;i<Font->length;i++) | |
| 4106 { | |
| 4107 if(Font->chars[i].code == character) | |
| 4108 { | |
| 4109 found = 1; | |
| 4110 break; | |
| 4111 } | |
| 4112 } | |
| 4113 if (!found && Font == &FontT54) | |
| 4114 { | |
| 699 | 4115 Font = (tFont *)&FontT54Extra; |
| 567 | 4116 } |
| 4117 else if (!found && (Font == &FontT84 || Font == &FontT84Spaced)) | |
| 4118 { | |
| 699 | 4119 Font = (tFont *)&FontT84Extra; |
| 567 | 4120 } |
| 4121 else if (!found && Font == &FontT105) | |
| 4122 { | |
| 699 | 4123 Font = (tFont *)&FontT105Extra; |
| 567 | 4124 } |
| 4125 | |
| 4126 return Font; | |
| 4127 } | |
| 870 | 4128 #endif |
| 567 | 4129 uint32_t GFX_Character_Width(uint8_t character, tFont *Font) |
| 4130 { | |
| 4131 uint32_t i; | |
| 870 | 4132 #ifndef BOOTLOADER_STANDALONE |
| 567 | 4133 uint32_t found; |
| 870 | 4134 #endif |
| 567 | 4135 |
| 4136 for(i=0;i<Font->length;i++) | |
| 4137 { | |
| 4138 if(Font->chars[i].code == character) | |
| 4139 { | |
| 4140 return Font->chars[i].image->width; | |
| 4141 } | |
| 4142 } | |
| 4143 | |
| 870 | 4144 #ifndef BOOTLOADER_STANDALONE |
| 567 | 4145 found = 0; |
| 4146 if (Font == &FontT54) | |
| 4147 { | |
| 4148 found = 1; | |
| 699 | 4149 Font = (tFont *)&FontT54Extra; |
| 567 | 4150 } |
| 4151 else if (Font == &FontT84 || Font == &FontT84Spaced) | |
| 4152 { | |
| 4153 found = 1; | |
| 699 | 4154 Font = (tFont *)&FontT84Extra; |
| 567 | 4155 } |
| 4156 else if (Font == &FontT105) | |
| 4157 { | |
| 4158 found = 1; | |
| 699 | 4159 Font = (tFont *)&FontT105Extra; |
| 567 | 4160 } |
| 4161 | |
| 4162 if (found) | |
| 4163 { | |
| 4164 for(i=0;i<Font->length;i++) | |
| 4165 { | |
| 4166 if(Font->chars[i].code == character) | |
| 4167 { | |
| 4168 return Font->chars[i].image->width; | |
| 4169 } | |
| 4170 } | |
| 4171 } | |
| 870 | 4172 #endif |
| 567 | 4173 return 0; |
| 4174 } | |
| 870 | 4175 |
| 4176 void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor) | |
| 4177 { | |
| 4178 char *p = text; | |
| 4179 uint8_t index = 0; | |
| 4180 | |
| 4181 while ((*p) && (index < MAX_COLOR_STRING_LENGTH)) | |
| 4182 { | |
| 4183 if (*p == '\020') | |
| 4184 { | |
| 4185 if(!GFX_is_colorschemeDiveStandard()) | |
| 4186 { | |
| 4187 *p = '\027'; | |
| 4188 } | |
| 4189 else if(alternativeColor != 0) | |
| 4190 { | |
| 4191 *p += alternativeColor; | |
| 4192 } | |
| 4193 } | |
| 4194 p++; | |
| 4195 index++; | |
| 4196 } | |
| 4197 } | |
| 4198 |
