Mercurial > public > ostc4
annotate Discovery/Src/gfx_engine.c @ 119:76fa42fc0b20 FlipDisplay
Cleanup writechar pointers
Fill screen with 0 if a line is skipped
author | Ideenmodellierer |
---|---|
date | Sun, 06 Jan 2019 22:33:26 +0100 |
parents | 79b19d56ab08 |
children | 0d97971b771b |
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 { |
114 | 916 pDestination = (uint16_t*)hgfx->FBStartAdress; |
917 pDestination += (hgfx->ImageHeight * (hgfx->ImageWidth - x0 + offset)) + (480 - y0+offset); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
918 stepdir = -1; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
919 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
920 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
921 { |
114 | 922 pDestination = (uint16_t*)hgfx->FBStartAdress; |
923 pDestination += (x0 - offset)*hgfx->ImageHeight + (y0-offset); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
924 stepdir = 1; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
925 } |
38 | 926 for(int x=thickness;x>0;x--) |
927 { | |
928 for(int y=thickness;y>0;y--) | |
929 { | |
930 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
931 pDestination += stepdir; |
38 | 932 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
933 pDestination += stepdir * (hgfx->ImageHeight - thickness); |
38 | 934 } |
935 } | |
936 | |
937 | |
938 void GFX_draw_thick_line(uint8_t thickness, GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) | |
939 { | |
940 if(thickness < 2) | |
941 GFX_draw_line(hgfx, start, stop, color); | |
942 | |
943 int x0 = start.x; | |
944 int y0 = start.y; | |
945 int x1 = stop.x; | |
946 int y1 = stop.y; | |
947 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; | |
948 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; | |
949 int err = (dx>dy ? dx : -dy)/2, e2; | |
950 | |
951 | |
952 if(start.x == stop.x) | |
953 { | |
954 if(start.y > stop.y) gfx_flip(&start,&stop); | |
955 for (int j = stop.y - start.y; j > 0; j--) | |
956 { | |
957 gfx_brush(thickness,hgfx,start.x,start.y++,color); | |
958 } | |
959 } | |
960 else | |
961 if(start.y == stop.y) | |
962 { | |
963 if(start.x > stop.x) gfx_flip(&start,&stop); | |
964 | |
965 for (int j = stop.x - start.x; j > 0; j--) | |
966 { | |
967 gfx_brush(thickness,hgfx,start.x++,start.y,color); | |
968 } | |
969 } | |
970 else // diagonal | |
971 { | |
972 for(;;) | |
973 { | |
974 gfx_brush(thickness,hgfx,x0,y0,color); | |
975 if (x0==x1 && y0==y1) break; | |
976 e2 = err; | |
977 if (e2 >-dx) { err -= dy; x0 += sx; } | |
978 if (e2 < dy) { err += dx; y0 += sy; } | |
979 } | |
980 } | |
981 } | |
982 | |
983 | |
984 void GFX_draw_line(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) | |
985 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
986 uint16_t* pDestination; |
38 | 987 uint32_t j; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
988 int16_t stepdir; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
989 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
990 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
991 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
992 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
993 /* horizontal line */ |
38 | 994 if(start.x == stop.x) |
995 { | |
996 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
|
997 |
114 | 998 pDestination = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
999 if(pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1000 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1001 pDestination += (800 - start.x) * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1002 pDestination += (480 - start.y); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1003 stepdir = -1; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1006 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1007 pDestination += start.x * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1008 pDestination += start.y; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1009 stepdir = 1; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1010 } |
38 | 1011 for (j = stop.y - start.y; j > 0; j--) |
1012 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1013 *(__IO uint16_t*)pDestination = 0xFF00 + color; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1014 pDestination += stepdir; |
38 | 1015 } |
1016 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1017 else /* vertical line ? */ |
38 | 1018 if(start.y == stop.y) |
1019 { | |
1020 if(start.x > stop.x) gfx_flip(&start,&stop); | |
114 | 1021 pDestination = (uint16_t*)hgfx->FBStartAdress; |
110
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 if(pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1024 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1025 pDestination += (800 - start.x) * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1026 pDestination += (480 - start.y); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1027 stepdir = -1; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1030 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1031 pDestination += start.x * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1032 pDestination += start.y; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1033 stepdir = 1; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1034 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1035 |
38 | 1036 for (j = stop.x - start.x; j > 0; j--) |
1037 { | |
1038 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1039 pDestination += stepdir * hgfx->ImageHeight; |
38 | 1040 } |
1041 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1042 else /* diagonal */ |
38 | 1043 { |
1044 int x0 = start.x; | |
1045 int y0 = start.y; | |
1046 int x1 = stop.x; | |
1047 int y1 = stop.y; | |
1048 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; | |
1049 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; | |
1050 int err = (dx>dy ? dx : -dy)/2, e2; | |
1051 | |
1052 for(;;) | |
1053 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1054 pDestination = (uint16_t*)hgfx->FBStartAdress; |
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 if(pSettings->FlipDisplay) |
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 pDestination += (((800 - x0) * hgfx->ImageHeight) + (480 - y0)); |
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 else |
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 pDestination += ((x0 * hgfx->ImageHeight) + y0); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1063 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1064 |
38 | 1065 *(__IO uint16_t*)pDestination = 0xFF00 + color; |
1066 if (x0==x1 && y0==y1) break; | |
1067 e2 = err; | |
1068 if (e2 >-dx) { err -= dy; x0 += sx; } | |
1069 if (e2 < dy) { err += dx; y0 += sy; } | |
1070 } | |
1071 } | |
1072 } | |
1073 | |
1074 | |
1075 void GFX_draw_image_monochrome(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image, uint8_t color) | |
1076 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1077 uint16_t* pDestination; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1078 uint32_t j; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1079 point_t start, stop; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1080 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1081 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1082 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1083 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1084 start.x = window.left; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1085 start.y = (hgfx->ImageHeight - image->height - window.top); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1086 stop.y = start.y + image->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1087 stop.x = start.x + image->width; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1088 j = 0; |
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 if(pSettings->FlipDisplay) |
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 for(int xx = start.x; xx < stop.x; xx++) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1093 { |
114 | 1094 pDestination = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1095 pDestination += (hgfx->ImageHeight - start.y) + (stop.x * hgfx->ImageHeight) ; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1096 pDestination -= (xx - start.x) * hgfx->ImageHeight; |
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 for(int yy = start.y; yy < stop.y; yy++) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1099 { |
114 | 1100 *(__IO uint16_t*)pDestination-- = (image->data[j++] << 8) + color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1101 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1102 } |
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 else |
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 for(int xx = start.x; xx < stop.x; xx++) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1107 { |
114 | 1108 pDestination = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1109 pDestination += xx * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1110 pDestination += start.y; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1111 for(int yy = start.y; yy < stop.y; yy++) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1112 { |
114 | 1113 *(__IO uint16_t*)pDestination++ = (image->data[j++] << 8) + color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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 |
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 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
|
1121 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1122 uint16_t* pDestination; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1123 |
38 | 1124 uint32_t j; |
1125 point_t start, stop; | |
1126 | |
1127 start.x = window.left; | |
1128 start.y = (hgfx->ImageHeight - image->height - window.top); | |
1129 stop.y = start.y + image->height; | |
1130 stop.x = start.x + image->width; | |
1131 j = 0; | |
1132 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1133 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1134 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1135 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1136 if(pSettings->FlipDisplay) |
38 | 1137 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1138 for(int xx = start.x; xx < stop.x; xx++) |
38 | 1139 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1140 pDestination = (uint16_t*)hgfx->FBStartAdress; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1141 pDestination += (hgfx->ImageHeight - start.y) + (stop.x * hgfx->ImageHeight); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1142 pDestination -= (xx - start.x) * hgfx->ImageHeight; |
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 for(int yy = start.y; yy < stop.y; yy++) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1145 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1146 // *(__IO uint16_t*)pDestination-- = image->data[j++] << 8 | 0xFF; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1147 *(__IO uint16_t*)pDestination-- = 0xFF << 8 | image->data[j++]; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1148 } |
38 | 1149 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1150 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1151 else |
38 | 1152 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1153 for(int xx = start.x; xx < stop.x; xx++) |
38 | 1154 { |
114 | 1155 pDestination = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1156 pDestination += xx * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1157 pDestination += start.y; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1158 for(int yy = start.y; yy < stop.y; yy++) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1159 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1160 *(__IO uint16_t*)pDestination++ = 0xFF << 8 | image->data[j++]; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1161 } |
38 | 1162 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1163 } |
38 | 1164 } |
1165 | |
1166 | |
1167 int16_Point_t switchToOctantZeroFrom(uint8_t octant, int16_t x, int16_t y) | |
1168 { | |
1169 int16_Point_t answer; | |
1170 switch(octant) | |
1171 { | |
1172 case 0:// return (x,y); | |
1173 answer.x = x; | |
1174 answer.y = y; | |
1175 break; | |
1176 case 1:// return (y,x); | |
1177 answer.x = y; | |
1178 answer.y = x; | |
1179 break; | |
1180 case 2:// return (y, -x); | |
1181 answer.x = y; | |
1182 answer.y = -x; | |
1183 break; | |
1184 case 3:// return (-x, y); | |
1185 answer.x = -x; | |
1186 answer.y = y; | |
1187 break; | |
1188 case 4:// return (-x, -y); | |
1189 answer.x = -x; | |
1190 answer.y = -y; | |
1191 break; | |
1192 case 5:// return (-y, -x); | |
1193 answer.x = -y; | |
1194 answer.y = -x; | |
1195 break; | |
1196 case 6:// return (-y, x); | |
1197 answer.x = -y; | |
1198 answer.y = x; | |
1199 break; | |
1200 case 7:// return (x, -y); | |
1201 answer.x = x; | |
1202 answer.y = -y; | |
1203 break; | |
1204 } | |
1205 return answer; | |
1206 } | |
1207 | |
1208 /* this is NOT fast nor optimized */ | |
1209 void GFX_draw_pixel(GFX_DrawCfgScreen *hgfx, int16_t x, int16_t y, uint8_t color) | |
1210 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1211 uint16_t* pDestination; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1212 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1213 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1214 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1215 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1216 pDestination = (uint16_t*)hgfx->FBStartAdress; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1217 if(pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1218 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1219 pDestination += (800 - x) * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1220 pDestination += (480 - y); |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1223 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1224 pDestination += x * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1225 pDestination += y; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1226 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1227 *(__IO uint16_t*)pDestination = 0xFF << 8 | color; |
38 | 1228 } |
1229 | |
1230 | |
1231 /* store the quarter circle for given radius */ | |
1232 void GFX_draw_circle_with_MEMORY(uint8_t use_memory, GFX_DrawCfgScreen *hgfx, point_t center, uint8_t radius, int8_t color) | |
1233 { | |
1234 } | |
1235 | |
1236 /* this is NOT fast nor optimized */ | |
1237 void GFX_draw_circle(GFX_DrawCfgScreen *hgfx, point_t center, uint8_t radius, int8_t color) | |
1238 { | |
1239 int x, y; | |
1240 int l; | |
1241 int r2, y2; | |
1242 int y2_new; | |
1243 int ty; | |
1244 | |
1245 /* cos pi/4 = 185363 / 2^18 (approx) */ | |
1246 l = (radius * 185363) >> 18; | |
1247 | |
1248 /* hw */ | |
1249 l += 1; | |
1250 | |
1251 /* At x=0, y=radius */ | |
1252 y = radius; | |
1253 | |
1254 r2 = y2 = y * y; | |
1255 ty = (2 * y) - 1; | |
1256 y2_new = r2 + 3; | |
1257 | |
1258 for (x = 0; x <= l; x++) { | |
1259 y2_new -= (2 * x) - 3; | |
1260 | |
1261 if ((y2 - y2_new) >= ty) { | |
1262 y2 -= ty; | |
1263 y -= 1; | |
1264 ty -= 2; | |
1265 } | |
1266 | |
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 GFX_draw_pixel (hgfx, -x + center.x, y + center.y, color); | |
1270 GFX_draw_pixel (hgfx, -x + center.x, -y + center.y, color); | |
1271 | |
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 GFX_draw_pixel (hgfx, -y + center.x, x + center.y, color); | |
1275 GFX_draw_pixel (hgfx, -y + center.x, -x + center.y, color); | |
1276 } | |
1277 } | |
1278 | |
1279 | |
1280 void GFX_draw_colorline(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color) | |
1281 { | |
1282 uint32_t pDestination; | |
1283 uint32_t j; | |
1284 uint32_t temp; | |
1285 | |
1286 if(start.x == stop.x) | |
1287 { | |
1288 if(stop.y < start.y) | |
1289 { | |
1290 temp = stop.y; | |
1291 stop.y = start.y; | |
1292 start.y = temp; | |
1293 } | |
1294 pDestination = (uint32_t)hgfx->FBStartAdress; | |
1295 pDestination += start.x * hgfx->ImageHeight * 2; | |
1296 pDestination += start.y * 2; | |
1297 for (j = stop.y - start.y; j > 0; j--) | |
1298 { | |
1299 *(__IO uint8_t*)pDestination = color; | |
1300 pDestination += 1; | |
1301 *(__IO uint8_t*)pDestination = 0xFF; | |
1302 pDestination += 1; | |
1303 } | |
1304 } | |
1305 else | |
1306 if(start.y == stop.y) | |
1307 { | |
1308 if(stop.x < start.x) | |
1309 { | |
1310 temp = stop.x; | |
1311 stop.x = start.x; | |
1312 start.x = temp; | |
1313 } | |
1314 pDestination = (uint32_t)hgfx->FBStartAdress; | |
1315 pDestination += start.x * hgfx->ImageHeight * 2; | |
1316 pDestination += start.y * 2; | |
1317 for (j = stop.x - start.x; j > 0; j--) | |
1318 { | |
1319 *(__IO uint8_t*)pDestination = color; | |
1320 pDestination += 1; | |
1321 *(__IO uint8_t*)pDestination = 0xFF; | |
1322 pDestination -= 1; | |
1323 pDestination += hgfx->ImageHeight * 2; | |
1324 } | |
1325 } | |
1326 else // diagonal Bresenham's_line_algorithm | |
1327 { | |
1328 int x0 = start.x; | |
1329 int y0 = start.y; | |
1330 int x1 = stop.x; | |
1331 int y1 = stop.y; | |
1332 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1; | |
1333 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1; | |
1334 int err = (dx>dy ? dx : -dy)/2, e2; | |
1335 | |
1336 for(;;) | |
1337 { | |
1338 pDestination = (uint32_t)hgfx->FBStartAdress; | |
1339 pDestination += ((x0 * hgfx->ImageHeight) + y0) * 2; | |
1340 *(__IO uint8_t*)pDestination = color; | |
1341 pDestination += 1; | |
1342 *(__IO uint8_t*)pDestination = 0xFF; | |
1343 if (x0==x1 && y0==y1) break; | |
1344 e2 = err; | |
1345 if (e2 >-dx) { err -= dy; x0 += sx; } | |
1346 if (e2 < dy) { err += dx; y0 += sy; } | |
1347 } | |
1348 } | |
1349 } | |
1350 | |
1351 | |
1352 void GFX_draw_Grid(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, int vlines, float vdeltaline, int hlines, float hdeltalines, uint8_t color) | |
1353 { | |
1354 point_t p1; | |
1355 point_t p2; | |
1356 int winthight = window.bottom - window.top; | |
1357 int winwidth = window.right - window.left; | |
1358 float deltaline = 0; | |
1359 | |
1360 if(vlines > 0) | |
1361 { | |
1362 deltaline = ((float)winwidth) /vlines; | |
1363 | |
1364 p1.y = 479 - window.top; | |
1365 p2.y = 479 - window.bottom; | |
1366 for(int i = 0; i <= vlines; i++) | |
1367 { | |
1368 p1.x = window.left + (int)(i * deltaline + 0.5f); | |
1369 p2.x = p1.x ; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1370 //GFX_draw_colorline(hgfx, p1,p2, color ); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1371 GFX_draw_line(hgfx, p1,p2, color ); |
38 | 1372 } |
1373 } | |
1374 if(vdeltaline > 0) | |
1375 { | |
1376 p1.y = 479 - window.top; | |
1377 p2.y = 479 - window.bottom; | |
1378 for(int i = 0; i < winwidth/vdeltaline; i++) | |
1379 { | |
1380 p1.x = window.left + (int)(i * vdeltaline + 0.5f); | |
1381 p2.x = p1.x ; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1382 // GFX_draw_colorline(hgfx, p1,p2, color ); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1383 GFX_draw_line(hgfx, p1,p2, color ); |
38 | 1384 } |
1385 } | |
1386 if(hlines > 0) | |
1387 { | |
1388 deltaline = ((float)winthight)/hlines; | |
1389 p1.x = window.left; | |
1390 p2.x = window.right; | |
1391 for(int i = 0; i <= hlines; i++) | |
1392 { | |
1393 p1.y = 479 - window.top - (int)(i * deltaline + 0.5f); | |
1394 p2.y = p1.y; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1395 // GFX_draw_colorline(hgfx, p1,p2, color ); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1396 GFX_draw_line(hgfx, p1,p2, color ); |
38 | 1397 } |
1398 } | |
1399 } | |
1400 | |
1401 /* drawVeilUntil ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe | |
1402 * Xdivide ist nichr benutzt, wird weggelassen in dieser Version | |
1403 */ | |
1404 /* | |
1405 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) | |
1406 { | |
1407 if(window->bottom > 479) | |
1408 return; | |
1409 if(window->top > 479) | |
1410 return; | |
1411 if(window->right > 799) | |
1412 return; | |
1413 if(window->left > 799) | |
1414 return; | |
1415 if(window->bottom < 0) | |
1416 return; | |
1417 if(window->top < 0) | |
1418 return; | |
1419 if(window->right < 0) | |
1420 return; | |
1421 if(window->left < 0) | |
1422 return; | |
1423 if(window->bottom <= window->top) | |
1424 return; | |
1425 if(window->right <= window->left) | |
1426 return; | |
1427 | |
1428 uint16_t windowwidth = (uint16_t)window->right - (uint16_t)window->left; | |
1429 | |
1430 if(dataMax == dataMin) | |
1431 dataMax++; | |
1432 | |
1433 uint8_t invert = 0; | |
1434 if(dataMin > dataMax) | |
1435 { | |
1436 uint16_t dataFlip; | |
1437 dataFlip = dataMin; | |
1438 dataMin = dataMax; | |
1439 dataMax = dataFlip; | |
1440 invert = 1; | |
1441 } | |
1442 else | |
1443 invert = 0; | |
1444 | |
1445 uint16_t dataDelta = 0; | |
1446 dataDelta = dataMax - dataMin; | |
1447 | |
1448 uint8_t colormask = color; | |
1449 | |
1450 uint16_t loopX, loopData; | |
1451 loopX = 0; | |
1452 loopData = 0; | |
1453 while((loopX <= windowwidth) & (loopData < datalength)) | |
1454 { | |
1455 | |
1456 } | |
1457 | |
1458 | |
1459 uint32_t pDestination_zero_veil = 0; | |
1460 uint32_t pDestination = 0; | |
1461 uint32_t pDestinationOld = 0; | |
1462 int windowwidth = -1; | |
1463 int windowheight = -1; | |
1464 int w1 = -1; | |
1465 int w2 = -1; | |
1466 int value = -1; | |
1467 uint8_t colormask = 0; | |
1468 | |
1469 // preparation | |
1470 windowheight = window->bottom - window->top; | |
1471 windowwidth = window->right - window->left; | |
1472 pDestination_zero_veil = hgfx->FBStartAdress + 2 * ( (479 - (drawVeilUntil - 2) ) + ( (window->left) * hgfx->ImageHeight) ); | |
1473 | |
1474 while((w1 <= windowwidth) & (w2 < datalength)) | |
1475 { | |
1476 // before | |
1477 if(colour_data != NULL) | |
1478 { | |
1479 colormask = color + colour_data[w2]; | |
1480 } | |
1481 pDestination = hgfx->FBStartAdress + 2 * ( (479 - (window->top + value) ) + ( (w1 + window->left) * hgfx->ImageHeight) ); | |
1482 | |
1483 // after | |
1484 pDestination_zero_veil += (window->left) * hgfx->ImageHeight; | |
1485 } | |
1486 } | |
1487 */ | |
1488 | |
1489 | |
1490 | |
1491 // =============================================================================== | |
1492 // GFX_graph_print | |
1493 /// @brief Print all those nice curves, especially in logbook und miniLiveLogGraph | |
1494 /// @version 0.0.2 hw 160519 | |
1495 /// | |
1496 /// 151022 hw -bug fix | |
1497 /// - die aktuelle Version macht keine Linien mehr �ber die gesamte Bildschirmh�he. | |
1498 /// - daf�r sind L�cher in der Kurve (z.B. Temperaturgraph Tauchgang Matthias 17.10.15 15:19) | |
1499 /// | |
1500 /// more details about range can be found in show_logbook_logbook_show_log_page2() - temperature graph | |
1501 /// | |
1502 /// @param window: top and bottom is only the range used by the data of the graph, not the entire screen / scale | |
1503 /// @param drawVeilUntil: ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe | |
1504 /// @param Xdivide: wird bisher nichr benutzt. | |
1505 // =============================================================================== | |
1506 | |
1507 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1508 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 | 1509 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1510 uint16_t* pDestination_tmp; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1511 uint16_t* pDestination_start; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1512 uint16_t* pDestination_end; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1513 uint16_t* pDestination_zero_veil; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1514 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1515 SSettings* pSettings; |
38 | 1516 |
1517 uint32_t max = 0; | |
1518 int windowheight = -1; | |
1519 int windowwidth = -1; | |
1520 int i = -1; | |
1521 int w1 = -1; | |
1522 int w2 = -1; | |
1523 | |
1524 uint32_t h_ulong = 0; | |
1525 uint32_t h_ulong_old = 0; | |
1526 _Bool invert = 0; | |
1527 | |
1528 uint16_t dataDelta = 0; | |
1529 uint16_t dataDeltaHalve = 0; | |
1530 uint16_t dataTemp = 0; | |
1531 | |
1532 uint8_t colorDataTemp; | |
1533 uint8_t colormask = 0; | |
1534 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1535 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1536 pDestination_zero_veil = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1537 |
38 | 1538 if(dataMin > dataMax) |
1539 { | |
1540 uint16_t dataFlip; | |
1541 dataFlip = dataMin; | |
1542 dataMin = dataMax; | |
1543 dataMax = dataFlip; | |
1544 invert = 1; | |
1545 } | |
1546 else | |
1547 invert = 0; | |
1548 | |
1549 colormask = color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1550 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1551 pSettings = settingsGetPointer(); |
38 | 1552 |
1553 if(window->bottom > 479) | |
1554 return; | |
1555 if(window->top > 479) | |
1556 return; | |
1557 if(window->right > 799) | |
1558 return; | |
1559 if(window->left > 799) | |
1560 return; | |
1561 if(window->bottom < 0) | |
1562 return; | |
1563 if(window->top < 0) | |
1564 return; | |
1565 if(window->right < 0) | |
1566 return; | |
1567 if(window->left < 0) | |
1568 return; | |
1569 if(window->bottom <= window->top) | |
1570 return; | |
1571 if(window->right <= window->left) | |
1572 return; | |
1573 | |
1574 windowheight = window->bottom - window->top ; | |
1575 windowwidth = window->right - window->left; | |
1576 w1 = 0; | |
1577 w2 = 0; | |
1578 if(dataMax == dataMin) | |
1579 dataMax++; | |
1580 dataDelta = (unsigned long)(dataMax - dataMin); | |
1581 dataDeltaHalve = dataDelta / 2; | |
1582 while((w1 <= windowwidth) & (w2 < datalength)) | |
1583 { | |
1584 int tmp = (10 * w1 * (long)datalength)/windowwidth; | |
1585 w2 = tmp/10; | |
1586 int rest = tmp - w2*10; | |
1587 if(rest >= 5) | |
1588 w2++; | |
1589 | |
1590 if((datalength - 1) < w2) | |
1591 w2 = datalength-1; | |
1592 | |
1593 if(colour_data != NULL) | |
1594 { | |
1595 colorDataTemp = colour_data[w2]; | |
1596 colormask = color + colorDataTemp; | |
1597 } | |
1598 | |
1599 dataTemp = data[w2]; | |
1600 if(Xdivide > 1) | |
1601 { | |
1602 w2++; | |
1603 for(i=1;i<Xdivide;i++) | |
1604 { | |
1605 if(data[w2]>dataTemp) | |
1606 dataTemp = data[w2]; | |
1607 w2++; | |
1608 } | |
1609 } | |
1610 | |
1611 if(dataTemp > dataMin) | |
1612 dataTemp -= dataMin; | |
1613 else | |
1614 dataTemp = 0; | |
1615 | |
1616 if(invert) | |
1617 { | |
1618 if(dataTemp < dataDelta) | |
1619 dataTemp = dataDelta - dataTemp; | |
1620 else | |
1621 dataTemp = 0; | |
1622 } | |
1623 | |
1624 h_ulong = (unsigned long)dataTemp; | |
1625 h_ulong *= windowheight; | |
1626 h_ulong += dataDeltaHalve; | |
1627 h_ulong /= dataDelta; | |
1628 | |
1629 if(h_ulong > (window->bottom - window->top)) | |
1630 h_ulong = (window->bottom - window->top); | |
1631 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1632 if(!pSettings->FlipDisplay) |
38 | 1633 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1634 if(drawVeilUntil > 0) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1635 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1636 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1637 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
|
1638 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1639 else if(drawVeilUntil < 0 ) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1640 { |
114 | 1641 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1642 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
|
1643 } |
38 | 1644 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1645 else |
38 | 1646 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1647 if(drawVeilUntil > 0) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1648 { |
114 | 1649 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1650 pDestination_zero_veil += (((drawVeilUntil) ) + ( (window->right - w1) * hgfx->ImageHeight) ); |
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 else if(drawVeilUntil < 0 ) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1653 { |
114 | 1654 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1655 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
|
1656 } |
38 | 1657 } |
1658 if(h_ulong + window->top > max) | |
1659 { | |
1660 max = h_ulong + window->top; | |
1661 } | |
1662 | |
1663 // hw 160519 wof�r ist das? Damit funktioniert Temperatur 25,5�C nicht! | |
1664 // if((dataMax == 255) || (data[w2] != 255)) | |
1665 // { | |
1666 //output_content[pointer] = colormask; | |
1667 //output_mask[pointer] = true; | |
1668 if(w1 > 0) | |
1669 { | |
114 | 1670 pDestination_start = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1671 if(!pSettings->FlipDisplay) |
38 | 1672 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1673 pDestination_start += (((479 - (window->top)) + ((w1 + window->left) * hgfx->ImageHeight))); |
38 | 1674 } |
1675 else | |
1676 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1677 pDestination_start += (((window->top) + ((window->right - w1) * hgfx->ImageHeight))); |
38 | 1678 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1679 pDestination_end = pDestination_start; |
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(!pSettings->FlipDisplay) |
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 if(h_ulong >= h_ulong_old) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1684 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1685 pDestination_start -= h_ulong_old; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1686 pDestination_end -= h_ulong; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1689 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1690 pDestination_start -= h_ulong; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1691 pDestination_end -= h_ulong_old; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1692 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1693 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1694 else |
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 if(h_ulong < h_ulong_old) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1697 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1698 pDestination_start += h_ulong_old; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1699 pDestination_end += h_ulong; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1702 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1703 pDestination_start += h_ulong; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1704 pDestination_end += h_ulong_old; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1705 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1706 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1707 |
38 | 1708 |
1709 // deco stops | |
1710 if(drawVeilUntil < 0) | |
1711 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1712 if(!pSettings->FlipDisplay) |
38 | 1713 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1714 pDestination_tmp = pDestination_end; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1715 while(pDestination_tmp <= pDestination_zero_veil) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1716 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1717 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1718 pDestination_tmp++; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1719 } |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1722 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1723 pDestination_tmp = pDestination_zero_veil; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1724 while(pDestination_tmp <= pDestination_end) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1725 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1726 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1727 pDestination_tmp++; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1728 } |
38 | 1729 } |
1730 } | |
1731 else | |
1732 { | |
1733 // regular graph with veil underneath if requested | |
1734 // von oben nach unten | |
1735 // von grossen pDestination Werten zu kleinen pDestination Werten | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1736 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1737 pDestination_tmp = pDestination_start; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1738 while(pDestination_tmp >= pDestination_end) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1739 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1740 *(__IO uint16_t*)pDestination_tmp = (0xFF << 8) | colormask ; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1741 pDestination_tmp--; |
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 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1744 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1745 if(!pSettings->FlipDisplay) |
38 | 1746 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1747 while((drawVeilUntil > 0) && (pDestination_tmp >= pDestination_zero_veil)) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1748 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1749 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1750 pDestination_tmp--; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1751 } |
38 | 1752 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1753 else |
38 | 1754 { |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1755 pDestination_tmp = pDestination_start; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1756 while((drawVeilUntil > 0) && (pDestination_tmp <= pDestination_zero_veil)) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1757 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1758 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1759 pDestination_tmp++; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1760 } |
38 | 1761 } |
1762 } | |
1763 } | |
1764 h_ulong_old = h_ulong; | |
1765 // } | |
1766 w1++; | |
1767 w2++; | |
1768 } | |
1769 } | |
1770 | |
1771 | |
1772 void GFX_draw_header(GFX_DrawCfgScreen *hgfx, uint8_t colorId) | |
1773 { | |
1774 uint32_t pDestination; | |
1775 point_t start, stop, now; | |
1776 uint8_t alpha; | |
1777 | |
1778 /* display coordinate system */ | |
1779 start.y = 400; | |
1780 stop.y = 479; | |
1781 | |
1782 start.x = 0; | |
1783 stop.x = 799; | |
1784 | |
1785 now.y = start.y; | |
1786 now.x = start.x; | |
1787 | |
1788 while (now.x <= stop.x) | |
1789 { | |
1790 now.y = start.y; | |
1791 pDestination = (uint32_t)hgfx->FBStartAdress; | |
1792 pDestination += now.x * hgfx->ImageHeight * 2; | |
1793 pDestination += now.y * 2; | |
1794 now.x += 1; | |
1795 | |
1796 alpha = 27; | |
1797 while(alpha < 246) | |
1798 { | |
1799 alpha += 9; | |
1800 *(__IO uint8_t*)pDestination = colorId; | |
1801 pDestination += 1; | |
1802 *(__IO uint8_t*)pDestination = alpha; | |
1803 pDestination += 1; | |
1804 now.y += 1; | |
1805 } | |
1806 | |
1807 while(now.y <= stop.y) | |
1808 { | |
1809 *(__IO uint8_t*)pDestination = colorId; | |
1810 pDestination += 1; | |
1811 *(__IO uint8_t*)pDestination = 0xFF; | |
1812 pDestination += 1; | |
1813 now.y += 1; | |
1814 } | |
1815 } | |
1816 } | |
1817 | |
1818 void GFX_draw_box2(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color, uint8_t roundCorners) | |
1819 { | |
1820 point_t point2, point4; | |
1821 | |
1822 if(roundCorners) | |
1823 { | |
1824 point2.x = stop.x - start.x; | |
1825 point2.y = stop.y - start.y; | |
1826 GFX_draw_box(hgfx,start,point2,1,color); | |
1827 } | |
1828 else | |
1829 { | |
1830 point2.x = stop.x; | |
1831 point2.y = start.y; | |
1832 | |
1833 point4.x = start.x; | |
1834 point4.y = stop.y; | |
1835 | |
1836 GFX_draw_line(hgfx,start,point2,color); | |
1837 GFX_draw_line(hgfx,point2,stop,color); | |
1838 GFX_draw_line(hgfx,stop,point4,color); | |
1839 GFX_draw_line(hgfx,point4,start,color); | |
1840 } | |
1841 } | |
1842 | |
1843 void GFX_draw_box(GFX_DrawCfgScreen *hgfx, point_t LeftLow, point_t WidthHeight, uint8_t Style, uint8_t color) | |
1844 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1845 uint16_t* pDestination; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1846 uint16_t* pStart; |
38 | 1847 uint32_t j; |
1848 uint32_t lineWidth, lineHeight; | |
1849 int x, y; | |
1850 uint8_t intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1851 int stepdir; |
38 | 1852 |
1853 typedef struct { | |
1854 int x; | |
1855 int y; | |
1856 uint8_t intensity; | |
1857 } corner_t; | |
1858 const corner_t corner[16] = { | |
1859 {3,3,255}, // nur einmal | |
1860 {9,0,242}, | |
1861 {8,0,194}, | |
1862 {7,0,115}, | |
1863 {6,0,36}, | |
1864 {9,1,33}, | |
1865 {8,1,84}, | |
1866 {7,1,161}, | |
1867 {6,1,255}, | |
1868 {5,1,242}, | |
1869 {4,1,36}, | |
1870 {6,2,33}, | |
1871 {5,2,84}, | |
1872 {4,2,255}, | |
1873 {3,2,84}, | |
1874 {4,3,110} | |
1875 }; | |
1876 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1877 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1878 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1879 |
38 | 1880 lineWidth = WidthHeight.x; |
1881 lineHeight = WidthHeight.y; | |
114 | 1882 pStart = (uint16_t*)hgfx->FBStartAdress; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1883 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1884 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1885 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1886 pStart += LeftLow.x * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1887 pStart += LeftLow.y; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1888 stepdir = 1; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1891 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1892 pStart += (800 - LeftLow.x - 1) * hgfx->ImageHeight; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1893 pStart += (480 - LeftLow.y); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1894 stepdir = -1; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1895 } |
38 | 1896 |
1897 // Untere Linie | |
1898 pDestination = pStart; | |
1899 if(Style) | |
1900 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1901 pDestination += stepdir * 10 * hgfx->ImageHeight; |
38 | 1902 lineWidth -= 18; |
1903 } | |
1904 for (j = lineWidth; j > 0; j--) | |
1905 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1906 |
38 | 1907 *(__IO uint16_t*)pDestination = 0xFF00 + color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1908 pDestination += stepdir * hgfx->ImageHeight; |
38 | 1909 } |
1910 | |
1911 // Obere Linie | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1912 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1913 pDestination = pStart + stepdir * WidthHeight.y; |
38 | 1914 if(Style) |
1915 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1916 pDestination += stepdir * 10 * hgfx->ImageHeight; |
38 | 1917 } |
1918 | |
1919 for (j = lineWidth; j > 0; j--) | |
1920 { | |
1921 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1922 pDestination += stepdir * hgfx->ImageHeight; |
38 | 1923 } |
1924 | |
1925 // Linke Linie | |
1926 pDestination = pStart; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1927 |
38 | 1928 if(Style) |
1929 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1930 pDestination += stepdir * 10; |
38 | 1931 lineHeight -= 18; |
1932 } | |
1933 | |
1934 for (j = lineHeight; j > 0; j--) | |
1935 { | |
1936 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1937 pDestination += stepdir; |
38 | 1938 } |
1939 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1940 |
38 | 1941 // Rechte Linie |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1942 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1943 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight; |
38 | 1944 if(Style) |
1945 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1946 pDestination += stepdir * 10; |
38 | 1947 } |
1948 | |
1949 for (j = lineHeight; j > 0; j--) | |
1950 { | |
1951 *(__IO uint16_t*)pDestination = 0xFF00 + color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1952 pDestination += stepdir; |
38 | 1953 } |
1954 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1955 |
38 | 1956 // Ecken wenn notwendig == Style |
1957 if(Style) | |
1958 { | |
1959 // links unten | |
1960 pDestination = pStart; | |
1961 x = corner[0].x; | |
1962 y = corner[0].y; | |
1963 intensity = corner[0].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1964 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1965 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 1966 |
1967 for(j = 15; j > 0; j--) | |
1968 { | |
1969 x = corner[j].x; | |
1970 y = corner[j].y; | |
1971 intensity = corner[j].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1972 *(__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
|
1973 *(__IO uint16_t*)(pDestination + stepdir * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 1974 } |
1975 // links oben | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1976 pDestination = pStart + stepdir * WidthHeight.y; |
38 | 1977 x = corner[0].x; |
1978 y = corner[0].y; | |
1979 intensity = corner[0].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1980 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 1981 |
1982 for(j = 15; j > 0; j--) | |
1983 { | |
1984 x = corner[j].x; | |
1985 y = corner[j].y; | |
1986 intensity = corner[j].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1987 *(__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
|
1988 *(__IO uint16_t*)(pDestination + stepdir * (-x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 1989 } |
1990 // rechts unten | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1991 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight; |
38 | 1992 x = corner[0].x; |
1993 y = corner[0].y; | |
1994 intensity = corner[0].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
1995 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 1996 |
1997 for(j = 15; j > 0; j--) | |
1998 { | |
1999 x = corner[j].x; | |
2000 y = corner[j].y; | |
2001 intensity = corner[j].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2002 *(__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
|
2003 *(__IO uint16_t*)(pDestination + stepdir * (x - (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 2004 } |
2005 // rechts oben | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2006 pDestination = pStart + stepdir * WidthHeight.y + stepdir * WidthHeight.x * hgfx->ImageHeight; |
38 | 2007 x = corner[0].x; |
2008 y = corner[0].y; | |
2009 intensity = corner[0].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2010 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 2011 |
2012 for(j = 15; j > 0; j--) | |
2013 { | |
2014 x = corner[j].x; | |
2015 y = corner[j].y; | |
2016 intensity = corner[j].intensity; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2017 *(__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
|
2018 *(__IO uint16_t*)(pDestination + stepdir * -1 * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color; |
38 | 2019 } |
2020 } | |
2021 } | |
2022 | |
2023 | |
2024 | |
2025 | |
2026 /** | |
2027 ****************************************************************************** | |
2028 * @brief GFX write label. / Write string with defined color | |
2029 * @author heinrichs weikamp gmbh | |
2030 * @version V0.0.1 | |
2031 * @date 07-July-2014 | |
2032 ****************************************************************************** | |
2033 * | |
2034 * @param hgfx: check gfx_engine.h. | |
2035 * @param color: 16bit Alpha+CLUT. | |
2036 * @retval None | |
2037 */ | |
2038 | |
2039 uint32_t GFX_write_label(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint8_t color) | |
2040 { | |
2041 return GFX_write_string_color(Font, hgfx, pText, 0, color); | |
2042 } | |
2043 | |
2044 | |
2045 /** | |
2046 ****************************************************************************** | |
2047 * @brief GFX writeGfx_write_label_varstring. / Write string with all parameters and font color options | |
2048 * @author Peter Ryser | |
2049 * @version V0.0.1 | |
2050 * @date 22-April-2014 | |
2051 ****************************************************************************** | |
2052 * | |
2053 * @param XleftGimpStyle: | |
2054 * @param XrightGimpStyle: | |
2055 * @param YtopGimpStyle: | |
2056 * @param color: | |
2057 * @param tFont: | |
2058 * @param text: text to be printed | |
2059 * @retval None | |
2060 */ | |
2061 | |
2062 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) | |
2063 { | |
2064 | |
2065 GFX_DrawCfgWindow hgfx; | |
2066 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2067 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2068 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2069 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2070 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2071 |
38 | 2072 if(XrightGimpStyle > 799) |
2073 XrightGimpStyle = 799; | |
2074 if(XleftGimpStyle >= XrightGimpStyle) | |
2075 XleftGimpStyle = 0; | |
2076 if(YtopGimpStyle > 479) | |
2077 YtopGimpStyle = 479; | |
2078 hgfx.Image = screenInput; | |
2079 hgfx.WindowNumberOfTextLines = 1; | |
2080 hgfx.WindowLineSpacing = 0; | |
2081 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2082 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2083 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2084 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2085 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2086 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2087 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2088 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2089 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2090 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2091 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2092 } |
38 | 2093 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2094 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2095 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2096 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2097 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2098 if(hgfx.WindowY0 + Font->height > 480) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2099 hgfx.WindowY1 = 480; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2100 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2101 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2102 } |
38 | 2103 GFX_write_label(Font, &hgfx, text, color); |
2104 } | |
2105 | |
2106 /** | |
2107 ****************************************************************************** | |
2108 * @brief GFX write string. / Write string with all parameters and font options | |
2109 * @author heinrichs weikamp gmbh | |
2110 * @version V0.0.1 | |
2111 * @date 22-April-2014 | |
2112 ****************************************************************************** | |
2113 * | |
2114 * @param hgfx: check gfx_engine.h. | |
2115 * @param color: 32bit ARGB8888. | |
2116 * @retval None | |
2117 */ | |
2118 | |
2119 uint16_t GFX_return_offset(const tFont *Font, char *pText, uint8_t position) | |
2120 { | |
2121 char character; | |
2122 uint16_t digit, i; | |
2123 uint8_t found; | |
2124 uint16_t distance; | |
2125 | |
2126 if(position == 0) | |
2127 return 0; | |
2128 | |
2129 distance = 0; | |
2130 for(digit = 0; digit < position; digit++) | |
2131 { | |
2132 character = pText[digit]; | |
2133 if(character == 0) | |
2134 return 0; | |
2135 | |
2136 found = 0; | |
2137 for(i=0;i<Font->length;i++) | |
2138 { | |
2139 if(Font->chars[i].code == character) | |
2140 { | |
2141 found = 1; | |
2142 break; | |
2143 } | |
2144 } | |
2145 if(found) | |
2146 { | |
2147 distance += (uint16_t)(Font->chars[i].image->width); | |
2148 if(Font == &FontT144) | |
2149 distance += 3; | |
2150 else | |
2151 if(Font == &FontT105) | |
2152 distance += 2; | |
2153 } | |
2154 } | |
2155 return distance; | |
2156 | |
2157 /* FEHLT: | |
2158 if(*pText < ' ') | |
2159 if((*pText) & 0x80) | |
2160 | |
2161 if(((tFont *)settings.font == &FontT105) && settings.dualFont && ((*pText == '.') || (*pText == ':'))) | |
2162 settings.font = (uint32_t)&FontT54; | |
2163 */ | |
2164 } | |
2165 | |
2166 void GFX_clean_line(GFX_DrawCfgWindow* hgfx, uint32_t line_number) | |
2167 { | |
2168 uint16_t height; | |
2169 uint32_t pDestination, i, j; | |
2170 uint16_t left, width, bottom, nextlineStep; | |
2171 | |
2172 bottom = hgfx->WindowY0; | |
2173 | |
2174 if(hgfx->WindowNumberOfTextLines && line_number && (line_number <= hgfx->WindowNumberOfTextLines)) | |
2175 { | |
2176 bottom += hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number); | |
2177 height = hgfx->WindowLineSpacing; | |
2178 } | |
2179 else | |
2180 { | |
2181 height = 1 + hgfx->WindowY1 - bottom; | |
2182 } | |
2183 | |
2184 pDestination = (uint32_t)hgfx->Image->FBStartAdress; | |
2185 | |
2186 left = hgfx->WindowX0; | |
2187 width = 1 + hgfx->WindowX1 - left; | |
2188 nextlineStep = hgfx->Image->ImageHeight - height; | |
2189 nextlineStep *= 2; | |
2190 pDestination += 2 * bottom; | |
2191 pDestination += 2 * hgfx->Image->ImageHeight * left; | |
2192 | |
2193 for(j = width; j > 0; j--) | |
2194 { | |
2195 for(i = height; i > 0; i--) | |
2196 { | |
2197 *(__IO uint16_t*)pDestination = 0; | |
2198 pDestination += 2; | |
2199 } | |
2200 pDestination += nextlineStep; | |
2201 } | |
2202 } | |
2203 | |
2204 | |
2205 void GFX_clean_area(GFX_DrawCfgScreen *tMscreen, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, uint16_t YBottomGimpStyle) | |
2206 { | |
2207 uint16_t height; | |
2208 uint32_t pDestination, i, j; | |
2209 int32_t left, width, bottom, nextlineStep; | |
2210 | |
2211 bottom = tMscreen->ImageHeight - YBottomGimpStyle; | |
2212 height = 1 + YBottomGimpStyle - YtopGimpStyle; | |
2213 | |
2214 if(bottom < 0) | |
2215 bottom = 0; | |
2216 if(height > tMscreen->ImageHeight) | |
2217 height = tMscreen->ImageHeight; | |
2218 | |
2219 pDestination = tMscreen->FBStartAdress; | |
2220 | |
2221 left = XleftGimpStyle; | |
2222 width = 1 + XrightGimpStyle - left; | |
2223 if(width < 1) | |
2224 width = 1; | |
2225 | |
2226 if(width > tMscreen->ImageWidth) | |
2227 width = tMscreen->ImageWidth; | |
2228 | |
2229 nextlineStep = tMscreen->ImageHeight - height; | |
2230 nextlineStep *= 2; | |
2231 pDestination += 2 * bottom; | |
2232 pDestination += 2 * tMscreen->ImageHeight * left; | |
2233 | |
2234 for(j = width; j > 0; j--) | |
2235 { | |
2236 for(i = height; i > 0; i--) | |
2237 { | |
2238 *(__IO uint16_t*)pDestination = 0; | |
2239 pDestination += 2; | |
2240 } | |
2241 pDestination += nextlineStep; | |
2242 } | |
2243 } | |
2244 | |
2245 | |
2246 uint32_t GFX_write_string(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint32_t line_number) | |
2247 { | |
2248 return GFX_write_string_color(Font, hgfx, pText, line_number, 0); | |
2249 } | |
2250 | |
2251 uint32_t GFX_write_string_color(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint32_t line_number, uint8_t color) | |
2252 { | |
2253 if(hgfx->Image->FBStartAdress < FBGlobalStart) | |
2254 return 0; | |
2255 | |
2256 GFX_CfgWriteString settings; | |
2257 uint32_t newXdelta; | |
2258 uint8_t minimal = 0; | |
2259 // uint32_t try_again; | |
2260 | |
2261 if(hgfx->WindowNumberOfTextLines && line_number && (line_number <= hgfx->WindowNumberOfTextLines)) | |
2262 { | |
2263 settings.Ydelta = hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number); | |
2264 } | |
2265 else | |
2266 { | |
2267 settings.Ydelta = 0; | |
2268 } | |
2269 settings.font = (uint32_t)Font; | |
2270 settings.Xdelta = 0; | |
2271 settings.color = color; | |
2272 settings.invert = 0; | |
2273 settings.resize = 0; | |
2274 settings.dualFont = 0; | |
2275 settings.spaceMode = 0; | |
2276 settings.singleSpaceWithSizeOfNextChar = 0; | |
2277 settings.useTinyFont = 0; | |
2278 settings.TinyFontExtraYdelta = 0; | |
2279 settings.TinyFont = (uint32_t)Font; | |
2280 settings.doubleSize = 0; | |
2281 | |
2282 if((*pText) == TXT_MINIMAL) // for customtext and anything with Sonderzeichen | |
2283 minimal = 1; | |
2284 else | |
2285 minimal = 0; | |
2286 | |
2287 if(Font == &FontT144) | |
2288 settings.TinyFont = (uint32_t)&FontT84; | |
2289 else | |
2290 if(Font == &FontT105) | |
2291 settings.TinyFont = (uint32_t)&FontT54; | |
2292 else | |
2293 if(Font == &FontT54) | |
2294 { | |
2295 settings.TinyFont = (uint32_t)&FontT48; | |
2296 settings.TinyFontExtraYdelta = -9; | |
2297 } | |
2298 else | |
2299 if(Font == &FontT48) | |
2300 { | |
2301 settings.TinyFont = (uint32_t)&FontT24; | |
2302 settings.TinyFontExtraYdelta = 6; | |
2303 } | |
2304 else | |
2305 if(Font == &FontT42) | |
2306 { | |
2307 settings.TinyFont = (uint32_t)&FontT24; | |
2308 settings.TinyFontExtraYdelta = 2; | |
2309 } | |
2310 | |
2311 settings.actualFont = (tFont *)settings.font; | |
2312 | |
2313 while ((*pText != 0) && (settings.Xdelta != 0x0000FFFF))// und fehlend: Abfrage window / image size | |
2314 { | |
2315 // try_again = 0; | |
2316 | |
2317 if((*pText == '\177') && !minimal) | |
2318 { | |
2319 if(settings.singleSpaceWithSizeOfNextChar) | |
2320 { | |
2321 settings.singleSpaceWithSizeOfNextChar = 0; | |
2322 pText++; | |
2323 settings.Xdelta += *pText; | |
2324 } | |
2325 else | |
2326 settings.singleSpaceWithSizeOfNextChar = 1; | |
2327 } | |
2328 else | |
2329 if(*pText < ' ') | |
2330 { | |
2331 /* Xdelta -inline- changes */ | |
2332 if((*pText == '\t') && !minimal) | |
2333 settings.Xdelta = hgfx->WindowTab - hgfx->WindowX0; | |
2334 else | |
2335 if(*pText == '\r') // carriage return, no newline | |
2336 settings.Xdelta = 0; | |
2337 else | |
2338 if((*pText == '\001') && !minimal) // center | |
2339 settings.Xdelta = GFX_write__Modify_Xdelta__Centered(&settings, hgfx, pText+1); | |
2340 else | |
2341 if((*pText == '\002') && !minimal) // right | |
2342 settings.Xdelta = GFX_write__Modify_Xdelta__RightAlign(&settings, hgfx, pText+1); | |
2343 else | |
2344 if((*pText == '\003') && !minimal) // doubleSize | |
2345 settings.doubleSize = 1; | |
2346 else | |
2347 /* Xdelta -up/down changes */ | |
2348 if((*pText == '\f') && !minimal) // form feed = top align | |
2349 { | |
2350 if((hgfx->WindowY1 - hgfx->WindowY0) >= ((tFont *)settings.font)->height) | |
2351 { | |
2352 settings.Ydelta = hgfx->WindowY1 - hgfx->WindowY0; | |
2353 settings.Ydelta -= ((tFont *)settings.font)->height; | |
2354 } | |
2355 } | |
2356 else | |
2357 if(*pText == '\n') // newline, no carriage return | |
2358 { | |
2359 if(hgfx->WindowNumberOfTextLines && (line_number < hgfx->WindowNumberOfTextLines)) | |
2360 { | |
2361 line_number++; | |
2362 settings.Ydelta = hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number); | |
2363 } | |
2364 } | |
2365 else | |
2366 /* Font style changes */ | |
2367 if(*pText == '\a') | |
2368 settings.invert = 1; | |
2369 else | |
2370 if((*pText == '\016') && !minimal) | |
2371 { | |
2372 if(settings.dualFont == 0) | |
2373 settings.dualFont = 1; | |
2374 else | |
2375 settings.actualFont = (tFont *)settings.TinyFont; | |
2376 } | |
2377 else | |
2378 if((*pText == '\017') && !minimal) | |
2379 { | |
2380 settings.dualFont = 0; | |
2381 settings.actualFont = (tFont *)settings.font; | |
2382 } | |
2383 else | |
2384 if((*pText == '\005') && !minimal) | |
2385 { | |
2386 newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48); | |
2387 settings.Xdelta = newXdelta; | |
2388 } | |
2389 else | |
2390 if((*pText == '\006') && !minimal) | |
2391 { | |
2392 newXdelta = GFX_write_char(hgfx, &settings, 'b', (tFont *)&Awe48); | |
2393 settings.Xdelta = newXdelta; | |
2394 } | |
2395 else | |
2396 if((*pText >= '\020') && (*pText <= '\032') && !minimal) | |
2397 settings.color = *pText - '\020'; | |
2398 else | |
2399 if((*pText == '\034') && !minimal) | |
2400 settings.spaceMode = 1; | |
2401 else | |
2402 if((*pText == '\035') && !minimal) | |
2403 settings.spaceMode = 0; | |
2404 } | |
2405 else | |
2406 if(((*pText) == TXT_2BYTE) && !minimal) | |
2407 { | |
2408 pText++; | |
2409 settings.Xdelta = GFX_write_substring(&settings, hgfx, (uint8_t)TXT_2BYTE, (int8_t)*pText); | |
2410 } | |
2411 else | |
2412 if(((*pText) & 0x80) && !minimal) | |
2413 settings.Xdelta = GFX_write_substring(&settings, hgfx, (uint8_t)*pText, 0); | |
2414 else | |
2415 if(!settings.invert && (*pText == ' ')) | |
2416 { | |
2417 if(settings.spaceMode == 0) | |
2418 settings.Xdelta += ((tFont *)settings.font)->spacesize; | |
2419 else | |
2420 settings.Xdelta += ((tFont *)settings.font)->spacesize2Monospaced; | |
2421 } | |
2422 else | |
2423 if((settings.spaceMode == 1) && (*pText == ' ')) | |
2424 settings.Xdelta += ((tFont *)settings.font)->spacesize2Monospaced; | |
2425 else | |
2426 { | |
2427 if(((tFont *)settings.font == &FontT144) && ((*pText == '.') || (*pText == ':'))) | |
2428 settings.actualFont = (tFont *)settings.TinyFont; | |
2429 else | |
2430 if(((tFont *)settings.font == &FontT105) && settings.dualFont && ((*pText == '.') || (*pText == ':'))) | |
2431 settings.actualFont = (tFont *)settings.TinyFont; | |
2432 | |
2433 if(settings.actualFont == (tFont *)settings.TinyFont) | |
2434 settings.Ydelta += settings.TinyFontExtraYdelta; | |
2435 | |
2436 newXdelta = GFX_write_char(hgfx, &settings, *(uint8_t *)pText, settings.actualFont); | |
2437 settings.Xdelta = newXdelta; | |
2438 | |
2439 if(settings.actualFont == (tFont *)settings.TinyFont) | |
2440 settings.Ydelta -= settings.TinyFontExtraYdelta; | |
2441 } | |
2442 if(pText != 0) /* for TXT_2BYTE */ | |
2443 pText++; | |
2444 } | |
2445 return settings.Ydelta; | |
2446 } | |
2447 | |
2448 /* Private functions ---------------------------------------------------------*/ | |
2449 /****************************************************************************** | |
2450 Static Function | |
2451 *******************************************************************************/ | |
2452 | |
2453 /** | |
2454 ****************************************************************************** | |
2455 * @brief GFX write substring. / Write string without parameters | |
2456 * @author heinrichs weikamp gmbh | |
2457 * @version V0.0.1 | |
2458 * @date 22-April-2014 | |
2459 ****************************************************************************** | |
2460 * | |
2461 * @param hgfx: check gfx_engine.h. | |
2462 * @param color: 32bit ARGB8888. | |
2463 * @retval None | |
2464 */ | |
2465 | |
2466 static uint32_t GFX_write_substring(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, uint8_t textId, int8_t nextCharFor2Byte) | |
2467 { | |
2468 uint8_t i, j; | |
2469 uint32_t found; | |
2470 uint32_t pText; | |
58 | 2471 uint16_t decodeUTF8; |
38 | 2472 uint8_t gfx_selected_language; |
2473 #ifndef BOOTLOADER_STANDALONE | |
2474 SSettings *pSettings; | |
2475 pSettings = settingsGetPointer(); | |
2476 gfx_selected_language = pSettings->selected_language; | |
2477 if(gfx_selected_language >= LANGUAGE_END) | |
2478 #endif | |
2479 gfx_selected_language = 0; | |
58 | 2480 |
2481 | |
38 | 2482 // ----------------------------- |
58 | 2483 if(textId != (uint8_t)TXT_2BYTE) |
38 | 2484 { |
2485 found = 0; | |
2486 j = 0; | |
2487 for(i=(uint8_t)TXT_Language;i<(uint8_t)TXT_END;i++) | |
2488 { | |
2489 if(text_array[j].code == textId) | |
2490 { | |
2491 found = 1; | |
2492 break; | |
2493 } | |
2494 j++; | |
2495 } | |
2496 if(!found) | |
2497 return cfg->Xdelta; | |
58 | 2498 |
38 | 2499 // ----------------------------- |
2500 pText = (uint32_t)text_array[j].text[gfx_selected_language]; | |
2501 if(!pText) | |
2502 pText = (uint32_t)text_array[j].text[0]; | |
2503 else | |
2504 if(*(char*)pText == 0) | |
2505 pText = (uint32_t)text_array[j].text[0]; | |
2506 } | |
2507 // ----------------------------- | |
2508 else | |
2509 { | |
2510 if(!nextCharFor2Byte) | |
2511 return cfg->Xdelta; | |
2512 | |
2513 found = 0; | |
2514 for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++) | |
2515 { | |
2516 if((uint8_t)text_array2[j].code == (uint8_t)nextCharFor2Byte) | |
2517 { | |
2518 found = 1; | |
2519 break; | |
2520 } | |
2521 } | |
2522 if(!found) | |
2523 return cfg->Xdelta; | |
2524 // ----------------------------- | |
2525 pText = (uint32_t)text_array2[j].text[gfx_selected_language]; | |
2526 if(!pText) | |
2527 pText = (uint32_t)text_array2[j].text[0]; | |
2528 else | |
2529 if(*(char*)pText == 0) | |
2530 pText = (uint32_t)text_array2[j].text[0]; | |
2531 } | |
2532 // ----------------------------- | |
2533 | |
2534 if(cfg->actualFont == (tFont *)cfg->TinyFont) | |
2535 cfg->Ydelta += cfg->TinyFontExtraYdelta; | |
2536 | |
2537 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size | |
2538 { | |
2539 if(*(char*)pText == '\t') | |
2540 cfg->Xdelta = hgfx->WindowTab - hgfx->WindowX0; | |
2541 else | |
2542 if(*(char*)pText == ' ') | |
2543 cfg->Xdelta += ((tFont *)cfg->actualFont)->spacesize; | |
2544 else | |
58 | 2545 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ |
2546 { | |
2547 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ | |
2548 pText++; | |
2549 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */ | |
2550 if (decodeUTF8 <= 0xff) /* The following function has a uint8 input parameter ==> no UNICODEs > 0xff supported */ | |
2551 { | |
2552 cfg->Xdelta = GFX_write_char(hgfx, cfg, (uint8_t)decodeUTF8, (tFont *)cfg->actualFont); | |
2553 } | |
2554 } | |
2555 else | |
38 | 2556 cfg->Xdelta = GFX_write_char(hgfx, cfg, *(uint8_t *)pText, (tFont *)cfg->actualFont); |
2557 | |
2558 pText++; | |
2559 } | |
2560 | |
2561 if(cfg->actualFont == (tFont *)cfg->TinyFont) | |
2562 cfg->Ydelta -= cfg->TinyFontExtraYdelta; | |
2563 | |
2564 return cfg->Xdelta; | |
2565 } | |
2566 | |
2567 | |
2568 /** | |
2569 ****************************************************************************** | |
2570 * @brief GFX write char. / Write non-inverted, non-colored with entire 8 bit range | |
2571 * @author heinrichs weikamp gmbh | |
2572 * @version V0.0.1 | |
2573 * @date 22-April-2014 | |
2574 ****************************************************************************** | |
2575 * | |
2576 * @param hgfx: check gfx_engine.h. | |
2577 * @param Ydelta: input | |
2578 * @param character: character | |
2579 * @param *Font: pointer to font to be used for this char | |
2580 * @retval Ydelta: 0x0000FFFF if not successful or char_truncated | |
2581 */ | |
2582 | |
2583 static uint32_t GFX_write_char_doubleSize(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font) | |
2584 { | |
2585 uint32_t i, j; | |
2586 uint32_t width, height; | |
2587 uint32_t found; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2588 uint16_t* pDestination; |
38 | 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); | |
119 | 2630 pDestination = (uint16_t*)(hgfx->Image->FBStartAdress); |
38 | 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 { | |
119 | 2698 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2699 pDestination += stepdir; |
119 | 2700 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
110
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 { | |
119 | 2718 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2719 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2720 pDestination += stepdir; |
119 | 2721 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2722 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2723 pDestination += stepdir; |
38 | 2724 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2725 |
119 | 2726 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2727 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2728 pDestination += stepdir; |
119 | 2729 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2730 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2731 pDestination += stepdir; |
38 | 2732 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2733 |
119 | 2734 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2735 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2736 pDestination += stepdir; |
119 | 2737 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2738 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2739 pDestination += stepdir; |
38 | 2740 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2741 |
119 | 2742 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2743 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2744 pDestination += stepdir; |
119 | 2745 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2746 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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 { | |
119 | 2757 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
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; |
119 | 2760 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2761 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2762 pDestination += stepdir; |
119 | 2763 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2764 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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; |
119 | 2767 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2768 pDestination += stepdir; |
119 | 2769 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2770 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2771 pDestination += stepdir; |
119 | 2772 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2773 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2774 pDestination += stepdir; |
119 | 2775 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2776 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2777 pDestination += stepdir; |
119 | 2778 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2779 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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 { | |
119 | 2795 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2796 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2797 pDestination += stepdir; |
119 | 2798 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2799 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2800 pDestination += stepdir; |
38 | 2801 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2802 |
119 | 2803 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2804 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2805 pDestination += stepdir; |
119 | 2806 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; |
2807 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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 { | |
119 | 2818 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2819 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2820 pDestination += stepdir; |
119 | 2821 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2822 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2823 pDestination += stepdir; |
119 | 2824 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2825 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2826 pDestination += stepdir; |
119 | 2827 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
2828 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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 { | |
119 | 2847 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2848 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2849 pDestination += stepdir; |
119 | 2850 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2851 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2852 pDestination += stepdir; |
38 | 2853 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2854 |
119 | 2855 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2856 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2857 pDestination += stepdir; |
119 | 2858 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2859 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2860 pDestination += stepdir; |
38 | 2861 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2862 |
119 | 2863 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2864 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2865 pDestination += stepdir; |
119 | 2866 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2867 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2868 pDestination += stepdir; |
38 | 2869 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2870 |
119 | 2871 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2872 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2873 pDestination += stepdir; |
119 | 2874 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2875 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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 { | |
119 | 2898 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2899 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2900 pDestination += stepdir; |
119 | 2901 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2902 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2903 pDestination += stepdir; |
38 | 2904 pSource++; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2905 |
119 | 2906 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2907 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
2908 pDestination += stepdir; |
119 | 2909 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color; |
2910 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
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; |
119 | 2970 uint16_t* pDestination2; |
38 | 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); | |
119 | 3019 pDestination = (uint16_t*)(hgfx->Image->FBStartAdress); |
3020 | |
38 | 3021 |
3022 height = Font->chars[i].image->height; | |
3023 width = Font->chars[i].image->width; | |
3024 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3025 OffsetDestination = hgfx->Image->ImageHeight - height; |
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 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3028 /* Xyyyyy y= height */ |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3029 /* Xyyyyy x= width */ |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3030 /* Xyyyyy */ |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3031 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3032 if(pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3033 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3034 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
|
3035 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
|
3036 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3037 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3038 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3039 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
|
3040 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
|
3041 } |
38 | 3042 |
3043 | |
3044 // ----------------------------- | |
3045 char_truncated_WidthFlag = 0; | |
3046 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta); | |
3047 if(width_left < width) | |
3048 { | |
3049 char_truncated_WidthFlag = 1; | |
3050 width = width_left; | |
3051 } | |
3052 // ----------------------------- | |
3053 char_truncated_Height = 0; | |
3054 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta); | |
3055 if(height_left < height) | |
3056 { | |
3057 char_truncated_Height = height - height_left; | |
3058 if((char_truncated_Height & 1) != 0) | |
3059 { | |
3060 height_left -= 1; | |
3061 char_truncated_Height += 1; | |
3062 } | |
3063 height = height_left; | |
3064 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3065 OffsetDestination += char_truncated_Height; |
38 | 3066 // ----------------------------- |
3067 if(height == 0) | |
3068 return 0x0000FFFF; | |
3069 // ----------------------------- | |
3070 | |
3071 if(cfg->singleSpaceWithSizeOfNextChar) | |
3072 { | |
3073 cfg->singleSpaceWithSizeOfNextChar = 0; | |
3074 | |
3075 if(cfg->invert) | |
3076 fill = 0xFF; | |
3077 else | |
3078 fill = 0; | |
3079 | |
3080 height /= 2; | |
3081 for(i = width; i > 0; i--) | |
3082 { | |
3083 for (j = height; j > 0; j--) | |
3084 { | |
119 | 3085 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3086 pDestination += stepdir; |
119 | 3087 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3088 pDestination += stepdir; |
38 | 3089 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3090 pDestination += stepdir * OffsetDestination; |
38 | 3091 } |
3092 } | |
3093 else | |
3094 if(cfg->invert) | |
3095 { | |
3096 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ | |
3097 { | |
3098 height /= 4; | |
3099 for(i = width; i > 0; i--) | |
3100 { | |
3101 if(*(uint8_t*)pSource != 0x01) | |
3102 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3103 |
38 | 3104 for (j = height; j > 0; j--) |
3105 { | |
119 | 3106 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3107 pDestination += stepdir; |
119 | 3108 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3109 pDestination += stepdir; |
119 | 3110 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3111 pDestination += stepdir; |
119 | 3112 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3113 pDestination += stepdir; |
38 | 3114 } |
3115 pSource += char_truncated_Height; | |
3116 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3117 else /* empty line => fast fill */ |
38 | 3118 { |
3119 pSource++; | |
3120 for (j = height; j > 0; j--) | |
3121 { | |
119 | 3122 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3123 pDestination += stepdir; |
119 | 3124 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3125 pDestination += stepdir; |
119 | 3126 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3127 pDestination += stepdir; |
119 | 3128 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3129 pDestination += stepdir; |
38 | 3130 } |
3131 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3132 pDestination += stepdir * OffsetDestination; |
38 | 3133 } |
3134 } | |
3135 else | |
3136 { | |
3137 height /= 2; | |
3138 for(i = width; i > 0; i--) | |
3139 { | |
3140 if(*(uint8_t*)pSource != 0x01) | |
3141 { | |
3142 for (j = height; j > 0; j--) | |
3143 { | |
119 | 3144 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3145 pDestination += stepdir; |
119 | 3146 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3147 pDestination += stepdir; |
38 | 3148 } |
3149 pSource += char_truncated_Height; | |
3150 } | |
3151 else | |
3152 { | |
3153 pSource++; | |
3154 for (j = height; j > 0; j--) | |
3155 { | |
119 | 3156 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3157 pDestination += stepdir; |
119 | 3158 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3159 pDestination += stepdir; |
38 | 3160 } |
3161 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3162 pDestination += stepdir * OffsetDestination; |
38 | 3163 } |
3164 } | |
3165 } | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3166 else /* not inverted */ |
38 | 3167 { |
3168 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */ | |
3169 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3170 |
38 | 3171 height /= 4; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3172 |
38 | 3173 for(i = width; i > 0; i--) |
3174 { | |
3175 if(*(uint8_t*)pSource != 0x01) | |
3176 { | |
3177 for (j = height; j > 0; j--) | |
3178 { | |
119 | 3179 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3180 pDestination += stepdir; |
119 | 3181 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3182 pDestination += stepdir; |
119 | 3183 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3184 pDestination += stepdir; |
119 | 3185 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3186 pDestination += stepdir; |
38 | 3187 } |
3188 pSource += char_truncated_Height; | |
3189 } | |
119 | 3190 else /* clear line */ |
38 | 3191 { |
3192 pSource++; | |
119 | 3193 for (j = height; j > 0; j--) |
3194 { | |
3195 *(__IO uint16_t*)pDestination = cfg->color; | |
3196 pDestination += stepdir; | |
3197 *(__IO uint16_t*)pDestination = cfg->color; | |
3198 pDestination += stepdir; | |
3199 *(__IO uint16_t*)pDestination = cfg->color; | |
3200 pDestination += stepdir; | |
3201 *(__IO uint16_t*)pDestination = cfg->color; | |
3202 pDestination += stepdir; | |
3203 } | |
38 | 3204 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3205 pDestination += stepdir * OffsetDestination; |
38 | 3206 } |
3207 } | |
3208 else | |
3209 { | |
3210 height /= 2; | |
3211 for(i = width; i > 0; i--) | |
3212 { | |
3213 if(*(uint8_t*)pSource != 0x01) | |
3214 { | |
3215 for (j = height; j > 0; j--) | |
3216 { | |
119 | 3217 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3218 pDestination += stepdir; |
119 | 3219 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3220 pDestination += stepdir; |
38 | 3221 } |
3222 pSource += char_truncated_Height; | |
3223 } | |
119 | 3224 else /* clear line */ |
38 | 3225 { |
3226 pSource++; | |
119 | 3227 for (j = height; j > 0; j--) |
3228 { | |
3229 *(__IO uint16_t*)pDestination = cfg->color; | |
3230 pDestination += stepdir; | |
3231 *(__IO uint16_t*)pDestination = cfg->color; | |
3232 pDestination += stepdir; | |
3233 } | |
38 | 3234 } |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
3235 pDestination += stepdir * OffsetDestination; |
38 | 3236 } |
3237 } | |
3238 } | |
3239 | |
3240 // ----------------------------- | |
3241 | |
3242 if(Font == &FontT144) | |
3243 width += 3; | |
3244 else | |
3245 if(Font == &FontT105) | |
3246 width += 2; | |
3247 /* | |
3248 else | |
3249 if(Font == &Font144) | |
3250 width += 3; | |
3251 else | |
3252 if(Font == &Font84) | |
3253 width += 1; | |
3254 */ | |
3255 // ----------------------------- | |
3256 | |
3257 if(char_truncated_WidthFlag) | |
3258 return 0x0000FFFF; | |
3259 else | |
3260 return cfg->Xdelta + width; | |
3261 } | |
3262 | |
3263 | |
3264 /** | |
3265 ****************************************************************************** | |
3266 * @brief GFX write Modify helper for center and right align. | |
3267 * @author heinrichs weikamp gmbh | |
3268 * @version V0.0.1 | |
3269 * @date 17-March-2015 | |
3270 ****************************************************************************** | |
3271 * | |
3272 * @param *cText: output | |
3273 * @param *pTextInput: input | |
3274 * @param gfx_selected_language: gfx_selected_language | |
3275 * @retval counter and *cText content | |
3276 */ | |
3277 int8_t GFX_write__Modify_helper(char *cText, const char *pTextInput, uint8_t gfx_selected_language) | |
3278 { | |
3279 uint32_t pText, backup; | |
3280 uint8_t textId; | |
3281 int8_t counter; | |
3282 uint32_t found; | |
3283 uint32_t j; | |
3284 | |
3285 pText = (uint32_t)pTextInput; | |
3286 counter = 0; | |
3287 while((counter < 100) && (*(char*)pText != 0) && (*(char*)pText != '\r')) | |
3288 { | |
3289 if((*(char*)pText) == TXT_2BYTE) | |
3290 { | |
3291 backup = pText; | |
3292 | |
3293 found = 0; | |
3294 j = 0; | |
3295 textId = (int8_t)*(char*)(pText + 1); | |
3296 if(textId != 0) | |
3297 { | |
3298 for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++) | |
3299 { | |
3300 if((uint8_t)text_array2[j].code == (uint8_t)textId) | |
3301 { | |
3302 found = 1; | |
3303 break; | |
3304 } | |
3305 } | |
3306 if(found) | |
3307 { | |
3308 pText = (uint32_t)text_array2[j].text[gfx_selected_language]; | |
3309 if(!pText) | |
3310 pText = (uint32_t)text_array2[j].text[0]; | |
3311 else | |
3312 if(*(char*)pText == 0) | |
3313 pText = (uint32_t)text_array2[j].text[0]; | |
3314 | |
3315 while((counter < 100) && (*(char*)pText != 0)) | |
3316 cText[counter++] = *(char*)pText++; | |
3317 } | |
3318 pText = backup + 2; | |
3319 } | |
3320 else | |
3321 pText = 0; | |
3322 } | |
3323 if((*(char*)pText) & 0x80) | |
3324 { | |
3325 backup = pText; | |
3326 | |
3327 found = 0; | |
3328 j = 0; | |
3329 textId = (uint8_t)*(char*)pText; | |
3330 for(uint8_t ii=(uint8_t)TXT_Language;ii<(uint8_t)TXT_END;ii++) | |
3331 { | |
3332 if(text_array[j].code == textId) | |
3333 { | |
3334 found = 1; | |
3335 break; | |
3336 } | |
3337 j++; | |
3338 } | |
3339 if(found) | |
3340 { | |
3341 pText = (uint32_t)text_array[j].text[gfx_selected_language]; | |
3342 if(!pText) | |
3343 pText = (uint32_t)text_array[j].text[0]; | |
3344 else | |
3345 if(*(char*)pText == 0) | |
3346 pText = (uint32_t)text_array[j].text[0]; | |
3347 | |
3348 while((counter < 100) && (*(char*)pText != 0)) | |
3349 cText[counter++] = *(char*)pText++; | |
3350 } | |
3351 pText = backup + 1; | |
3352 } | |
3353 else | |
3354 { | |
3355 cText[counter++] = *(char*)pText++; | |
3356 } | |
3357 } | |
3358 cText[counter] = 0; | |
3359 return counter; | |
3360 } | |
3361 | |
3362 | |
3363 /** | |
3364 ****************************************************************************** | |
3365 * @brief GFX write Modify Ydelta for align. / calc Ydelta for start | |
3366 * @author heinrichs weikamp gmbh | |
3367 * @version V0.0.1 | |
3368 * @date 22-April-2014 | |
3369 ****************************************************************************** | |
3370 * | |
3371 * @param *hgfx: check gfx_engine.h. | |
3372 * @param *cfg: Ydelta, Font | |
3373 * @param *pText: character | |
3374 * @retval Ydelta: 0 if text has to start left ( and probably does not fit) | |
3375 */ | |
3376 | |
3377 uint32_t GFX_write__Modify_Xdelta__Centered(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput) | |
3378 { | |
3379 char cText[101]; | |
3380 uint32_t result; | |
3381 uint32_t Xsum; | |
3382 uint32_t i, j; | |
3383 uint8_t gfx_selected_language; | |
3384 uint32_t pText; | |
58 | 3385 uint16_t decodeUTF8; |
38 | 3386 |
3387 #ifndef BOOTLOADER_STANDALONE | |
3388 SSettings *pSettings; | |
3389 pSettings = settingsGetPointer(); | |
3390 gfx_selected_language = pSettings->selected_language; | |
3391 if(gfx_selected_language >= LANGUAGE_END) | |
3392 #endif | |
3393 gfx_selected_language = 0; | |
3394 // ----------------------------- | |
3395 | |
3396 GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); | |
3397 | |
3398 pText = (uint32_t)&cText[0]; | |
3399 Xsum = 0; | |
3400 j = 0; | |
3401 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size | |
3402 { | |
58 | 3403 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ |
3404 { | |
3405 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ | |
3406 pText++; | |
3407 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */ | |
3408 } | |
3409 else | |
3410 { | |
3411 decodeUTF8 = *(char*)pText; /* place ASCII char */ | |
3412 } | |
3413 | |
38 | 3414 for(i=0;i<((tFont *)cfg->font)->length;i++) |
3415 { | |
58 | 3416 if(((tFont *)cfg->font)->chars[i].code == decodeUTF8) |
38 | 3417 { |
3418 Xsum += ((tFont *)cfg->font)->chars[i].image->width; | |
3419 break; | |
3420 } | |
3421 } | |
3422 pText++; | |
3423 j++; | |
3424 if(((tFont *)cfg->font == &FontT144) && (*(char*)pText != 0)) | |
3425 Xsum += 3; | |
3426 else | |
3427 if(((tFont *)cfg->font == &FontT105) && (*(char*)pText != 0)) | |
3428 Xsum += 2; | |
3429 } | |
3430 pText -= j; | |
3431 | |
3432 if(cfg->doubleSize) | |
3433 Xsum *= 2; | |
3434 | |
3435 result = hgfx->WindowX1 - hgfx->WindowX0; | |
3436 if(Xsum < result) | |
3437 { | |
3438 result -= Xsum; | |
3439 result /= 2; | |
3440 } | |
3441 else | |
3442 result = 0; | |
3443 return result; | |
3444 } | |
3445 | |
3446 | |
3447 uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput) | |
3448 { | |
3449 char cText[101]; | |
3450 uint32_t result; | |
3451 uint32_t Xsum; | |
3452 uint32_t i, j; | |
3453 tFont *font; | |
3454 uint8_t gfx_selected_language; | |
3455 uint32_t pText; | |
3456 uint8_t setToTinyFont = 0; | |
58 | 3457 uint16_t decodeUTF8; |
38 | 3458 |
3459 #ifndef BOOTLOADER_STANDALONE | |
3460 SSettings *pSettings; | |
3461 pSettings = settingsGetPointer(); | |
3462 gfx_selected_language = pSettings->selected_language; | |
3463 if(gfx_selected_language >= LANGUAGE_END) | |
3464 #endif | |
3465 gfx_selected_language = 0; | |
3466 // ----------------------------- | |
3467 | |
3468 GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language); | |
3469 pText = (uint32_t)&cText[0]; | |
3470 | |
3471 // ----------------------------- | |
3472 | |
3473 setToTinyFont = 0; | |
3474 font = (tFont *)cfg->font; | |
3475 Xsum = 0; | |
3476 j = 0; | |
3477 | |
3478 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size | |
3479 { | |
3480 if((font == &FontT144) && (*(char*)pText == '.')) | |
3481 { | |
3482 font = (tFont *)&FontT84; | |
3483 } | |
3484 else | |
3485 if((font == &FontT105) && (*(char*)pText == '\16')) // two times to start tiny font | |
3486 { | |
3487 if(!setToTinyFont) | |
3488 setToTinyFont = 1; | |
3489 else | |
3490 font = (tFont *)&FontT54; | |
3491 } | |
3492 else | |
3493 if((font == &FontT105) && cfg->dualFont && ((*(char*)pText == '.') || (*(char*)pText == ':'))) | |
3494 { | |
3495 font = (tFont *)&FontT54; | |
3496 } | |
3497 | |
3498 if(*(char*)pText == ' ') | |
3499 { | |
3500 Xsum += font->spacesize; | |
3501 } | |
3502 else | |
3503 { | |
58 | 3504 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ |
3505 { | |
3506 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ | |
3507 pText++; | |
3508 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */ | |
3509 } | |
3510 else | |
3511 { | |
3512 decodeUTF8 = *(char*)pText; | |
3513 } | |
38 | 3514 for(i=0;i<font->length;i++) |
3515 { | |
58 | 3516 if(font->chars[i].code == decodeUTF8) |
38 | 3517 { |
3518 Xsum += font->chars[i].image->width; | |
3519 break; | |
3520 } | |
3521 } | |
3522 } | |
3523 pText++; | |
3524 j++; | |
3525 if((font == &FontT144) && (*(char*)pText != 0)) | |
3526 Xsum += 3; | |
3527 else | |
3528 if((font == &FontT105) && (*(char*)pText != 0)) | |
3529 Xsum += 2; | |
3530 } | |
3531 pText -= j; | |
3532 | |
3533 if(cfg->doubleSize) | |
3534 Xsum *= 2; | |
3535 | |
3536 result = hgfx->WindowX1 - hgfx->WindowX0 - 1; | |
3537 if(Xsum < result) | |
3538 result -= Xsum; | |
3539 else | |
3540 result = 0; | |
3541 | |
3542 return result; | |
3543 } | |
3544 | |
3545 | |
3546 | |
3547 void GFX_LTDC_Init(void) | |
3548 { | |
3549 /* | |
3550 HSYNC=10 (9+1) | |
3551 HBP=10 (19-10+1) | |
3552 ActiveW=480 (499-10-10+1) | |
3553 HFP=8 (507-480-10-10+1) | |
3554 | |
3555 VSYNC=2 (1+1) | |
3556 VBP=2 (3-2+1) | |
3557 ActiveH=800 (803-2-2+1) | |
3558 VFP=2 (805-800-2-2+1) | |
3559 */ | |
3560 | |
3561 /* Timing configuration */ | |
3562 /* Horizontal synchronization width = Hsync - 1 */ | |
3563 LtdcHandle.Init.HorizontalSync = 9; | |
3564 /* Vertical synchronization height = Vsync - 1 */ | |
3565 LtdcHandle.Init.VerticalSync = 1; | |
3566 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ | |
3567 LtdcHandle.Init.AccumulatedHBP = 19; | |
3568 /* Accumulated vertical back porch = Vsync + VBP - 1 */ | |
3569 LtdcHandle.Init.AccumulatedVBP = 3; | |
3570 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ | |
3571 LtdcHandle.Init.AccumulatedActiveW = 499;//500;//499; | |
3572 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ | |
3573 LtdcHandle.Init.AccumulatedActiveH = 803; | |
3574 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ | |
3575 LtdcHandle.Init.TotalWidth = 507;//508;//507; | |
3576 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ | |
3577 LtdcHandle.Init.TotalHeigh = 805; | |
3578 | |
3579 /* Configure R,G,B component values for LCD background color */ | |
3580 LtdcHandle.Init.Backcolor.Red= 0; | |
3581 LtdcHandle.Init.Backcolor.Blue= 0; | |
3582 LtdcHandle.Init.Backcolor.Green= 0; | |
3583 | |
3584 /* LCD clock configuration */ | |
3585 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | |
3586 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | |
3587 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | |
3588 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ | |
3589 | |
3590 /* done in main.c SystemClockConfig | |
3591 | |
3592 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | |
3593 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; | |
3594 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; | |
3595 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; | |
3596 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
3597 */ | |
3598 /* Polarity */ | |
3599 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
3600 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL; | |
3601 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
3602 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC; | |
3603 | |
3604 LtdcHandle.Instance = LTDC; | |
3605 | |
3606 /* Configure the LTDC */ | |
3607 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins | |
3608 { | |
3609 /* Initialization Error */ | |
3610 GFX_Error_Handler(); | |
3611 } | |
3612 } | |
3613 | |
3614 void GFX_VGA_LTDC_Init_test(void) | |
3615 { | |
3616 | |
3617 LtdcHandle.Init.HorizontalSync = 48; | |
3618 /* Vertical synchronization height = Vsync - 1 */ | |
3619 LtdcHandle.Init.VerticalSync = 3; | |
3620 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ | |
3621 LtdcHandle.Init.AccumulatedHBP = 48 + 40 - 1; | |
3622 /* Accumulated vertical back porch = Vsync + VBP - 1 */ | |
3623 LtdcHandle.Init.AccumulatedVBP = 3 + 29 - 1; | |
3624 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ | |
3625 LtdcHandle.Init.AccumulatedActiveW = 800 + 48 + 40 - 1;//499;//500;//499; | |
3626 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ | |
3627 LtdcHandle.Init.AccumulatedActiveH = 480 + 3 + 29 - 1; | |
3628 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ | |
3629 LtdcHandle.Init.TotalWidth = 800 + 48 + 40 - 1 + 40;//508;//507; | |
3630 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ | |
3631 LtdcHandle.Init.TotalHeigh = 480 + 3 + 29 - 1 + 13; | |
3632 | |
3633 /* Configure R,G,B component values for LCD background color */ | |
3634 LtdcHandle.Init.Backcolor.Red= 0; | |
3635 LtdcHandle.Init.Backcolor.Blue= 0; | |
3636 LtdcHandle.Init.Backcolor.Green= 0; | |
3637 | |
3638 /* LCD clock configuration */ | |
3639 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | |
3640 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | |
3641 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | |
3642 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ | |
3643 | |
3644 /* done in main.c SystemClockConfig | |
3645 | |
3646 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | |
3647 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; | |
3648 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; | |
3649 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; | |
3650 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
3651 */ | |
3652 /* Polarity */ | |
3653 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
3654 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL; | |
3655 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
3656 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IPC;//LTDC_PCPOLARITY_IPC; | |
3657 | |
3658 LtdcHandle.Instance = LTDC; | |
3659 | |
3660 /* Configure the LTDC */ | |
3661 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins | |
3662 { | |
3663 /* Initialization Error */ | |
3664 GFX_Error_Handler(); | |
3665 } | |
3666 } | |
3667 | |
3668 | |
3669 void GFX_VGA_LTDC_Init_org(void) | |
3670 { | |
3671 | |
3672 LtdcHandle.Init.HorizontalSync = 96; | |
3673 /* Vertical synchronization height = Vsync - 1 */ | |
3674 LtdcHandle.Init.VerticalSync = 2; | |
3675 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ | |
3676 LtdcHandle.Init.AccumulatedHBP = 96 + 48; | |
3677 /* Accumulated vertical back porch = Vsync + VBP - 1 */ | |
3678 LtdcHandle.Init.AccumulatedVBP = 2 + 35; | |
3679 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ | |
3680 LtdcHandle.Init.AccumulatedActiveW = 96 + 48 + 800;//499;//500;//499; | |
3681 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ | |
3682 LtdcHandle.Init.AccumulatedActiveH = 2 + 35 + 480; | |
3683 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ | |
3684 LtdcHandle.Init.TotalWidth = 96 + 48 + 800 + 12;//508;//507; | |
3685 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ | |
3686 LtdcHandle.Init.TotalHeigh = 2 + 35 + 480 + 12; | |
3687 | |
3688 /* Configure R,G,B component values for LCD background color */ | |
3689 LtdcHandle.Init.Backcolor.Red= 0; | |
3690 LtdcHandle.Init.Backcolor.Blue= 0; | |
3691 LtdcHandle.Init.Backcolor.Green= 0; | |
3692 | |
3693 /* LCD clock configuration */ | |
3694 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | |
3695 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | |
3696 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | |
3697 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ | |
3698 | |
3699 /* done in main.c SystemClockConfig | |
3700 | |
3701 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | |
3702 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; | |
3703 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; | |
3704 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; | |
3705 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
3706 */ | |
3707 /* Polarity */ | |
3708 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
3709 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AH; | |
3710 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
3711 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IPC;//LTDC_PCPOLARITY_IPC; | |
3712 | |
3713 LtdcHandle.Instance = LTDC; | |
3714 | |
3715 /* Configure the LTDC */ | |
3716 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins | |
3717 { | |
3718 /* Initialization Error */ | |
3719 GFX_Error_Handler(); | |
3720 } | |
3721 } | |
3722 | |
3723 void GFX_VGA_LTDC_Init(void) | |
3724 //void GFX_VGA_LTDC_Init_640x480(void) | |
3725 { | |
3726 | |
3727 LtdcHandle.Init.HorizontalSync = 96; | |
3728 /* Vertical synchronization height = Vsync - 1 */ | |
3729 LtdcHandle.Init.VerticalSync = 2; | |
3730 /* Accumulated horizontal back porch = Hsync + HBP - 1 */ | |
3731 LtdcHandle.Init.AccumulatedHBP = 96 + 48; | |
3732 /* Accumulated vertical back porch = Vsync + VBP - 1 */ | |
3733 LtdcHandle.Init.AccumulatedVBP = 2 + 35; | |
3734 /* Accumulated active width = Hsync + HBP + Active Width - 1 */ | |
3735 LtdcHandle.Init.AccumulatedActiveW = 96 + 48 + 640;//499;//500;//499; | |
3736 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */ | |
3737 LtdcHandle.Init.AccumulatedActiveH = 2 + 35 + 480; | |
3738 /* Total width = Hsync + HBP + Active Width + HFP - 1 */ | |
3739 LtdcHandle.Init.TotalWidth = 96 + 48 + 640 + 12;//508;//507; | |
3740 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */ | |
3741 LtdcHandle.Init.TotalHeigh = 2 + 35 + 480 + 12; | |
3742 | |
3743 /* Configure R,G,B component values for LCD background color */ | |
3744 LtdcHandle.Init.Backcolor.Red= 0; | |
3745 LtdcHandle.Init.Backcolor.Blue= 0; | |
3746 LtdcHandle.Init.Backcolor.Green= 0; | |
3747 | |
3748 /* LCD clock configuration */ | |
3749 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ | |
3750 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */ | |
3751 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */ | |
3752 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */ | |
3753 | |
3754 /* done in main.c SystemClockConfig | |
3755 | |
3756 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; | |
3757 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; | |
3758 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4; | |
3759 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8; | |
3760 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); | |
3761 */ | |
3762 /* Polarity */ | |
3763 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL; | |
3764 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AH; | |
3765 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL; | |
3766 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IPC;//LTDC_PCPOLARITY_IPC; | |
3767 | |
3768 LtdcHandle.Instance = LTDC; | |
3769 | |
3770 /* Configure the LTDC */ | |
3771 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // auch init der GPIO Pins | |
3772 { | |
3773 /* Initialization Error */ | |
3774 GFX_Error_Handler(); | |
3775 } | |
3776 } | |
3777 | |
3778 | |
3779 void GFX_LTDC_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) | |
3780 { | |
3781 LTDC_LayerCfgTypeDef Layercfg; | |
3782 | |
3783 /* Layer Init */ | |
3784 Layercfg.WindowX0 = 0; | |
3785 Layercfg.WindowX1 = 480; | |
3786 Layercfg.WindowY0 = 0; | |
3787 Layercfg.WindowY1 = 800; | |
3788 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_AL88;//LTDC_PIXEL_FORMAT_ARGB8888; | |
3789 Layercfg.FBStartAdress = FB_Address; | |
3790 Layercfg.Alpha = 255; | |
3791 Layercfg.Alpha0 = 0; | |
3792 Layercfg.Backcolor.Blue = 0; | |
3793 Layercfg.Backcolor.Green = 0; | |
3794 Layercfg.Backcolor.Red = 0; | |
3795 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; | |
3796 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; | |
3797 Layercfg.ImageWidth = 480; | |
3798 Layercfg.ImageHeight = 800; | |
3799 | |
3800 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, LayerIndex); | |
3801 HAL_LTDC_ConfigLayer(&LtdcHandle, &Layercfg, LayerIndex); | |
3802 HAL_LTDC_EnableCLUT(&LtdcHandle, LayerIndex); | |
3803 } | |
3804 | |
3805 void GFX_VGA_LTDC_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address) | |
3806 { | |
3807 LTDC_LayerCfgTypeDef Layercfg; | |
3808 | |
3809 /* Layer Init */ | |
3810 Layercfg.WindowX0 = 0; | |
3811 Layercfg.WindowX1 = 640; | |
3812 Layercfg.WindowY0 = 0; | |
3813 Layercfg.WindowY1 = 480; | |
3814 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_AL88;//LTDC_PIXEL_FORMAT_ARGB8888; | |
3815 Layercfg.FBStartAdress = FB_Address; | |
3816 Layercfg.Alpha = 255; | |
3817 Layercfg.Alpha0 = 0; | |
3818 Layercfg.Backcolor.Blue = 0; | |
3819 Layercfg.Backcolor.Green = 0; | |
3820 Layercfg.Backcolor.Red = 0; | |
3821 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; | |
3822 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; | |
3823 Layercfg.ImageWidth = 640; | |
3824 Layercfg.ImageHeight = 480; | |
3825 | |
3826 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, LayerIndex); | |
3827 HAL_LTDC_ConfigLayer(&LtdcHandle, &Layercfg, LayerIndex); | |
3828 HAL_LTDC_EnableCLUT(&LtdcHandle, LayerIndex); | |
3829 } | |
3830 | |
3831 void GFX_LTDC_LayerTESTInit(uint16_t LayerIndex, uint32_t FB_Address) | |
3832 { | |
3833 LTDC_LayerCfgTypeDef Layercfg; | |
3834 | |
3835 /* Layer Init */ | |
3836 Layercfg.WindowX0 = 0; | |
3837 Layercfg.WindowX1 = 390; | |
3838 Layercfg.WindowY0 = 0; | |
3839 Layercfg.WindowY1 = 800; | |
3840 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_AL88;//LTDC_PIXEL_FORMAT_ARGB8888; | |
3841 Layercfg.FBStartAdress = FB_Address; | |
3842 Layercfg.Alpha = 255; | |
3843 Layercfg.Alpha0 = 255; | |
3844 Layercfg.Backcolor.Blue = 0; | |
3845 Layercfg.Backcolor.Green = 0; | |
3846 Layercfg.Backcolor.Red = 200; | |
3847 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; | |
3848 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; | |
3849 Layercfg.ImageWidth = 480; | |
3850 Layercfg.ImageHeight = 800; | |
3851 | |
3852 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, LayerIndex); | |
3853 HAL_LTDC_ConfigLayer(&LtdcHandle, &Layercfg, LayerIndex); | |
3854 HAL_LTDC_EnableCLUT(&LtdcHandle, LayerIndex); | |
3855 } | |
3856 | |
3857 | |
3858 uint32_t GFX_doubleBufferOne(void) | |
3859 { | |
3860 return SDRAM_DOUBLE_BUFFER_ONE; | |
3861 } | |
3862 | |
3863 | |
3864 uint32_t GFX_doubleBufferTwo(void) | |
3865 { | |
3866 return SDRAM_DOUBLE_BUFFER_TWO; | |
3867 } | |
3868 | |
3869 /* | |
3870 void doubleBufferClear(uint32_t pDestination) | |
3871 { | |
3872 for(uint32_t i = 2*200*480; i > 0; i--) | |
3873 { | |
3874 *(__IO uint16_t*)pDestination = 0; | |
3875 pDestination += 2; | |
3876 *(__IO uint16_t*)pDestination = 0; | |
3877 pDestination += 2; | |
3878 *(__IO uint16_t*)pDestination = 0; | |
3879 pDestination += 2; | |
3880 *(__IO uint16_t*)pDestination = 0; | |
3881 pDestination += 2; | |
3882 } | |
3883 } | |
3884 | |
3885 | |
3886 void GFX_doubleBufferClearOne(void) | |
3887 { | |
3888 doubleBufferClear(SDRAM_DOUBLE_BUFFER_ONE); | |
3889 } | |
3890 | |
3891 | |
3892 void GFX_doubleBufferClearTwo(void) | |
3893 { | |
3894 doubleBufferClear(SDRAM_DOUBLE_BUFFER_TWO); | |
3895 } | |
3896 */ | |
3897 | |
3898 uint32_t getFrameByNumber(uint8_t ZeroToMaxFrames) | |
3899 { | |
3900 if(ZeroToMaxFrames >= MAXFRAMES) | |
3901 return 0; | |
3902 else | |
3903 return frame[ZeroToMaxFrames].StartAddress; | |
3904 } | |
3905 | |
3906 uint32_t getFrame(uint8_t callerId) | |
3907 { | |
3908 uint8_t i; | |
3909 | |
3910 i = 0; | |
3911 while((i < MAXFRAMES) && (frame[i].status != CLEAR)) | |
3912 i++; | |
3913 | |
3914 if((i < MAXFRAMES) && (frame[i].status == CLEAR)) | |
3915 { | |
3916 frame[i].status = BLOCKED; | |
3917 frame[i].caller = callerId; | |
3918 return frame[i].StartAddress; | |
3919 } | |
3920 | |
3921 i = 0; | |
3922 while((i < MAXFRAMES) && (frame[i].status != RELEASED)) | |
3923 i++; | |
3924 | |
3925 if((i < MAXFRAMES) && (frame[i].status == RELEASED)) | |
3926 { | |
3927 GFX_clear_frame_immediately(frame[i].StartAddress); | |
3928 frame[i].status = BLOCKED; | |
3929 return frame[i].StartAddress; | |
3930 } | |
3931 return 0; | |
3932 } | |
3933 | |
3934 | |
3935 void GFX_forceReleaseFramesWithId(uint8_t callerId) | |
3936 { | |
3937 for(int i=0; i<MAXFRAMES; i++) | |
3938 if((frame[i].caller == callerId) && (frame[i].status == BLOCKED)) | |
3939 frame[i].status = RELEASED; | |
3940 } | |
3941 | |
3942 | |
3943 void releaseAllFramesExcept(uint8_t callerId, uint32_t frameStartAddress) | |
3944 { | |
3945 for(int i=0; i<MAXFRAMES; i++) | |
3946 if((frame[i].caller == callerId) && (frame[i].status == BLOCKED) && (frame[i].StartAddress != frameStartAddress)) | |
3947 frame[i].status = RELEASED; | |
3948 } | |
3949 | |
3950 | |
3951 uint8_t releaseFrame(uint8_t callerId, uint32_t frameStartAddress) | |
3952 { | |
3953 static uint8_t countErrorCalls = 0; | |
3954 | |
3955 if(frameStartAddress < FBGlobalStart) | |
3956 return 2; | |
3957 | |
3958 | |
3959 uint8_t i; | |
3960 | |
3961 i = 0; | |
3962 while((i < MAXFRAMES) && (frame[i].StartAddress != frameStartAddress)) | |
3963 i++; | |
3964 | |
3965 if((i < MAXFRAMES) && (frame[i].StartAddress == frameStartAddress)) | |
3966 { | |
3967 if(frame[i].caller == callerId) | |
3968 { | |
3969 frame[i].status = RELEASED; | |
3970 return 1; | |
3971 } | |
3972 else | |
3973 countErrorCalls++; | |
3974 } | |
3975 return 0; | |
3976 } | |
3977 | |
3978 | |
3979 uint16_t blockedFramesCount(void) | |
3980 { | |
3981 uint16_t count = MAXFRAMES; | |
3982 | |
3983 for(int i = 0;i<MAXFRAMES;i++) | |
3984 if(frame[i].status == BLOCKED) | |
3985 count--; | |
3986 | |
3987 return count; | |
3988 } | |
3989 | |
3990 | |
3991 uint8_t getFrameCount(uint8_t frameId) | |
3992 { | |
3993 if(frameId < (MAXFRAMECOUNTER - 3)) | |
3994 return frameCounter[frameId]; | |
3995 else | |
3996 return frameCounter[MAXFRAMECOUNTER - 2]; | |
3997 } | |
3998 | |
3999 | |
4000 void housekeepingFrame(void) | |
4001 { | |
4002 static uint8_t countLogClear = 0; | |
4003 | |
4004 if(DMA2D_at_work != 255) | |
4005 return; | |
4006 | |
4007 /* new for debug hw 151202 */ | |
4008 for(int i=1;i<MAXFRAMECOUNTER;i++) | |
4009 { | |
4010 frameCounter[i] = 0; | |
4011 } | |
4012 for(int i=1;i<MAXFRAMES;i++) | |
4013 { | |
4014 if(frame[i].status == BLOCKED) | |
4015 { | |
4016 if(frame[i].caller < (MAXFRAMECOUNTER - 2)) | |
4017 frameCounter[frame[i].caller]++; | |
4018 else | |
4019 frameCounter[MAXFRAMECOUNTER-3]++; | |
4020 } | |
4021 else | |
4022 if(frame[i].status == RELEASED) | |
4023 frameCounter[MAXFRAMECOUNTER-2]++; | |
4024 else | |
4025 frameCounter[MAXFRAMECOUNTER-1]++; | |
4026 } | |
4027 | |
4028 | |
4029 uint8_t i; | |
4030 | |
4031 i = 0; | |
4032 while((i < MAXFRAMES) && ((frame[i].status != RELEASED) || (frame[i].StartAddress == GFX_get_pActualFrameTop()) || (frame[i].StartAddress == GFX_get_pActualFrameBottom()))) | |
4033 i++; | |
4034 | |
4035 if((i < MAXFRAMES) && (frame[i].status == RELEASED)) | |
4036 { | |
4037 if(frame[i].caller == 15) | |
4038 countLogClear++; | |
4039 GFX_clear_frame_dma2d(i); | |
4040 } | |
4041 } | |
4042 | |
4043 | |
4044 static void GFX_Dma2d_TransferComplete(DMA2D_HandleTypeDef* Dma2dHandle) | |
4045 { | |
4046 if(DMA2D_at_work < MAXFRAMES) | |
4047 frame[DMA2D_at_work].status = CLEAR; | |
4048 | |
4049 DMA2D_at_work = 255; | |
4050 } | |
4051 | |
4052 | |
4053 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle) | |
4054 { | |
4055 | |
4056 } | |
4057 | |
4058 static void GFX_Error_Handler(void) | |
4059 { | |
4060 /* Turn LED3 on */ | |
4061 // BSP_LED_On(LED3); | |
4062 while(1) | |
4063 { | |
4064 } | |
4065 } | |
4066 | |
4067 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) | |
4068 { | |
4069 GFX_DrawCfgWindow hgfx; | |
4070 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4071 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4072 pSettings = settingsGetPointer(); |
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 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4075 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4076 if(XrightGimpStyle > 799) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4077 XrightGimpStyle = 799; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4078 if(XleftGimpStyle >= XrightGimpStyle) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4079 XleftGimpStyle = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4080 if(YtopGimpStyle > 479) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4081 YtopGimpStyle = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4082 } |
38 | 4083 hgfx.Image = tMscreen; |
4084 hgfx.WindowNumberOfTextLines = 1; | |
4085 hgfx.WindowLineSpacing = 0; | |
4086 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4087 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4088 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4089 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4090 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4091 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4092 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4093 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4094 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4095 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4096 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4097 } |
38 | 4098 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4099 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4100 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4101 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4102 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4103 if(hgfx.WindowY0 + Font->height >= 479) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4104 hgfx.WindowY1 = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4105 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4106 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4107 } |
38 | 4108 GFX_write_string_color(Font, &hgfx, text, 0, color); |
4109 } | |
4110 | |
4111 | |
4112 void gfx_write_topline_simple(GFX_DrawCfgScreen *tMscreen, const char *text, uint8_t color) | |
4113 { | |
4114 GFX_DrawCfgWindow hgfx; | |
4115 const tFont *Font = &FontT48; | |
4116 | |
4117 hgfx.Image = tMscreen; | |
4118 hgfx.WindowNumberOfTextLines = 1; | |
4119 hgfx.WindowLineSpacing = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4120 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4121 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4122 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4123 |
38 | 4124 hgfx.WindowTab = 0; |
4125 hgfx.WindowX0 = 20; | |
4126 hgfx.WindowX1 = 779; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4127 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4128 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4129 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4130 hgfx.WindowY1 = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4131 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
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 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4134 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4135 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4136 hgfx.WindowY1 = Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4137 } |
38 | 4138 GFX_write_label(Font, &hgfx, text, color); |
4139 } | |
4140 | |
4141 | |
4142 void gfx_write_page_number(GFX_DrawCfgScreen *tMscreen, uint8_t page, uint8_t total, uint8_t color) | |
4143 { | |
4144 GFX_DrawCfgWindow hgfx; | |
4145 const tFont *Font = &FontT48; | |
4146 char text[7]; | |
4147 uint8_t i, secondDigitPage, secondDigitTotal; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4148 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4149 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4150 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4151 |
38 | 4152 hgfx.Image = tMscreen; |
4153 hgfx.WindowNumberOfTextLines = 1; | |
4154 hgfx.WindowLineSpacing = 0; | |
4155 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4156 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4157 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4158 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4159 hgfx.WindowX1 = 779; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4160 hgfx.WindowX0 = hgfx.WindowX1 - (25*5); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4161 hgfx.WindowY1 = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4162 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4163 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4164 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4165 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4166 hgfx.WindowX1 = 25*5; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4167 hgfx.WindowX0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4168 hgfx.WindowY1 = Font->height;; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4169 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
58
diff
changeset
|
4170 } |
38 | 4171 if(page > 99) |
4172 page = 99; | |
4173 if(total > 99) | |
4174 total = 99; | |
4175 | |
4176 i = 0; | |
4177 text[i++] = '\002'; | |
4178 | |
4179 secondDigitPage = page / 10; | |
4180 page -= secondDigitPage * 10; | |
4181 | |
4182 secondDigitTotal = total / 10; | |
4183 total -= secondDigitTotal * 10; | |
4184 | |
4185 if(secondDigitPage) | |
4186 text[i++] = '0' + secondDigitPage; | |
4187 text[i++] = '0' + page; | |
4188 | |
4189 text[i++] = '/'; | |
4190 | |
4191 if(secondDigitTotal) | |
4192 text[i++] = '0' + secondDigitTotal; | |
4193 text[i++] = '0' + total; | |
4194 | |
4195 text[i] = 0; | |
4196 | |
4197 GFX_clear_window_immediately(&hgfx); | |
4198 GFX_write_label(Font, &hgfx, text, color); | |
4199 } | |
4200 | |
4201 | |
4202 uint8_t gfx_number_to_string(uint8_t max_digits, _Bool fill, char *pText, uint32_t input) | |
4203 { | |
4204 uint8_t digits[10]; | |
4205 uint32_t number, divider; | |
4206 int first; | |
4207 uint8_t out; | |
4208 | |
4209 number = input; | |
4210 first = 0; | |
4211 divider = 1000000000; | |
4212 for(int i=9;i>=0;i--) | |
4213 { | |
4214 digits[i] = (uint8_t)(number / divider); | |
4215 number -= digits[i] * divider; | |
4216 divider /= 10; | |
4217 if((first == 0) && (digits[i] != 0)) | |
4218 first = i; | |
4219 } | |
4220 | |
4221 if((first + 1) > max_digits) | |
4222 { | |
4223 for(int i = 0; i<max_digits; i++) | |
4224 pText[i] = '9'; | |
4225 out = max_digits; | |
4226 } | |
4227 else if(fill) | |
4228 { | |
4229 int i = 0; | |
4230 for(int k = max_digits; k>0; k--) | |
4231 pText[i++] = digits[k -1] + '0'; | |
4232 out = max_digits; | |
4233 } | |
4234 else | |
4235 { | |
4236 int i = 0; | |
4237 for(int k = first; k>=0; k--) | |
4238 pText[i++] = digits[k] + '0'; | |
4239 out = i; | |
4240 } | |
4241 | |
4242 return out; | |
4243 } | |
4244 | |
4245 | |
4246 /* output is | |
4247 * 0-> | |
4248 * | | |
4249 * v | |
4250 * | |
4251 * input is | |
4252 * | |
4253 * -> | |
4254 * A | |
4255 * | | |
4256 * 0 | |
4257 */ | |
4258 void GFX_screenshot(void) | |
4259 { | |
4260 uint32_t pSource = GFX_get_pActualFrameTop(); | |
4261 uint32_t pSourceBottom =GFX_get_pActualFrameBottom(); | |
4262 uint32_t pBottomNew = getFrame(99); | |
4263 uint32_t pDestination = GFX_doubleBufferOne(); | |
4264 uint32_t sourceNow; | |
4265 | |
4266 | |
4267 uint32_t bot_leftStart = FrameHandler.actualBottom.leftStart; // x0 z.B. 0 | |
4268 uint32_t bot_bottomStart = FrameHandler.actualBottom.bottomStart; // y0 z.B. 25 | |
4269 uint32_t bot_width = FrameHandler.actualBottom.width; // 800 | |
4270 uint32_t bot_height = FrameHandler.actualBottom.height; // 390 | |
4271 | |
4272 struct split | |
4273 { | |
4274 uint8_t blue; | |
4275 uint8_t green; | |
4276 uint8_t red; | |
4277 uint8_t alpha; | |
4278 }; | |
4279 | |
4280 union inout_u | |
4281 { | |
4282 uint32_t in; | |
4283 struct split out; | |
4284 }; | |
4285 | |
4286 union inout_u value; | |
4287 | |
4288 /* test | |
4289 uint32_t pSourceTemp = pSource + (2*479); | |
4290 for (int j = 0xFFFF; j > 0x00FF; j -= 0x0100) | |
4291 { | |
4292 *(__IO uint16_t*)pSourceTemp = j; | |
4293 pSourceTemp += 480*2; | |
4294 } | |
4295 */ | |
4296 // Top Layer | |
4297 const unsigned width = 800, height = 480; | |
4298 const uint32_t heightX2 = height*2; | |
4299 | |
4300 for(unsigned y = 0; y < height; y++) | |
4301 { | |
4302 sourceNow = pSource + 2 * ((height - 1) - y); | |
4303 for(unsigned x = 0; x < width; x++) | |
4304 { | |
4305 // sourceNow += 2 * height * x + 2 * (height - 1 - y); | |
4306 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)]; | |
4307 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1); | |
4308 | |
4309 *(__IO uint8_t*)(pDestination++) = value.out.red; | |
4310 *(__IO uint8_t*)(pDestination++) = value.out.green; | |
4311 *(__IO uint8_t*)(pDestination++) = value.out.blue; | |
4312 *(__IO uint8_t*)(pDestination++) = value.out.alpha; | |
4313 sourceNow += heightX2; | |
4314 } | |
4315 } | |
4316 | |
4317 // Bottom Layer | |
4318 // build newBottom | |
4319 pSource = pSourceBottom; | |
4320 for(unsigned x = bot_leftStart; x < bot_leftStart+bot_width; x++) | |
4321 { | |
4322 for(unsigned y = bot_bottomStart; y < bot_bottomStart+bot_height; y++) | |
4323 { | |
4324 pDestination = pBottomNew + (2 * y); | |
4325 pDestination += heightX2 * x; | |
4326 *(__IO uint16_t*)(pDestination) = *(__IO uint16_t*)(pSource); | |
4327 pSource += 2; | |
4328 } | |
4329 } | |
4330 | |
4331 // output Bottom Layer | |
4332 pSource = pBottomNew; | |
4333 pDestination = GFX_doubleBufferTwo(); | |
4334 | |
4335 for(unsigned y = 0; y < height; y++) | |
4336 { | |
4337 sourceNow = pSource + 2 * ((height - 1) - y); | |
4338 for(unsigned x = 0; x < width; x++) | |
4339 { | |
4340 // sourceNow = pSource + 2 * height * x + 2 * (height - 1 - y); | |
4341 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)]; | |
4342 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1); | |
4343 | |
4344 *(__IO uint8_t*)(pDestination++) = value.out.red; | |
4345 *(__IO uint8_t*)(pDestination++) = value.out.green; | |
4346 *(__IO uint8_t*)(pDestination++) = value.out.blue; | |
4347 *(__IO uint8_t*)(pDestination++) = value.out.alpha; | |
4348 sourceNow += heightX2; | |
4349 } | |
4350 } | |
4351 releaseFrame(99,pBottomNew); | |
4352 /* | |
4353 // das kommt dazu! | |
4354 unsigned yEnd = 480 - FrameHandler.actualBottom.bottomStart; | |
4355 unsigned yStart = yEnd - FrameHandler.actualBottom.height; | |
4356 | |
4357 if(yStart > 0) | |
4358 { | |
4359 for(unsigned y = 0; y < yStart; y++) | |
4360 for(unsigned x = 0; x < width; x++) | |
4361 { | |
4362 *(__IO uint8_t*)(pDestination++) = 0; | |
4363 *(__IO uint8_t*)(pDestination++) = 0; | |
4364 *(__IO uint8_t*)(pDestination++) = 0; | |
4365 *(__IO uint8_t*)(pDestination++) = 0; | |
4366 } | |
4367 } | |
4368 for(unsigned y = yStart; y < yEnd; y++) | |
4369 for(unsigned x = 0; x < width; x++) | |
4370 { | |
4371 sourceNow = pSource + 2 * height * x + 2 * (height - 1 - y); | |
4372 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)]; | |
4373 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1); | |
4374 | |
4375 *(__IO uint8_t*)(pDestination++) = value.out.red; | |
4376 *(__IO uint8_t*)(pDestination++) = value.out.green; | |
4377 *(__IO uint8_t*)(pDestination++) = value.out.blue; | |
4378 *(__IO uint8_t*)(pDestination++) = value.out.alpha; | |
4379 } | |
4380 if(yEnd < 480) | |
4381 { | |
4382 for(unsigned y = yEnd; y < 480; y++) | |
4383 for(unsigned x = 0; x < width; x++) | |
4384 { | |
4385 *(__IO uint8_t*)(pDestination++) = 0; | |
4386 *(__IO uint8_t*)(pDestination++) = 0; | |
4387 *(__IO uint8_t*)(pDestination++) = 0; | |
4388 *(__IO uint8_t*)(pDestination++) = 0; | |
4389 } | |
4390 } | |
4391 */ | |
4392 } |