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