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