985
|
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 #define RING_BUF_SIZE (5u)
|
|
40 #define MAX_COLOR_STRING_LENGTH (100u)
|
|
41
|
|
42 typedef struct
|
|
43 {
|
|
44 uint32_t Xdelta;
|
|
45 uint32_t Ydelta;
|
|
46 uint8_t invert;
|
|
47 uint8_t color;
|
|
48 uint8_t dualFont;
|
|
49 uint8_t resize;
|
|
50 uint32_t font;
|
|
51 uint8_t spaceMode;
|
|
52 uint8_t singleSpaceWithSizeOfNextChar;
|
|
53 uint8_t useTinyFont;
|
|
54 uint32_t TinyFont;
|
|
55 int8_t TinyFontExtraYdelta;
|
|
56 tFont *actualFont;
|
|
57 uint8_t doubleSize;
|
|
58 } GFX_CfgWriteString;
|
|
59
|
|
60 typedef struct
|
|
61 {
|
|
62 uint32_t pBuffer;
|
|
63 uint32_t height;
|
|
64 uint32_t width;
|
|
65 uint32_t leftStart;
|
|
66 uint32_t bottomStart;
|
|
67 } GFX_layerSingle;
|
|
68 /*
|
|
69 typedef struct
|
|
70 {
|
|
71 GFX_layerSingle top;
|
|
72 GFX_layerSingle bottom;
|
|
73 } GFX_layersTopBottom;
|
|
74 */
|
|
75 typedef struct
|
|
76 {
|
|
77 uint32_t pActualTopBuffer;
|
|
78 uint32_t pNextTopBuffer[RING_BUF_SIZE];
|
|
79 GFX_layerSingle actualBottom;
|
|
80 GFX_layerSingle nextBottom[RING_BUF_SIZE];
|
|
81 uint8_t NextTopWrite;
|
|
82 uint8_t NextBottomWrite;
|
|
83 uint8_t NextTopRead;
|
|
84 uint8_t NextBottomRead;
|
|
85 } GFX_layerControl;
|
|
86
|
|
87 typedef struct
|
|
88 {
|
|
89 uint32_t StartAddress;
|
|
90 int8_t status;
|
|
91 uint8_t caller;
|
|
92 } SFrameList;
|
|
93
|
|
94 enum FRAMESTATE
|
|
95 {
|
|
96 CLEAR = 0,
|
|
97 BLOCKED,
|
|
98 RELEASED
|
|
99 };
|
|
100
|
|
101 enum LOGOSTATE
|
|
102 {
|
|
103 LOGOOFF = 0,
|
|
104 LOGOSTART = 1,
|
|
105 LOGOSTOP = 255
|
|
106 };
|
|
107
|
|
108 // should be 43
|
|
109 #define MAXFRAMES 39
|
|
110
|
|
111 #define SDRAM_BANK_ADDR ((uint32_t)0xD0000000)
|
|
112 #define FBGlobalStart SDRAM_BANK_ADDR
|
|
113 #define FBOffsetEachIndex (800*480*2)
|
|
114
|
|
115 #define SDRAM_DOUBLE_BUFFER_ONE ((uint32_t)(FBGlobalStart + (MAXFRAMES * FBOffsetEachIndex)))
|
|
116 #define SDRAM_DOUBLE_BUFFER_TWO ((uint32_t)(SDRAM_DOUBLE_BUFFER_ONE + (2 * FBOffsetEachIndex)))
|
|
117 #define SDRAM_DOUBLE_BUFFER_END ((uint32_t)(SDRAM_DOUBLE_BUFFER_TWO + (2 * FBOffsetEachIndex)))
|
|
118
|
|
119 /* Semi Private variables ---------------------------------------------------------*/
|
|
120
|
|
121 DMA2D_HandleTypeDef Dma2dHandle;
|
|
122 static LTDC_HandleTypeDef LtdcHandle;
|
|
123
|
|
124 /* Private variables ---------------------------------------------------------*/
|
|
125
|
|
126 static uint8_t DMA2D_at_work = 0;
|
|
127
|
|
128 static GFX_layerControl FrameHandler = { 0 };
|
|
129
|
|
130 static uint32_t pInvisibleFrame = 0;
|
|
131 static uint32_t pLogoFrame = 0;
|
|
132 static uint8_t logoStatus;
|
|
133 static uint32_t pBackgroundHwFrame = 0;
|
|
134 static uint8_t backgroundHwStatus;
|
|
135
|
|
136 static SFrameList frame[MAXFRAMES];
|
|
137
|
|
138 static void GFX_clear_frame_immediately(uint32_t pDestination);
|
|
139 static void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image);
|
|
140 /* ITM Trace-----------------------------------------------------------------*/
|
|
141
|
|
142 #include "stdio.h"
|
|
143
|
|
144 #define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
|
|
145 #define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
|
|
146 #define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))
|
|
147
|
|
148 #define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
|
|
149 #define TRCENA 0x01000000
|
|
150
|
|
151 struct __FILE { int handle; /* Add whatever needed */ };
|
|
152 FILE __stdout;
|
|
153 FILE __stdin;
|
|
154
|
|
155 int fputc(int ch, FILE *f) {
|
|
156 if (DEMCR & TRCENA) {
|
|
157 while (ITM_Port32(0) == 0);
|
|
158 ITM_Port8(0) = ch;
|
|
159 }
|
|
160 return(ch);
|
|
161 }
|
|
162
|
|
163 uint32_t MinU32GFX(uint32_t a, uint32_t b)
|
|
164 {
|
|
165 return ((a<b)?a:b);
|
|
166 }
|
|
167
|
|
168
|
|
169 uint32_t MaxU32GFX(uint32_t a, uint32_t b)
|
|
170 {
|
|
171 return((a>b)?a:b);
|
|
172 }
|
|
173
|
|
174 /* Private function prototypes -----------------------------------------------*/
|
|
175
|
|
176 static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font);
|
|
177 static uint32_t GFX_write_substring(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, uint8_t textId, int8_t nextCharFor2Byte);
|
|
178 static uint32_t GFX_write__Modify_Xdelta__Centered(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pText);
|
|
179 static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput);
|
|
180 static void GFX_Error_Handler(void);
|
|
181 static void GFX_Dma2d_TransferComplete(DMA2D_HandleTypeDef* Dma2dHandle);
|
|
182 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle);
|
|
183 static void GFX_clear_frame_dma2d(uint8_t frameId);
|
|
184
|
|
185 static uint32_t GFX_doubleBufferOne(void);
|
|
186 static uint32_t GFX_doubleBufferTwo(void);
|
|
187
|
|
188 static void GFX_LTDC_Init_display1(void);
|
|
189
|
|
190
|
|
191 /* Exported functions --------------------------------------------------------*/
|
|
192
|
|
193 uint8_t GFX_logoStatus(void)
|
|
194 {
|
|
195 return logoStatus;
|
|
196 }
|
|
197
|
|
198 void GFX_SetWindowLayer0(uint32_t pDestination, int16_t XleftGimpStyle, int16_t XrightGimpStyle, int16_t YtopGimpStyle, int16_t YbottomGimpStyle)
|
|
199 {
|
|
200 int16_t XSize, YSize, X0, Y0;
|
|
201
|
|
202 if(XleftGimpStyle < 0) XleftGimpStyle = 0;
|
|
203 if(XrightGimpStyle < 0) XrightGimpStyle = 0;
|
|
204 if(XleftGimpStyle > 799) XleftGimpStyle = 800;
|
|
205 if(XrightGimpStyle > 799) XrightGimpStyle = 800;
|
|
206
|
|
207 if(YtopGimpStyle < 0) YtopGimpStyle = 0;
|
|
208 if(YbottomGimpStyle < 0) YbottomGimpStyle = 0;
|
|
209 if(YtopGimpStyle > 479) YtopGimpStyle = 480;
|
|
210 if(YbottomGimpStyle > 479) YbottomGimpStyle = 480;
|
|
211
|
|
212 /*
|
|
213 XSize = YbottomGimpStyle - YtopGimpStyle;
|
|
214 YSize = XrightGimpStyle - XleftGimpStyle;
|
|
215 if((XSize <= 0) || (YSize <= 0))
|
|
216 return;
|
|
217 X0 = 479 - YbottomGimpStyle;
|
|
218 Y0 = XleftGimpStyle;
|
|
219 while((LTDC->CPSR & LTDC_CPSR_CYPOS) <= (uint32_t)800);
|
|
220 HAL_LTDC_SetWindowSize(&LtdcHandle, XSize, YSize, LayerIdx);
|
|
221 HAL_LTDC_SetWindowPosition(&LtdcHandle, X0, Y0,LayerIdx);
|
|
222 HAL_LTDC_SetAddress(&LtdcHandle, pDestination, LayerIdx);
|
|
223 */
|
|
224
|
|
225 XSize = XrightGimpStyle - XleftGimpStyle;
|
|
226 YSize = YbottomGimpStyle - YtopGimpStyle;
|
|
227 if((XSize <= 0) || (YSize <= 0))
|
|
228 return;
|
|
229 Y0 = 479 - YbottomGimpStyle;
|
|
230 X0 = XleftGimpStyle;
|
|
231
|
|
232 GFX_SetFrameBottom(pDestination, X0, Y0, XSize, YSize);
|
|
233 }
|
|
234
|
|
235
|
|
236 void GFX_logoAutoOff(void)
|
|
237 {
|
|
238 if(logoStatus == LOGOOFF)
|
|
239 logoStatus = LOGOSTART;
|
|
240 }
|
|
241
|
|
242
|
|
243 void GFX_hwBackgroundOn(void)
|
|
244 {
|
|
245 backgroundHwStatus = LOGOSTART;
|
|
246 }
|
|
247
|
|
248
|
|
249 void GFX_hwBackgroundOff(void)
|
|
250 {
|
|
251 backgroundHwStatus = LOGOSTOP;
|
|
252 }
|
|
253
|
|
254 void GFX_build_hw_background_frame(void)
|
|
255 {
|
|
256 GFX_DrawCfgScreen tLogoTemp;
|
|
257 SWindowGimpStyle windowGimp;
|
|
258
|
|
259 pBackgroundHwFrame = getFrame(1);
|
|
260 backgroundHwStatus = 0;
|
|
261
|
|
262 tLogoTemp.FBStartAdress = pBackgroundHwFrame;
|
|
263 tLogoTemp.ImageHeight = 480;
|
|
264 tLogoTemp.ImageWidth = 800;
|
|
265 tLogoTemp.LayerIndex = 1;
|
|
266
|
|
267 windowGimp.left = (800 - 400) / 2;
|
|
268 windowGimp.top = 0;//(480 - 46) / 2;
|
|
269
|
|
270 GFX_draw_image_color(&tLogoTemp, windowGimp, &ImgHWcolor);
|
|
271 /*
|
|
272 char localtext[256];
|
|
273 uint8_t ptr = 0;
|
|
274
|
|
275 localtext[ptr++] = ' ';
|
|
276 localtext[ptr++] = ' ';
|
|
277 localtext[ptr++] = 'O';
|
|
278 localtext[ptr++] = 'S';
|
|
279 localtext[ptr++] = ' ';
|
|
280 ptr += GFX_printf_firmware(&localtext[ptr]);
|
|
281 localtext[ptr] = 0;
|
|
282
|
|
283 write_content_simple(&tLogoTemp, 0, 800, 240-24, &FontT24,localtext,CLUT_Font020);
|
|
284 */
|
|
285 }
|
|
286
|
|
287
|
|
288 void GFX_build_logo_frame(void)
|
|
289 {
|
|
290 GFX_DrawCfgScreen tLogoTemp;
|
|
291 SWindowGimpStyle windowGimp;
|
|
292
|
|
293 pLogoFrame = getFrame(1);
|
|
294 logoStatus = LOGOOFF;
|
|
295
|
|
296 tLogoTemp.FBStartAdress = pLogoFrame;
|
|
297 tLogoTemp.ImageHeight = 480;
|
|
298 tLogoTemp.ImageWidth = 800;
|
|
299 tLogoTemp.LayerIndex = 1;
|
|
300
|
|
301 windowGimp.left = (800 - 400) / 2;
|
|
302 windowGimp.top = (480 - 46) / 2;
|
|
303
|
|
304 GFX_draw_image_color(&tLogoTemp, windowGimp, &ImgHWcolor);
|
|
305 /*
|
|
306 char localtext[256];
|
|
307 uint8_t ptr = 0;
|
|
308
|
|
309 localtext[ptr++] = ' ';
|
|
310 localtext[ptr++] = ' ';
|
|
311 localtext[ptr++] = 'O';
|
|
312 localtext[ptr++] = 'S';
|
|
313 localtext[ptr++] = ' ';
|
|
314 ptr += GFX_printf_firmware(&localtext[ptr]);
|
|
315 localtext[ptr] = 0;
|
|
316
|
|
317 write_content_simple(&tLogoTemp, 0, 800, 240-24, &FontT24,localtext,CLUT_Font020);
|
|
318 */
|
|
319 }
|
|
320
|
|
321 void GFX_init(uint32_t * pDestinationOut)
|
|
322 {
|
|
323 frame[0].StartAddress = FBGlobalStart;
|
|
324 GFX_clear_frame_immediately(frame[0].StartAddress);
|
|
325 frame[0].status = CLEAR;
|
|
326 frame[0].caller = 0;
|
|
327
|
|
328 for(int i=1;i<MAXFRAMES;i++)
|
|
329 {
|
|
330 frame[i].StartAddress = frame[i-1].StartAddress + FBOffsetEachIndex;
|
|
331 GFX_clear_frame_immediately(frame[i].StartAddress);
|
|
332 frame[i].status = CLEAR;
|
|
333 frame[i].caller = 0;
|
|
334 }
|
|
335
|
|
336 pInvisibleFrame = getFrame(2);
|
|
337 *pDestinationOut = pInvisibleFrame;
|
|
338
|
|
339 GFX_build_logo_frame();
|
|
340 GFX_build_hw_background_frame();
|
|
341
|
|
342 /* Register to memory mode with ARGB8888 as color Mode */
|
|
343 Dma2dHandle.Init.Mode = DMA2D_R2M;
|
|
344 Dma2dHandle.Init.ColorMode = DMA2D_ARGB4444;//to fake AL88, before: DMA2D_ARGB8888;
|
|
345 Dma2dHandle.Init.OutputOffset = 0;
|
|
346
|
|
347 /* DMA2D Callbacks Configuration */
|
|
348 Dma2dHandle.XferCpltCallback = GFX_Dma2d_TransferComplete;
|
|
349 Dma2dHandle.XferErrorCallback = GFX_Dma2d_TransferError;
|
|
350
|
|
351 Dma2dHandle.Instance = DMA2D;
|
|
352
|
|
353 /* DMA2D Initialisation */
|
|
354 if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK)
|
|
355 GFX_Error_Handler();
|
|
356
|
|
357 if(HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1) != HAL_OK)
|
|
358 GFX_Error_Handler();
|
|
359
|
|
360 DMA2D_at_work = 255;
|
|
361 }
|
|
362 void GFX_init1_no_DMA(uint32_t * pDestinationOut, uint8_t blockFrames)
|
|
363 {
|
|
364 frame[0].StartAddress = FBGlobalStart;
|
|
365 GFX_clear_frame_immediately(frame[0].StartAddress);
|
|
366 frame[0].status = CLEAR;
|
|
367 frame[0].caller = 0;
|
|
368
|
|
369 for(int i=1;i<MAXFRAMES;i++)
|
|
370 {
|
|
371 frame[i].StartAddress = frame[i-1].StartAddress + FBOffsetEachIndex;
|
|
372 GFX_clear_frame_immediately(frame[i].StartAddress);
|
|
373 frame[i].status = CLEAR;
|
|
374 frame[i].caller = 0;
|
|
375 }
|
|
376
|
|
377 for(int i=0;i<blockFrames;i++)
|
|
378 {
|
|
379 frame[i].status = BLOCKED;
|
|
380 frame[i].caller = 1;
|
|
381 }
|
|
382
|
|
383 pInvisibleFrame = getFrame(2);
|
|
384 *pDestinationOut = pInvisibleFrame;
|
|
385
|
|
386 GFX_build_logo_frame();
|
|
387 GFX_build_hw_background_frame();
|
|
388 }
|
|
389
|
|
390
|
|
391 void GFX_init2_DMA(void)
|
|
392 {
|
|
393 /* Register to memory mode with ARGB8888 as color Mode */
|
|
394 Dma2dHandle.Init.Mode = DMA2D_R2M;
|
|
395 Dma2dHandle.Init.ColorMode = DMA2D_ARGB4444;//to fake AL88, before: DMA2D_ARGB8888;
|
|
396 Dma2dHandle.Init.OutputOffset = 0;
|
|
397
|
|
398 /* DMA2D Callbacks Configuration */
|
|
399 Dma2dHandle.XferCpltCallback = GFX_Dma2d_TransferComplete;
|
|
400 Dma2dHandle.XferErrorCallback = GFX_Dma2d_TransferError;
|
|
401
|
|
402 Dma2dHandle.Instance = DMA2D;
|
|
403
|
|
404 /* DMA2D Initialisation */
|
|
405 if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK)
|
|
406 GFX_Error_Handler();
|
|
407
|
|
408 if(HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1) != HAL_OK)
|
|
409 GFX_Error_Handler();
|
|
410
|
|
411 DMA2D_at_work = 255;
|
|
412 }
|
|
413
|
|
414
|
|
415 void GFX_SetFrameTop(uint32_t pDestination)
|
|
416 {
|
|
417 uint8_t NextTopWork = FrameHandler.NextTopWrite + 1;
|
|
418
|
|
419 if(NextTopWork == RING_BUF_SIZE)
|
|
420 {
|
|
421 NextTopWork = 0;
|
|
422 }
|
|
423
|
|
424 if(pDestination == 0)
|
|
425 pDestination = pInvisibleFrame;
|
|
426
|
|
427 FrameHandler.pNextTopBuffer[NextTopWork] = pDestination;
|
|
428 FrameHandler.NextTopWrite = NextTopWork;
|
|
429 }
|
|
430
|
|
431
|
|
432 void GFX_SetFrameBottom(uint32_t pDestination, uint32_t x0, uint32_t y0, uint32_t width, uint32_t height)
|
|
433 {
|
|
434 uint8_t NextBottomWork = FrameHandler.NextBottomWrite + 1;
|
|
435
|
|
436 if(NextBottomWork == RING_BUF_SIZE)
|
|
437 {
|
|
438 NextBottomWork = 0;
|
|
439 }
|
|
440
|
|
441 if(pDestination == 0)
|
|
442 pDestination = pInvisibleFrame;
|
|
443
|
|
444 FrameHandler.nextBottom[NextBottomWork].pBuffer = pDestination;
|
|
445 FrameHandler.nextBottom[NextBottomWork].height = height;
|
|
446 FrameHandler.nextBottom[NextBottomWork].width = width;
|
|
447 FrameHandler.nextBottom[NextBottomWork].leftStart = x0;
|
|
448 FrameHandler.nextBottom[NextBottomWork].bottomStart = y0;
|
|
449 FrameHandler.NextBottomWrite = NextBottomWork;
|
|
450 }
|
|
451
|
|
452
|
|
453 void GFX_SetFramesTopBottom(uint32_t pTop, uint32_t pBottom, uint32_t heightBottom)
|
|
454 {
|
|
455 GFX_SetFrameTop(pTop);
|
|
456 GFX_SetFrameBottom(pBottom, 0, 0, 800, heightBottom);
|
|
457 }
|
|
458
|
|
459
|
|
460 static uint32_t GFX_get_pActualFrameTop(void)
|
|
461 {
|
|
462 return FrameHandler.pActualTopBuffer;
|
|
463 }
|
|
464
|
|
465
|
|
466 static uint32_t GFX_get_pActualFrameBottom(void)
|
|
467 {
|
|
468 return FrameHandler.actualBottom.pBuffer;
|
|
469 }
|
|
470
|
|
471
|
|
472 void GFX_start_VSYNC_IRQ(void)
|
|
473 {
|
|
474 GPIO_InitTypeDef GPIO_InitStructure;
|
|
475
|
|
476 GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING;
|
|
477 GPIO_InitStructure.Pull = GPIO_NOPULL;
|
|
478 GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
|
479 GPIO_InitStructure.Pin = VSYNC_IRQ_PIN;
|
|
480 HAL_GPIO_Init(VSYNC_IRQ_GPIO_PORT, &GPIO_InitStructure);
|
|
481
|
|
482 HAL_NVIC_SetPriority(VSYNC_IRQ_EXTI_IRQn, 1, 0);
|
|
483 HAL_NVIC_EnableIRQ(VSYNC_IRQ_EXTI_IRQn);
|
|
484 }
|
|
485
|
|
486
|
|
487 void GFX_change_LTDC(void)
|
|
488 {
|
|
489 uint32_t pTop = 0;
|
|
490 uint32_t pBot = 0;
|
|
491 uint32_t heightBot = 0;
|
|
492 uint32_t widthBot = 0;
|
|
493 uint32_t leftStartBot = 0;
|
|
494 uint32_t bottomStartBot = 0;
|
|
495 uint8_t change_position = 0;
|
|
496 uint8_t change_size = 0;
|
|
497 uint8_t nextBottomBackup = FrameHandler.NextBottomRead; /* Restore entry value in case off logo handling */
|
|
498
|
|
499 // Top Frame
|
|
500 if(FrameHandler.NextTopRead != FrameHandler.NextTopWrite)
|
|
501 {
|
|
502 FrameHandler.NextTopRead++;
|
|
503 if(FrameHandler.NextTopRead == RING_BUF_SIZE)
|
|
504 {
|
|
505 FrameHandler.NextTopRead = 0;
|
|
506 }
|
|
507 }
|
|
508 pTop = FrameHandler.pNextTopBuffer[FrameHandler.NextTopRead];
|
|
509
|
|
510 if(FrameHandler.pActualTopBuffer != pTop)
|
|
511 {
|
|
512 HAL_LTDC_SetAddress(&LtdcHandle, pTop, 1);
|
|
513 FrameHandler.pActualTopBuffer = pTop;
|
|
514 }
|
|
515
|
|
516 // Bottom Frame
|
|
517 if(FrameHandler.NextBottomRead != FrameHandler.NextBottomWrite)
|
|
518 {
|
|
519 FrameHandler.NextBottomRead++;
|
|
520 if(FrameHandler.NextBottomRead == RING_BUF_SIZE)
|
|
521 {
|
|
522 FrameHandler.NextBottomRead = 0;
|
|
523 }
|
|
524 }
|
|
525 if(logoStatus != LOGOOFF)
|
|
526 {
|
|
527 switch(logoStatus)
|
|
528 {
|
|
529 case LOGOSTART:
|
|
530 HAL_LTDC_SetAlpha(&LtdcHandle, 0, 1);
|
|
531 HAL_LTDC_SetAlpha(&LtdcHandle, 34, 0);
|
|
532 HAL_LTDC_ConfigCLUT(&LtdcHandle, (uint32_t *)indexHWcolor, indexHWcolorSIZE, 0);
|
|
533 HAL_LTDC_SetAddress(&LtdcHandle, pLogoFrame, 0);
|
|
534 HAL_LTDC_SetWindowSize(&LtdcHandle, 480, 800, 0);
|
|
535 HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, 0, 0);
|
|
536 logoStatus = 2;
|
|
537 FrameHandler.NextBottomRead = nextBottomBackup;
|
|
538 break;
|
|
539
|
|
540 case LOGOSTOP:
|
|
541 HAL_LTDC_SetAlpha(&LtdcHandle, 255, 1);
|
|
542 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 0);
|
|
543
|
|
544 pBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].pBuffer;
|
|
545 heightBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].height;
|
|
546 widthBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].width;
|
|
547 leftStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].leftStart;
|
|
548 bottomStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].bottomStart;
|
|
549 HAL_LTDC_SetWindowSize(&LtdcHandle, heightBot, widthBot, 0);
|
|
550 HAL_LTDC_SetWindowPosition(&LtdcHandle, bottomStartBot, leftStartBot, 0);
|
|
551 HAL_LTDC_SetAddress(&LtdcHandle, pBot, 0);
|
|
552 HAL_LTDC_SetAlpha(&LtdcHandle, 255, 0);
|
|
553 FrameHandler.actualBottom.height = heightBot;
|
|
554 FrameHandler.actualBottom.width = widthBot;
|
|
555 FrameHandler.actualBottom.leftStart = leftStartBot;
|
|
556 FrameHandler.actualBottom.bottomStart = bottomStartBot;
|
|
557 FrameHandler.actualBottom.pBuffer = pBot;
|
|
558
|
|
559 logoStatus = LOGOOFF;
|
|
560 if(backgroundHwStatus == 2)
|
|
561 {
|
|
562 backgroundHwStatus = LOGOSTART;
|
|
563 }
|
|
564 break;
|
|
565 default:
|
|
566 if(logoStatus < 35)
|
|
567 {
|
|
568 logoStatus++;
|
|
569 if(logoStatus <= 15)
|
|
570 HAL_LTDC_SetAlpha(&LtdcHandle, 17*logoStatus, 0);
|
|
571 }
|
|
572 else
|
|
573 {
|
|
574 logoStatus +=20;
|
|
575 HAL_LTDC_SetAlpha(&LtdcHandle, logoStatus-55, 1);
|
|
576 HAL_LTDC_SetAlpha(&LtdcHandle, 255+55-logoStatus, 0);
|
|
577 }
|
|
578 FrameHandler.NextBottomRead = nextBottomBackup;
|
|
579 break;
|
|
580 }
|
|
581 return;
|
|
582 }
|
|
583 else if (backgroundHwStatus != LOGOOFF)
|
|
584 {
|
|
585
|
|
586 switch(backgroundHwStatus)
|
|
587 {
|
|
588 case LOGOSTART:
|
|
589 HAL_LTDC_ConfigCLUT(&LtdcHandle, (uint32_t *)indexHWcolor, indexHWcolorSIZE, 0);
|
|
590 HAL_LTDC_SetAddress(&LtdcHandle, pBackgroundHwFrame, 0);
|
|
591 HAL_LTDC_SetWindowSize(&LtdcHandle, 480, 800, 0);
|
|
592 HAL_LTDC_SetWindowPosition(&LtdcHandle, 0, 0, 0);
|
|
593 backgroundHwStatus = 2;
|
|
594 FrameHandler.NextBottomRead = nextBottomBackup;
|
|
595 break;
|
|
596
|
|
597 case LOGOSTOP:
|
|
598 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 0);
|
|
599 pBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].pBuffer;
|
|
600 heightBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].height;
|
|
601 widthBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].width;
|
|
602 leftStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].leftStart;
|
|
603 bottomStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].bottomStart;
|
|
604 HAL_LTDC_SetWindowSize(&LtdcHandle, heightBot, widthBot, 0);
|
|
605 HAL_LTDC_SetWindowPosition(&LtdcHandle, bottomStartBot, leftStartBot, 0);
|
|
606 HAL_LTDC_SetAddress(&LtdcHandle, pBot, 0);
|
|
607 HAL_LTDC_SetAlpha(&LtdcHandle, 255, 0);
|
|
608 FrameHandler.actualBottom.height = heightBot;
|
|
609 FrameHandler.actualBottom.width = widthBot;
|
|
610 FrameHandler.actualBottom.leftStart = leftStartBot;
|
|
611 FrameHandler.actualBottom.bottomStart = bottomStartBot;
|
|
612 FrameHandler.actualBottom.pBuffer = pBot;
|
|
613 backgroundHwStatus = LOGOOFF;
|
|
614 break;
|
|
615
|
|
616 default:
|
|
617 FrameHandler.NextBottomRead = nextBottomBackup;
|
|
618 break;
|
|
619 }
|
|
620
|
|
621 return;
|
|
622 }
|
|
623 else
|
|
624 {
|
|
625 pBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].pBuffer;
|
|
626 heightBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].height;
|
|
627 widthBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].width;
|
|
628 leftStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].leftStart;
|
|
629 bottomStartBot = FrameHandler.nextBottom[FrameHandler.NextBottomRead].bottomStart;
|
|
630
|
|
631 if(FrameHandler.actualBottom.pBuffer == pBot)
|
|
632 pBot = 0;
|
|
633
|
|
634 if((FrameHandler.actualBottom.height != heightBot) || (FrameHandler.actualBottom.width != widthBot))
|
|
635 change_size = 1;
|
|
636
|
|
637 if((FrameHandler.actualBottom.leftStart != leftStartBot) || (FrameHandler.actualBottom.bottomStart != bottomStartBot))
|
|
638 change_position = 1;
|
|
639
|
|
640 if(pBot || change_size || change_position)
|
|
641 {
|
|
642 if(heightBot && widthBot)
|
|
643 HAL_LTDC_SetWindowSize(&LtdcHandle, heightBot, widthBot, 0);
|
|
644
|
|
645 if(change_position || leftStartBot || bottomStartBot)
|
|
646 HAL_LTDC_SetWindowPosition(&LtdcHandle, bottomStartBot, leftStartBot, 0);
|
|
647
|
|
648 if(pBot)
|
|
649 HAL_LTDC_SetAddress(&LtdcHandle, pBot, 0);
|
|
650
|
|
651 if(change_size)
|
|
652 {
|
|
653 FrameHandler.actualBottom.height = heightBot;
|
|
654 FrameHandler.actualBottom.width = widthBot;
|
|
655 }
|
|
656 if(change_position)
|
|
657 {
|
|
658 FrameHandler.actualBottom.leftStart = leftStartBot;
|
|
659 FrameHandler.actualBottom.bottomStart = bottomStartBot;
|
|
660 }
|
|
661 if(pBot)
|
|
662 FrameHandler.actualBottom.pBuffer = pBot;
|
|
663 }
|
|
664 }
|
|
665 }
|
|
666
|
|
667 uint8_t GFX_is_colorschemeDiveStandard(void)
|
|
668 {
|
|
669 return (ColorLUT[CLUT_Font027] == 0x00FFFFFF);
|
|
670 }
|
|
671
|
|
672
|
|
673 void change_CLUT_entry(uint8_t entryToChange, uint8_t entryUsedForChange)
|
|
674 {
|
|
675 /* bug fix
|
|
676 static uint8_t counter = 0;
|
|
677
|
|
678 if(entryToChange == 0x1C)
|
|
679 counter++;
|
|
680 */
|
|
681 ColorLUT[entryToChange] = ColorLUT[entryUsedForChange];
|
|
682 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 1);
|
|
683 if(logoStatus == LOGOOFF)
|
|
684 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, 0);
|
|
685 }
|
|
686
|
|
687
|
|
688 void GFX_use_colorscheme(uint8_t colorscheme)
|
|
689 {
|
|
690 uint8_t ColorSchemeStart;
|
|
691
|
|
692 if(colorscheme > 3)
|
|
693 colorscheme = 0;
|
|
694
|
|
695 ColorSchemeStart = CLUT_Colorscheme0 + (8 * colorscheme);
|
|
696 for(int i=1; i<8; i++)
|
|
697 {
|
|
698 ColorLUT[CLUT_Font027 + i] = ColorLUT[ColorSchemeStart + i];
|
|
699 }
|
|
700 change_CLUT_entry(CLUT_Font027, ColorSchemeStart);
|
|
701 }
|
|
702
|
|
703
|
|
704 void GFX_VGA_transform(uint32_t pSource, uint32_t pDestination)
|
|
705 {
|
|
706 int h, v;
|
|
707 uint32_t offsetSource, offsetSourceStartOfLine;
|
|
708
|
|
709 offsetSourceStartOfLine = 480 + 480 - 2;
|
|
710 for(v=0;v<480;v++)
|
|
711 {
|
|
712 offsetSource = offsetSourceStartOfLine;
|
|
713 for(h=0;h<640;h++)
|
|
714 {
|
|
715 *(__IO uint8_t*)pDestination = *(uint8_t*)(pSource + offsetSource);
|
|
716 pDestination++;
|
|
717 offsetSource += 1;
|
|
718 *(__IO uint8_t*)pDestination = *(uint8_t*)(pSource + offsetSource);
|
|
719 pDestination++;
|
|
720 offsetSource += 480 + 479;
|
|
721 }
|
|
722 offsetSourceStartOfLine -= 2;
|
|
723 }
|
|
724 }
|
|
725
|
|
726
|
|
727 static void GFX_clear_frame_immediately(uint32_t pDestination)
|
|
728 {
|
|
729 uint32_t i;
|
|
730 uint32_t* pfill = (uint32_t*) pDestination;
|
|
731
|
|
732
|
|
733 for(i = 200*480; i > 0; i--)
|
|
734 {
|
|
735 *pfill++ = 0;
|
|
736 *pfill++ = 0;
|
|
737 }
|
|
738 }
|
|
739
|
|
740
|
|
741 void GFX_clear_window_immediately(GFX_DrawCfgWindow* hgfx)
|
|
742 {
|
|
743 uint32_t pDestination, i, j;
|
|
744 uint16_t left, width, bottom, height, nextlineStep;
|
|
745
|
|
746 pDestination = (uint32_t)hgfx->Image->FBStartAdress;
|
|
747
|
|
748 left = hgfx->WindowX0;
|
|
749 width = 1 + hgfx->WindowX1 - left;
|
|
750 bottom = hgfx->WindowY0;
|
|
751 height = 1 + hgfx->WindowY1 - bottom;
|
|
752 nextlineStep = hgfx->Image->ImageHeight - height;
|
|
753 nextlineStep *= 2;
|
|
754
|
|
755 pDestination += 2 * bottom;
|
|
756 pDestination += 2 * hgfx->Image->ImageHeight * left;
|
|
757
|
|
758 for(j = width; j > 0; j--)
|
|
759 {
|
|
760 for(i = height; i > 0; i--)
|
|
761 {
|
|
762 *(__IO uint16_t*)pDestination = 0;
|
|
763 pDestination += 2;
|
|
764 }
|
|
765 pDestination += nextlineStep;
|
|
766 }
|
|
767 }
|
|
768
|
|
769
|
|
770 static void GFX_clear_frame_dma2d(uint8_t frameId)
|
|
771 {
|
|
772 if(frameId >= MAXFRAMES)
|
|
773 return;
|
|
774
|
|
775 DMA2D_at_work = frameId;
|
|
776
|
|
777 if (HAL_DMA2D_Start_IT(&Dma2dHandle, 0x0000000000, frame[frameId].StartAddress, 480, 800) != HAL_OK)
|
|
778 GFX_Error_Handler();
|
|
779 }
|
|
780
|
|
781
|
|
782 void GFX_fill_buffer(uint32_t pDestination, uint8_t alpha, uint8_t color)
|
|
783 {
|
|
784
|
|
785 union al88_u
|
|
786 {
|
|
787 uint8_t al8[2];
|
|
788 uint16_t al88;
|
|
789 };
|
|
790 union al88_u colorcombination;
|
|
791 uint32_t i;
|
|
792 uint32_t* pfill = (uint32_t*) pDestination;
|
|
793 uint32_t fillpattern;
|
|
794
|
|
795 colorcombination.al8[0] = color;
|
|
796 colorcombination.al8[1] = alpha;
|
|
797
|
|
798 fillpattern = (colorcombination.al88 << 16) | colorcombination.al88;
|
|
799 for(i = 800*480/2; i > 0; i--)
|
|
800 {
|
|
801 *pfill++ = fillpattern;
|
|
802 }
|
|
803 }
|
|
804
|
|
805 static void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image)
|
|
806 {
|
|
807 uint16_t* pDestination;
|
|
808
|
|
809 uint32_t j;
|
|
810 point_t start, stop;
|
|
811
|
|
812 start.x = window.left;
|
|
813 start.y = (hgfx->ImageHeight - image->height - window.top);
|
|
814 stop.y = start.y + image->height;
|
|
815 stop.x = start.x + image->width;
|
|
816 j = 0;
|
|
817
|
|
818 for(int xx = start.x; xx < stop.x; xx++)
|
|
819 {
|
|
820 pDestination = (uint16_t*)hgfx->FBStartAdress;
|
|
821 pDestination += xx * hgfx->ImageHeight;
|
|
822 pDestination += start.y;
|
|
823 for(int yy = start.y; yy < stop.y; yy++)
|
|
824 {
|
|
825 *(__IO uint16_t*)pDestination++ = 0xFF << 8 | image->data[j++];
|
|
826 }
|
|
827 }
|
|
828 }
|
|
829
|
|
830
|
|
831 /* this is NOT fast nor optimized */
|
|
832 static void GFX_draw_pixel(GFX_DrawCfgScreen *hgfx, int16_t x, int16_t y, uint8_t color)
|
|
833 {
|
|
834 uint16_t* pDestination;
|
|
835
|
|
836 pDestination = (uint16_t*)hgfx->FBStartAdress;
|
|
837 pDestination += x * hgfx->ImageHeight;
|
|
838 pDestination += y;
|
|
839
|
|
840 *(__IO uint16_t*)pDestination = 0xFF << 8 | color;
|
|
841 }
|
|
842
|
|
843 /* this is NOT fast nor optimized */
|
|
844 void GFX_draw_circle(GFX_DrawCfgScreen *hgfx, point_t center, uint8_t radius, int8_t color)
|
|
845 {
|
|
846 int x, y;
|
|
847 int l;
|
|
848 int r2, y2;
|
|
849 int y2_new;
|
|
850 int ty;
|
|
851
|
|
852 /* cos pi/4 = 185363 / 2^18 (approx) */
|
|
853 l = (radius * 185363) >> 18;
|
|
854
|
|
855 /* hw */
|
|
856 l += 1;
|
|
857
|
|
858 /* At x=0, y=radius */
|
|
859 y = radius;
|
|
860
|
|
861 r2 = y2 = y * y;
|
|
862 ty = (2 * y) - 1;
|
|
863 y2_new = r2 + 3;
|
|
864
|
|
865 for (x = 0; x <= l; x++) {
|
|
866 y2_new -= (2 * x) - 3;
|
|
867
|
|
868 if ((y2 - y2_new) >= ty) {
|
|
869 y2 -= ty;
|
|
870 y -= 1;
|
|
871 ty -= 2;
|
|
872 }
|
|
873
|
|
874 GFX_draw_pixel (hgfx, x + center.x, y + center.y, color);
|
|
875 GFX_draw_pixel (hgfx, x + center.x, -y + center.y, color);
|
|
876 GFX_draw_pixel (hgfx, -x + center.x, y + center.y, color);
|
|
877 GFX_draw_pixel (hgfx, -x + center.x, -y + center.y, color);
|
|
878
|
|
879 GFX_draw_pixel (hgfx, y + center.x, x + center.y, color);
|
|
880 GFX_draw_pixel (hgfx, y + center.x, -x + center.y, color);
|
|
881 GFX_draw_pixel (hgfx, -y + center.x, x + center.y, color);
|
|
882 GFX_draw_pixel (hgfx, -y + center.x, -x + center.y, color);
|
|
883 }
|
|
884 }
|
|
885
|
|
886
|
|
887 void GFX_draw_colorline(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color)
|
|
888 {
|
|
889 uint32_t pDestination;
|
|
890 uint32_t j;
|
|
891 uint32_t temp;
|
|
892
|
|
893 if(start.x == stop.x)
|
|
894 {
|
|
895 if(stop.y < start.y)
|
|
896 {
|
|
897 temp = stop.y;
|
|
898 stop.y = start.y;
|
|
899 start.y = temp;
|
|
900 }
|
|
901 pDestination = (uint32_t)hgfx->FBStartAdress;
|
|
902 pDestination += start.x * hgfx->ImageHeight * 2;
|
|
903 pDestination += start.y * 2;
|
|
904 for (j = stop.y - start.y; j > 0; j--)
|
|
905 {
|
|
906 *(__IO uint8_t*)pDestination = color;
|
|
907 pDestination += 1;
|
|
908 *(__IO uint8_t*)pDestination = 0xFF;
|
|
909 pDestination += 1;
|
|
910 }
|
|
911 }
|
|
912 else
|
|
913 if(start.y == stop.y)
|
|
914 {
|
|
915 if(stop.x < start.x)
|
|
916 {
|
|
917 temp = stop.x;
|
|
918 stop.x = start.x;
|
|
919 start.x = temp;
|
|
920 }
|
|
921 pDestination = (uint32_t)hgfx->FBStartAdress;
|
|
922 pDestination += start.x * hgfx->ImageHeight * 2;
|
|
923 pDestination += start.y * 2;
|
|
924 for (j = stop.x - start.x; j > 0; j--)
|
|
925 {
|
|
926 *(__IO uint8_t*)pDestination = color;
|
|
927 pDestination += 1;
|
|
928 *(__IO uint8_t*)pDestination = 0xFF;
|
|
929 pDestination -= 1;
|
|
930 pDestination += hgfx->ImageHeight * 2;
|
|
931 }
|
|
932 }
|
|
933 else // diagonal Bresenham's_line_algorithm
|
|
934 {
|
|
935 int x0 = start.x;
|
|
936 int y0 = start.y;
|
|
937 int x1 = stop.x;
|
|
938 int y1 = stop.y;
|
|
939 int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
|
|
940 int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
|
|
941 int err = (dx>dy ? dx : -dy)/2, e2;
|
|
942
|
|
943 for(;;)
|
|
944 {
|
|
945 pDestination = (uint32_t)hgfx->FBStartAdress;
|
|
946 pDestination += ((x0 * hgfx->ImageHeight) + y0) * 2;
|
|
947 *(__IO uint8_t*)pDestination = color;
|
|
948 pDestination += 1;
|
|
949 *(__IO uint8_t*)pDestination = 0xFF;
|
|
950 if (x0==x1 && y0==y1) break;
|
|
951 e2 = err;
|
|
952 if (e2 >-dx) { err -= dy; x0 += sx; }
|
|
953 if (e2 < dy) { err += dx; y0 += sy; }
|
|
954 }
|
|
955 }
|
|
956 }
|
|
957
|
|
958 // ===============================================================================
|
|
959 // GFX_graph_print
|
|
960 /// @brief Print all those nice curves, especially in logbook und miniLiveLogGraph
|
|
961 /// @version 0.0.2 hw 160519
|
|
962 ///
|
|
963 /// 151022 hw -bug fix
|
|
964 /// - die aktuelle Version macht keine Linien mehr �ber die gesamte Bildschirmh�he.
|
|
965 /// - daf�r sind L�cher in der Kurve (z.B. Temperaturgraph Tauchgang Matthias 17.10.15 15:19)
|
|
966 ///
|
|
967 /// more details about range can be found in show_logbook_logbook_show_log_page2() - temperature graph
|
|
968 ///
|
|
969 /// @param window: top and bottom is only the range used by the data of the graph, not the entire screen / scale
|
|
970 /// @param drawVeilUntil: ist auff�llen des Bereichs unter der Kurve mit etwas hellerer Farbe
|
|
971 /// @param Xdivide: wird bisher nichr benutzt.
|
|
972 // ===============================================================================
|
|
973
|
|
974
|
|
975 void GFX_graph_print(GFX_DrawCfgScreen *hgfx, const SWindowGimpStyle *window, const int16_t drawVeilUntil, uint8_t Xdivide, uint16_t dataMin, uint16_t dataMax, uint16_t *data, uint16_t datalength, uint8_t color, uint8_t *colour_data)
|
|
976 {
|
|
977 uint16_t* pDestination_tmp;
|
|
978 uint16_t* pDestination_start;
|
|
979 uint16_t* pDestination_end;
|
|
980 uint16_t* pDestination_zero_veil;
|
|
981
|
|
982 uint32_t max = 0;
|
|
983 int windowheight = -1;
|
|
984 int windowwidth = -1;
|
|
985 int i = -1;
|
|
986 int w1 = -1;
|
|
987 int w2 = -1;
|
|
988
|
|
989 uint32_t h_ulong = 0;
|
|
990 uint32_t h_ulong_old = 0;
|
|
991 _Bool invert = 0;
|
|
992
|
|
993 uint16_t dataDelta = 0;
|
|
994 uint16_t dataDeltaHalve = 0;
|
|
995 uint16_t dataTemp = 0;
|
|
996
|
|
997 uint8_t colorDataTemp;
|
|
998 uint8_t colormask = 0;
|
|
999
|
|
1000 pDestination_zero_veil = 0;
|
|
1001
|
|
1002 if(dataMin > dataMax)
|
|
1003 {
|
|
1004 uint16_t dataFlip;
|
|
1005 dataFlip = dataMin;
|
|
1006 dataMin = dataMax;
|
|
1007 dataMax = dataFlip;
|
|
1008 invert = 1;
|
|
1009 }
|
|
1010 else
|
|
1011 invert = 0;
|
|
1012
|
|
1013 colormask = color;
|
|
1014
|
|
1015 if(window->bottom > 479)
|
|
1016 return;
|
|
1017 if(window->top > 479)
|
|
1018 return;
|
|
1019 if(window->right > 799)
|
|
1020 return;
|
|
1021 if(window->left > 799)
|
|
1022 return;
|
|
1023 if(window->bottom < 0)
|
|
1024 return;
|
|
1025 if(window->top < 0)
|
|
1026 return;
|
|
1027 if(window->right < 0)
|
|
1028 return;
|
|
1029 if(window->left < 0)
|
|
1030 return;
|
|
1031 if(window->bottom <= window->top)
|
|
1032 return;
|
|
1033 if(window->right <= window->left)
|
|
1034 return;
|
|
1035
|
|
1036 windowheight = window->bottom - window->top ;
|
|
1037 windowwidth = window->right - window->left;
|
|
1038 w1 = 0;
|
|
1039 w2 = 0;
|
|
1040 if(dataMax == dataMin)
|
|
1041 dataMax++;
|
|
1042 dataDelta = (unsigned long)(dataMax - dataMin);
|
|
1043 dataDeltaHalve = dataDelta / 2;
|
|
1044 while((w1 <= windowwidth) && (w2 < datalength))
|
|
1045 {
|
|
1046 int tmp = (10 * w1 * (long)datalength)/windowwidth;
|
|
1047 w2 = tmp/10;
|
|
1048 int rest = tmp - w2*10;
|
|
1049 if(rest >= 5)
|
|
1050 w2++;
|
|
1051
|
|
1052 if((datalength - 1) < w2)
|
|
1053 w2 = datalength-1;
|
|
1054
|
|
1055 if(colour_data != NULL)
|
|
1056 {
|
|
1057 colorDataTemp = colour_data[w2];
|
|
1058 colormask = color + colorDataTemp;
|
|
1059 }
|
|
1060
|
|
1061 dataTemp = data[w2];
|
|
1062 if(Xdivide > 1)
|
|
1063 {
|
|
1064 w2++;
|
|
1065 for(i=1;i<Xdivide;i++)
|
|
1066 {
|
|
1067 if(data[w2]>dataTemp)
|
|
1068 dataTemp = data[w2];
|
|
1069 w2++;
|
|
1070 }
|
|
1071 }
|
|
1072
|
|
1073 if(dataTemp > dataMin)
|
|
1074 dataTemp -= dataMin;
|
|
1075 else
|
|
1076 dataTemp = 0;
|
|
1077
|
|
1078 if(invert)
|
|
1079 {
|
|
1080 if(dataTemp < dataDelta)
|
|
1081 dataTemp = dataDelta - dataTemp;
|
|
1082 else
|
|
1083 dataTemp = 0;
|
|
1084 }
|
|
1085
|
|
1086 h_ulong = (unsigned long)dataTemp;
|
|
1087 h_ulong *= windowheight;
|
|
1088 h_ulong += dataDeltaHalve;
|
|
1089 h_ulong /= dataDelta;
|
|
1090
|
|
1091 if(h_ulong > (window->bottom - window->top))
|
|
1092 h_ulong = (window->bottom - window->top);
|
|
1093
|
|
1094 if(drawVeilUntil > 0)
|
|
1095 {
|
|
1096 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress;
|
|
1097 pDestination_zero_veil += ((479 - (drawVeilUntil - 2) ) + ((w1 + window->left) * hgfx->ImageHeight) );
|
|
1098 }
|
|
1099 else if(drawVeilUntil < 0 )
|
|
1100 {
|
|
1101 pDestination_zero_veil = (uint16_t*)hgfx->FBStartAdress;
|
|
1102 pDestination_zero_veil += ((479 + (drawVeilUntil)) + ((w1 + window->left) * hgfx->ImageHeight) );
|
|
1103 }
|
|
1104
|
|
1105 if(h_ulong + window->top > max)
|
|
1106 {
|
|
1107 max = h_ulong + window->top;
|
|
1108 }
|
|
1109
|
|
1110 // hw 160519 wof�r ist das? Damit funktioniert Temperatur 25,5�C nicht!
|
|
1111 // if((dataMax == 255) || (data[w2] != 255))
|
|
1112 // {
|
|
1113 //output_content[pointer] = colormask;
|
|
1114 //output_mask[pointer] = true;
|
|
1115 if(dataTemp != 0xFFFF) /* do not draw invalid data pixels */
|
|
1116 {
|
|
1117 if(w1 > 0)
|
|
1118 {
|
|
1119 pDestination_start = (uint16_t*)hgfx->FBStartAdress;
|
|
1120 pDestination_start += (((479 - (window->top)) + ((w1 + window->left) * hgfx->ImageHeight)));
|
|
1121 pDestination_end = pDestination_start;
|
|
1122
|
|
1123 if(h_ulong >= h_ulong_old)
|
|
1124 {
|
|
1125 pDestination_start -= h_ulong_old;
|
|
1126 pDestination_end -= h_ulong;
|
|
1127
|
|
1128 }
|
|
1129 else
|
|
1130 {
|
|
1131 if(h_ulong < h_ulong_old)
|
|
1132 {
|
|
1133 pDestination_start += h_ulong_old;
|
|
1134 pDestination_end += h_ulong;
|
|
1135 }
|
|
1136 else
|
|
1137 {
|
|
1138 pDestination_start += h_ulong;
|
|
1139 pDestination_end += h_ulong_old;
|
|
1140 }
|
|
1141 }
|
|
1142
|
|
1143
|
|
1144 // deco stops
|
|
1145 if(drawVeilUntil < 0)
|
|
1146 {
|
|
1147 pDestination_tmp = pDestination_end;
|
|
1148 while(pDestination_tmp <= pDestination_zero_veil)
|
|
1149 {
|
|
1150 *(__IO uint16_t*)pDestination_tmp = (0x80 << 8) | colormask;
|
|
1151 pDestination_tmp++;
|
|
1152 }
|
|
1153 }
|
|
1154 else
|
|
1155 {
|
|
1156 // regular graph with veil underneath if requested
|
|
1157 // von oben nach unten
|
|
1158 // von grossen pDestination Werten zu kleinen pDestination Werten
|
|
1159 {
|
|
1160 pDestination_tmp = pDestination_start;
|
|
1161 while(pDestination_tmp >= pDestination_end)
|
|
1162 {
|
|
1163 *(__IO uint16_t*)pDestination_tmp = (0xFF << 8) | colormask ;
|
|
1164 pDestination_tmp--;
|
|
1165 }
|
|
1166 }
|
|
1167
|
|
1168 while((drawVeilUntil > 0) && (pDestination_tmp >= pDestination_zero_veil))
|
|
1169 {
|
|
1170 *(__IO uint16_t*)pDestination_tmp = (0x20 << 8) | colormask ;
|
|
1171 pDestination_tmp--;
|
|
1172 }
|
|
1173 }
|
|
1174 }
|
|
1175 h_ulong_old = h_ulong;
|
|
1176 }
|
|
1177 w1++;
|
|
1178 w2++;
|
|
1179 }
|
|
1180 }
|
|
1181
|
|
1182
|
|
1183 void GFX_draw_header(GFX_DrawCfgScreen *hgfx, uint8_t colorId)
|
|
1184 {
|
|
1185 uint32_t pDestination;
|
|
1186 point_t start, stop, now;
|
|
1187 uint8_t alpha;
|
|
1188
|
|
1189 /* display coordinate system */
|
|
1190 start.y = 400;
|
|
1191 stop.y = 479;
|
|
1192
|
|
1193 start.x = 0;
|
|
1194 stop.x = 799;
|
|
1195
|
|
1196 now.y = start.y;
|
|
1197 now.x = start.x;
|
|
1198
|
|
1199 while (now.x <= stop.x)
|
|
1200 {
|
|
1201 now.y = start.y;
|
|
1202 pDestination = (uint32_t)hgfx->FBStartAdress;
|
|
1203 pDestination += now.x * hgfx->ImageHeight * 2;
|
|
1204 pDestination += now.y * 2;
|
|
1205 now.x += 1;
|
|
1206
|
|
1207 alpha = 27;
|
|
1208 while(alpha < 246)
|
|
1209 {
|
|
1210 alpha += 9;
|
|
1211 *(__IO uint8_t*)pDestination = colorId;
|
|
1212 pDestination += 1;
|
|
1213 *(__IO uint8_t*)pDestination = alpha;
|
|
1214 pDestination += 1;
|
|
1215 now.y += 1;
|
|
1216 }
|
|
1217
|
|
1218 while(now.y <= stop.y)
|
|
1219 {
|
|
1220 *(__IO uint8_t*)pDestination = colorId;
|
|
1221 pDestination += 1;
|
|
1222 *(__IO uint8_t*)pDestination = 0xFF;
|
|
1223 pDestination += 1;
|
|
1224 now.y += 1;
|
|
1225 }
|
|
1226 }
|
|
1227 }
|
|
1228
|
|
1229 void GFX_draw_box2(GFX_DrawCfgScreen *hgfx, point_t start, point_t stop, uint8_t color, uint8_t roundCorners)
|
|
1230 {
|
|
1231 point_t point2, point4;
|
|
1232
|
|
1233 if(roundCorners)
|
|
1234 {
|
|
1235 point2.x = stop.x - start.x;
|
|
1236 point2.y = stop.y - start.y;
|
|
1237 GFX_draw_box(hgfx,start,point2,1,color);
|
|
1238 }
|
|
1239 else
|
|
1240 {
|
|
1241 point2.x = stop.x;
|
|
1242 point2.y = start.y;
|
|
1243
|
|
1244 point4.x = start.x;
|
|
1245 point4.y = stop.y;
|
|
1246
|
|
1247 GFX_draw_line(hgfx,start,point2,color);
|
|
1248 GFX_draw_line(hgfx,point2,stop,color);
|
|
1249 GFX_draw_line(hgfx,stop,point4,color);
|
|
1250 GFX_draw_line(hgfx,point4,start,color);
|
|
1251 }
|
|
1252 }
|
|
1253
|
|
1254 void GFX_draw_box(GFX_DrawCfgScreen *hgfx, point_t LeftLow, point_t WidthHeight, uint8_t Style, uint8_t color)
|
|
1255 {
|
|
1256 uint16_t* pDestination;
|
|
1257 uint16_t* pStart;
|
|
1258 uint32_t j;
|
|
1259 uint32_t lineWidth, lineHeight;
|
|
1260 int x, y;
|
|
1261 uint8_t intensity;
|
|
1262 int stepdir;
|
|
1263
|
|
1264 typedef struct {
|
|
1265 int x;
|
|
1266 int y;
|
|
1267 uint8_t intensity;
|
|
1268 } corner_t;
|
|
1269 const corner_t corner[16] = {
|
|
1270 {3,3,255}, // nur einmal
|
|
1271 {9,0,242},
|
|
1272 {8,0,194},
|
|
1273 {7,0,115},
|
|
1274 {6,0,36},
|
|
1275 {9,1,33},
|
|
1276 {8,1,84},
|
|
1277 {7,1,161},
|
|
1278 {6,1,255},
|
|
1279 {5,1,242},
|
|
1280 {4,1,36},
|
|
1281 {6,2,33},
|
|
1282 {5,2,84},
|
|
1283 {4,2,255},
|
|
1284 {3,2,84},
|
|
1285 {4,3,110}
|
|
1286 };
|
|
1287
|
|
1288 lineWidth = WidthHeight.x;
|
|
1289 lineHeight = WidthHeight.y;
|
|
1290 pStart = (uint16_t*)hgfx->FBStartAdress;
|
|
1291
|
|
1292 pStart += LeftLow.x * hgfx->ImageHeight;
|
|
1293 pStart += LeftLow.y;
|
|
1294 stepdir = 1;
|
|
1295
|
|
1296 // Untere Linie
|
|
1297 pDestination = pStart;
|
|
1298 if(Style)
|
|
1299 {
|
|
1300 pDestination += stepdir * 10 * hgfx->ImageHeight;
|
|
1301 lineWidth -= 18;
|
|
1302 }
|
|
1303 for (j = lineWidth; j > 0; j--)
|
|
1304 {
|
|
1305
|
|
1306 *(__IO uint16_t*)pDestination = 0xFF00 + color;
|
|
1307 pDestination += stepdir * hgfx->ImageHeight;
|
|
1308 }
|
|
1309
|
|
1310 // Obere Linie
|
|
1311
|
|
1312 pDestination = pStart + stepdir * WidthHeight.y;
|
|
1313 if(Style)
|
|
1314 {
|
|
1315 pDestination += stepdir * 10 * hgfx->ImageHeight;
|
|
1316 }
|
|
1317
|
|
1318 for (j = lineWidth; j > 0; j--)
|
|
1319 {
|
|
1320 *(__IO uint16_t*)pDestination = 0xFF00 + color;
|
|
1321 pDestination += stepdir * hgfx->ImageHeight;
|
|
1322 }
|
|
1323
|
|
1324 // Linke Linie
|
|
1325 pDestination = pStart;
|
|
1326
|
|
1327 if(Style)
|
|
1328 {
|
|
1329 pDestination += stepdir * 10;
|
|
1330 lineHeight -= 18;
|
|
1331 }
|
|
1332
|
|
1333 for (j = lineHeight; j > 0; j--)
|
|
1334 {
|
|
1335 *(__IO uint16_t*)pDestination = 0xFF00 + color;
|
|
1336 pDestination += stepdir;
|
|
1337 }
|
|
1338
|
|
1339
|
|
1340 // Rechte Linie
|
|
1341
|
|
1342 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight;
|
|
1343 if(Style)
|
|
1344 {
|
|
1345 pDestination += stepdir * 10;
|
|
1346 }
|
|
1347
|
|
1348 for (j = lineHeight; j > 0; j--)
|
|
1349 {
|
|
1350 *(__IO uint16_t*)pDestination = 0xFF00 + color;
|
|
1351 pDestination += stepdir;
|
|
1352 }
|
|
1353
|
|
1354
|
|
1355 // Ecken wenn notwendig == Style
|
|
1356 if(Style)
|
|
1357 {
|
|
1358 // links unten
|
|
1359 pDestination = pStart;
|
|
1360 x = corner[0].x;
|
|
1361 y = corner[0].y;
|
|
1362 intensity = corner[0].intensity;
|
|
1363
|
|
1364 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1365
|
|
1366 for(j = 15; j > 0; j--)
|
|
1367 {
|
|
1368 x = corner[j].x;
|
|
1369 y = corner[j].y;
|
|
1370 intensity = corner[j].intensity;
|
|
1371 *(__IO uint16_t*)(pDestination + stepdir * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1372 *(__IO uint16_t*)(pDestination + stepdir * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1373 }
|
|
1374 // links oben
|
|
1375 pDestination = pStart + stepdir * WidthHeight.y;
|
|
1376 x = corner[0].x;
|
|
1377 y = corner[0].y;
|
|
1378 intensity = corner[0].intensity;
|
|
1379 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1380
|
|
1381 for(j = 15; j > 0; j--)
|
|
1382 {
|
|
1383 x = corner[j].x;
|
|
1384 y = corner[j].y;
|
|
1385 intensity = corner[j].intensity;
|
|
1386 *(__IO uint16_t*)(pDestination + stepdir * (-y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1387 *(__IO uint16_t*)(pDestination + stepdir * (-x + (y * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1388 }
|
|
1389 // rechts unten
|
|
1390 pDestination = pStart + stepdir * WidthHeight.x * hgfx->ImageHeight;
|
|
1391 x = corner[0].x;
|
|
1392 y = corner[0].y;
|
|
1393 intensity = corner[0].intensity;
|
|
1394 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1395
|
|
1396 for(j = 15; j > 0; j--)
|
|
1397 {
|
|
1398 x = corner[j].x;
|
|
1399 y = corner[j].y;
|
|
1400 intensity = corner[j].intensity;
|
|
1401 *(__IO uint16_t*)(pDestination + stepdir * (y - (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1402 *(__IO uint16_t*)(pDestination + stepdir * (x - (y * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1403 }
|
|
1404 // rechts oben
|
|
1405 pDestination = pStart + stepdir * WidthHeight.y + stepdir * WidthHeight.x * hgfx->ImageHeight;
|
|
1406 x = corner[0].x;
|
|
1407 y = corner[0].y;
|
|
1408 intensity = corner[0].intensity;
|
|
1409 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1410
|
|
1411 for(j = 15; j > 0; j--)
|
|
1412 {
|
|
1413 x = corner[j].x;
|
|
1414 y = corner[j].y;
|
|
1415 intensity = corner[j].intensity;
|
|
1416 *(__IO uint16_t*)(pDestination + stepdir * -1 * (y + (x * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1417 *(__IO uint16_t*)(pDestination + stepdir * -1 * (x + (y * hgfx->ImageHeight))) = (intensity << 8) + color;
|
|
1418 }
|
|
1419 }
|
|
1420 }
|
|
1421
|
|
1422
|
|
1423 /**
|
|
1424 ******************************************************************************
|
|
1425 * @brief GFX write label. / Write string with defined color
|
|
1426 * @author heinrichs weikamp gmbh
|
|
1427 * @version V0.0.1
|
|
1428 * @date 07-July-2014
|
|
1429 ******************************************************************************
|
|
1430 *
|
|
1431 * @param hgfx: check gfx_engine.h.
|
|
1432 * @param color: 16bit Alpha+CLUT.
|
|
1433 * @retval None
|
|
1434 */
|
|
1435
|
|
1436 uint32_t GFX_write_label(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint8_t color)
|
|
1437 {
|
|
1438 return GFX_write_string_color(Font, hgfx, pText, 0, color);
|
|
1439 }
|
|
1440
|
|
1441
|
|
1442 /**
|
|
1443 ******************************************************************************
|
|
1444 * @brief GFX writeGfx_write_label_varstring. / Write string with all parameters and font color options
|
|
1445 heinrichs weikamp gmbh
|
|
1446 * @version V0.0.1
|
|
1447 * @date 22-April-2014
|
|
1448 ******************************************************************************
|
|
1449 *
|
|
1450 * @param XleftGimpStyle:
|
|
1451 * @param XrightGimpStyle:
|
|
1452 * @param YtopGimpStyle:
|
|
1453 * @param color:
|
|
1454 * @param tFont:
|
|
1455 * @param text: text to be printed
|
|
1456 * @retval None
|
|
1457 */
|
|
1458
|
|
1459 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)
|
|
1460 {
|
|
1461
|
|
1462 GFX_DrawCfgWindow hgfx;
|
|
1463
|
|
1464 if(XrightGimpStyle > 799)
|
|
1465 XrightGimpStyle = 799;
|
|
1466 if(XleftGimpStyle >= XrightGimpStyle)
|
|
1467 XleftGimpStyle = 0;
|
|
1468 if(YtopGimpStyle > 479)
|
|
1469 YtopGimpStyle = 479;
|
|
1470 hgfx.Image = screenInput;
|
|
1471 hgfx.WindowNumberOfTextLines = 1;
|
|
1472 hgfx.WindowLineSpacing = 0;
|
|
1473 hgfx.WindowTab = 0;
|
|
1474
|
|
1475 hgfx.WindowX0 = XleftGimpStyle;
|
|
1476 hgfx.WindowX1 = XrightGimpStyle;
|
|
1477 hgfx.WindowY1 = 479 - YtopGimpStyle;
|
|
1478 if(hgfx.WindowY1 < Font->height)
|
|
1479 hgfx.WindowY0 = 0;
|
|
1480 else
|
|
1481 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
|
|
1482 GFX_write_label(Font, &hgfx, text, color);
|
|
1483 }
|
|
1484
|
|
1485 /**
|
|
1486 ******************************************************************************
|
|
1487 * @brief GFX write string. / Write string with all parameters and font options
|
|
1488 * @author heinrichs weikamp gmbh
|
|
1489 * @version V0.0.1
|
|
1490 * @date 22-April-2014
|
|
1491 ******************************************************************************
|
|
1492 *
|
|
1493 * @param hgfx: check gfx_engine.h.
|
|
1494 * @param color: 32bit ARGB8888.
|
|
1495 * @retval None
|
|
1496 */
|
|
1497
|
|
1498 uint16_t GFX_return_offset(const tFont *Font, char *pText, uint8_t position)
|
|
1499 {
|
|
1500 char character;
|
|
1501 uint16_t digit, i;
|
|
1502 uint8_t found;
|
|
1503 uint16_t distance;
|
|
1504
|
|
1505 if(position == 0)
|
|
1506 return 0;
|
|
1507
|
|
1508 distance = 0;
|
|
1509 for(digit = 0; digit < position; digit++)
|
|
1510 {
|
|
1511 character = pText[digit];
|
|
1512 if(character == 0)
|
|
1513 return 0;
|
|
1514
|
|
1515 found = 0;
|
|
1516 for(i=0;i<Font->length;i++)
|
|
1517 {
|
|
1518 if(Font->chars[i].code == character)
|
|
1519 {
|
|
1520 found = 1;
|
|
1521 break;
|
|
1522 }
|
|
1523 }
|
|
1524 if(found)
|
|
1525 {
|
|
1526 distance += (uint16_t)(Font->chars[i].image->width);
|
|
1527 if(Font == &FontT105)
|
|
1528 distance += 2;
|
|
1529 }
|
|
1530 }
|
|
1531 return distance;
|
|
1532
|
|
1533 /* FEHLT:
|
|
1534 if(*pText < ' ')
|
|
1535 if((*pText) & 0x80)
|
|
1536
|
|
1537 if(((tFont *)settings.font == &FontT105) && settings.dualFont && ((*pText == '.') || (*pText == ':')))
|
|
1538 settings.font = (uint32_t)&FontT54;
|
|
1539 */
|
|
1540 }
|
|
1541
|
|
1542 void GFX_clean_line(GFX_DrawCfgWindow* hgfx, uint32_t line_number)
|
|
1543 {
|
|
1544 uint16_t height;
|
|
1545 uint32_t pDestination, i, j;
|
|
1546 uint16_t left, width, bottom, nextlineStep;
|
|
1547
|
|
1548 bottom = hgfx->WindowY0;
|
|
1549
|
|
1550 if(hgfx->WindowNumberOfTextLines && line_number && (line_number <= hgfx->WindowNumberOfTextLines))
|
|
1551 {
|
|
1552 bottom += hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number);
|
|
1553 height = hgfx->WindowLineSpacing;
|
|
1554 }
|
|
1555 else
|
|
1556 {
|
|
1557 height = 1 + hgfx->WindowY1 - bottom;
|
|
1558 }
|
|
1559
|
|
1560 pDestination = (uint32_t)hgfx->Image->FBStartAdress;
|
|
1561
|
|
1562 left = hgfx->WindowX0;
|
|
1563 width = 1 + hgfx->WindowX1 - left;
|
|
1564 nextlineStep = hgfx->Image->ImageHeight - height;
|
|
1565 nextlineStep *= 2;
|
|
1566 pDestination += 2 * bottom;
|
|
1567 pDestination += 2 * hgfx->Image->ImageHeight * left;
|
|
1568
|
|
1569 for(j = width; j > 0; j--)
|
|
1570 {
|
|
1571 for(i = height; i > 0; i--)
|
|
1572 {
|
|
1573 *(__IO uint16_t*)pDestination = 0;
|
|
1574 pDestination += 2;
|
|
1575 }
|
|
1576 pDestination += nextlineStep;
|
|
1577 }
|
|
1578 }
|
|
1579
|
|
1580
|
|
1581 void GFX_clean_area(GFX_DrawCfgScreen *tMscreen, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, uint16_t YBottomGimpStyle)
|
|
1582 {
|
|
1583 uint16_t height;
|
|
1584 uint32_t pDestination, i, j;
|
|
1585 int32_t left, width, bottom, nextlineStep;
|
|
1586
|
|
1587 bottom = tMscreen->ImageHeight - YBottomGimpStyle;
|
|
1588 height = 1 + YBottomGimpStyle - YtopGimpStyle;
|
|
1589
|
|
1590 if(bottom < 0)
|
|
1591 bottom = 0;
|
|
1592 if(height > tMscreen->ImageHeight)
|
|
1593 height = tMscreen->ImageHeight;
|
|
1594
|
|
1595 pDestination = tMscreen->FBStartAdress;
|
|
1596
|
|
1597 left = XleftGimpStyle;
|
|
1598 width = 1 + XrightGimpStyle - left;
|
|
1599 if(width < 1)
|
|
1600 width = 1;
|
|
1601
|
|
1602 if(width > tMscreen->ImageWidth)
|
|
1603 width = tMscreen->ImageWidth;
|
|
1604
|
|
1605 nextlineStep = tMscreen->ImageHeight - height;
|
|
1606 nextlineStep *= 2;
|
|
1607 pDestination += 2 * bottom;
|
|
1608 pDestination += 2 * tMscreen->ImageHeight * left;
|
|
1609
|
|
1610 for(j = width; j > 0; j--)
|
|
1611 {
|
|
1612 for(i = height; i > 0; i--)
|
|
1613 {
|
|
1614 *(__IO uint16_t*)pDestination = 0;
|
|
1615 pDestination += 2;
|
|
1616 }
|
|
1617 pDestination += nextlineStep;
|
|
1618 }
|
|
1619 }
|
|
1620
|
|
1621
|
|
1622 uint32_t GFX_write_string(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint32_t line_number)
|
|
1623 {
|
|
1624 return GFX_write_string_color(Font, hgfx, pText, line_number, 0);
|
|
1625 }
|
|
1626
|
|
1627 uint32_t GFX_write_string_color(const tFont *Font, GFX_DrawCfgWindow* hgfx, const char *pText, uint32_t line_number, uint8_t color)
|
|
1628 {
|
|
1629 if(hgfx->Image->FBStartAdress < FBGlobalStart)
|
|
1630 return 0;
|
|
1631
|
|
1632 GFX_CfgWriteString settings;
|
|
1633 uint32_t newXdelta;
|
|
1634 uint8_t minimal = 0;
|
|
1635 // uint32_t try_again;
|
|
1636
|
|
1637 if(hgfx->WindowNumberOfTextLines && line_number && (line_number <= hgfx->WindowNumberOfTextLines))
|
|
1638 {
|
|
1639 settings.Ydelta = hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number);
|
|
1640 }
|
|
1641 else
|
|
1642 {
|
|
1643 settings.Ydelta = 0;
|
|
1644 }
|
|
1645 settings.font = (uint32_t)Font;
|
|
1646 settings.Xdelta = 0;
|
|
1647 settings.color = color;
|
|
1648 settings.invert = 0;
|
|
1649 settings.resize = 0;
|
|
1650 settings.dualFont = 0;
|
|
1651 settings.spaceMode = 0;
|
|
1652 settings.singleSpaceWithSizeOfNextChar = 0;
|
|
1653 settings.useTinyFont = 0;
|
|
1654 settings.TinyFontExtraYdelta = 0;
|
|
1655 settings.TinyFont = (uint32_t)Font;
|
|
1656 settings.doubleSize = 0;
|
|
1657
|
|
1658 if((*pText) == TXT_MINIMAL) // for customtext and anything with Sonderzeichen
|
|
1659 minimal = 1;
|
|
1660 else
|
|
1661 minimal = 0;
|
|
1662
|
|
1663 if(Font == &FontT105)
|
|
1664 settings.TinyFont = (uint32_t)&FontT54;
|
|
1665 else
|
|
1666 if(Font == &FontT54)
|
|
1667 {
|
|
1668 settings.TinyFont = (uint32_t)&FontT48;
|
|
1669 settings.TinyFontExtraYdelta = -9;
|
|
1670 }
|
|
1671 else
|
|
1672 if(Font == &FontT48)
|
|
1673 {
|
|
1674 settings.TinyFont = (uint32_t)&FontT24;
|
|
1675 settings.TinyFontExtraYdelta = 6;
|
|
1676 }
|
|
1677 else
|
|
1678 if(Font == &FontT42)
|
|
1679 {
|
|
1680 settings.TinyFont = (uint32_t)&FontT24;
|
|
1681 settings.TinyFontExtraYdelta = 2;
|
|
1682 }
|
|
1683
|
|
1684 settings.actualFont = (tFont *)settings.font;
|
|
1685
|
|
1686 while ((*pText != 0) && (settings.Xdelta != 0x0000FFFF))// und fehlend: Abfrage window / image size
|
|
1687 {
|
|
1688 // try_again = 0;
|
|
1689
|
|
1690 if((*pText == '\177') && !minimal)
|
|
1691 {
|
|
1692 if(settings.singleSpaceWithSizeOfNextChar)
|
|
1693 {
|
|
1694 settings.singleSpaceWithSizeOfNextChar = 0;
|
|
1695 pText++;
|
|
1696 settings.Xdelta += *pText;
|
|
1697 }
|
|
1698 else
|
|
1699 settings.singleSpaceWithSizeOfNextChar = 1;
|
|
1700 }
|
|
1701 else
|
|
1702 if(*pText < ' ')
|
|
1703 {
|
|
1704 /* Xdelta -inline- changes */
|
|
1705 if((*pText == '\t') && !minimal)
|
|
1706 settings.Xdelta = hgfx->WindowTab - hgfx->WindowX0;
|
|
1707 else
|
|
1708 if(*pText == '\r') // carriage return, no newline
|
|
1709 settings.Xdelta = 0;
|
|
1710 else
|
|
1711 if((*pText == '\001')) // center
|
|
1712 settings.Xdelta = GFX_write__Modify_Xdelta__Centered(&settings, hgfx, pText+1);
|
|
1713 else
|
|
1714 if((*pText == '\002')) // right
|
|
1715 settings.Xdelta = GFX_write__Modify_Xdelta__RightAlign(&settings, hgfx, pText+1);
|
|
1716 else
|
|
1717 if((*pText == '\003') && !minimal) // doubleSize
|
|
1718 settings.doubleSize = 1;
|
|
1719 else
|
|
1720 /* Xdelta -up/down changes */
|
|
1721 if((*pText == '\f') && !minimal) // form feed = top align
|
|
1722 {
|
|
1723 if((hgfx->WindowY1 - hgfx->WindowY0) >= ((tFont *)settings.font)->height)
|
|
1724 {
|
|
1725 settings.Ydelta = hgfx->WindowY1 - hgfx->WindowY0;
|
|
1726 settings.Ydelta -= ((tFont *)settings.font)->height;
|
|
1727 }
|
|
1728 }
|
|
1729 else
|
|
1730 if(*pText == '\n') // newline, no carriage return
|
|
1731 {
|
|
1732 if(hgfx->WindowNumberOfTextLines && (line_number < hgfx->WindowNumberOfTextLines))
|
|
1733 {
|
|
1734 line_number++;
|
|
1735 settings.Ydelta = hgfx->WindowLineSpacing * (hgfx->WindowNumberOfTextLines - line_number);
|
|
1736 }
|
|
1737 }
|
|
1738 else
|
|
1739 /* Font style changes */
|
|
1740 if(*pText == '\a')
|
|
1741 settings.invert = settings.invert ? 0 : 1;
|
|
1742 else
|
|
1743 if((*pText == '\016') && !minimal)
|
|
1744 {
|
|
1745 if(settings.dualFont == 0)
|
|
1746 settings.dualFont = 1;
|
|
1747 else
|
|
1748 settings.actualFont = (tFont *)settings.TinyFont;
|
|
1749 }
|
|
1750 else
|
|
1751 if((*pText == '\017') && !minimal)
|
|
1752 {
|
|
1753 settings.dualFont = 0;
|
|
1754 settings.actualFont = (tFont *)settings.font;
|
|
1755 }
|
|
1756 else
|
|
1757 if((*pText >= '\020') && (*pText <= '\032') && !minimal)
|
|
1758 settings.color = *pText - '\020';
|
|
1759 else
|
|
1760 if((*pText == '\034') && !minimal)
|
|
1761 settings.spaceMode = 1;
|
|
1762 else
|
|
1763 if((*pText == '\035') && !minimal)
|
|
1764 settings.spaceMode = 0;
|
|
1765 }
|
|
1766 else
|
|
1767 if(((*pText) == TXT_2BYTE) && !minimal)
|
|
1768 {
|
|
1769 pText++;
|
|
1770 settings.Xdelta = GFX_write_substring(&settings, hgfx, (uint8_t)TXT_2BYTE, (int8_t)*pText);
|
|
1771 }
|
|
1772 else
|
|
1773 if(((*pText) & 0x80) && !minimal)
|
|
1774 settings.Xdelta = GFX_write_substring(&settings, hgfx, (uint8_t)*pText, 0);
|
|
1775 else
|
|
1776 if(!settings.invert && (*pText == ' '))
|
|
1777 {
|
|
1778 if(settings.spaceMode == 0)
|
|
1779 settings.Xdelta += ((tFont *)settings.font)->spacesize;
|
|
1780 else
|
|
1781 settings.Xdelta += ((tFont *)settings.font)->spacesize2Monospaced;
|
|
1782 }
|
|
1783 else
|
|
1784 if((settings.spaceMode == 1) && (*pText == ' '))
|
|
1785 settings.Xdelta += ((tFont *)settings.font)->spacesize2Monospaced;
|
|
1786 else
|
|
1787 {
|
|
1788 if(((tFont *)settings.font == &FontT105) && settings.dualFont && ((*pText == '.') || (*pText == ':')))
|
|
1789 settings.actualFont = (tFont *)settings.TinyFont;
|
|
1790
|
|
1791 if(settings.actualFont == (tFont *)settings.TinyFont)
|
|
1792 settings.Ydelta += settings.TinyFontExtraYdelta;
|
|
1793
|
|
1794 newXdelta = GFX_write_char(hgfx, &settings, *(uint8_t *)pText, settings.actualFont);
|
|
1795 settings.Xdelta = newXdelta;
|
|
1796
|
|
1797 if(settings.actualFont == (tFont *)settings.TinyFont)
|
|
1798 settings.Ydelta -= settings.TinyFontExtraYdelta;
|
|
1799 }
|
|
1800 if(pText != 0) /* for TXT_2BYTE */
|
|
1801 pText++;
|
|
1802 }
|
|
1803 return settings.Ydelta;
|
|
1804 }
|
|
1805
|
|
1806 /* Private functions ---------------------------------------------------------*/
|
|
1807 /******************************************************************************
|
|
1808 Static Function
|
|
1809 *******************************************************************************/
|
|
1810
|
|
1811 /**
|
|
1812 ******************************************************************************
|
|
1813 * @brief GFX write substring. / Write string without parameters
|
|
1814 * @author heinrichs weikamp gmbh
|
|
1815 * @version V0.0.1
|
|
1816 * @date 22-April-2014
|
|
1817 ******************************************************************************
|
|
1818 *
|
|
1819 * @param hgfx: check gfx_engine.h.
|
|
1820 * @param color: 32bit ARGB8888.
|
|
1821 * @retval None
|
|
1822 */
|
|
1823
|
|
1824 static uint32_t GFX_write_substring(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, uint8_t textId, int8_t nextCharFor2Byte)
|
|
1825 {
|
|
1826 uint8_t i, j;
|
|
1827 uint32_t found;
|
|
1828 uint32_t pText;
|
|
1829 uint16_t decodeUTF8;
|
|
1830
|
|
1831 // -----------------------------
|
|
1832 if(textId != (uint8_t)TXT_2BYTE)
|
|
1833 {
|
|
1834 found = 0;
|
|
1835 j = 0;
|
|
1836 for(i=(uint8_t)TXT_Language;i<(uint8_t)TXT_END;i++)
|
|
1837 {
|
|
1838 j++;
|
|
1839 }
|
|
1840 if(!found)
|
|
1841 return cfg->Xdelta;
|
|
1842
|
|
1843 }
|
|
1844 // -----------------------------
|
|
1845 else
|
|
1846 {
|
|
1847 if(!nextCharFor2Byte)
|
|
1848 return cfg->Xdelta;
|
|
1849
|
|
1850 found = 0;
|
|
1851
|
|
1852 if(!found)
|
|
1853 return cfg->Xdelta;
|
|
1854 }
|
|
1855 // -----------------------------
|
|
1856
|
|
1857 if(cfg->actualFont == (tFont *)cfg->TinyFont)
|
|
1858 cfg->Ydelta += cfg->TinyFontExtraYdelta;
|
|
1859
|
|
1860 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size
|
|
1861 {
|
|
1862 if(*(char*)pText == '\t')
|
|
1863 cfg->Xdelta = hgfx->WindowTab - hgfx->WindowX0;
|
|
1864 else
|
|
1865 if((*(char*)pText == ' ') && (cfg->invert == 0)) /* bypass drawing of white space only for not inverted mode */
|
|
1866 {
|
|
1867 cfg->Xdelta += ((tFont *)cfg->actualFont)->spacesize;
|
|
1868 }
|
|
1869 else
|
|
1870 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */
|
|
1871 {
|
|
1872 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */
|
|
1873 pText++;
|
|
1874 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */
|
|
1875 if (decodeUTF8 <= 0xff) /* The following function has a uint8 input parameter ==> no UNICODEs > 0xff supported */
|
|
1876 {
|
|
1877 cfg->Xdelta = GFX_write_char(hgfx, cfg, (uint8_t)decodeUTF8, (tFont *)cfg->actualFont);
|
|
1878 }
|
|
1879 }
|
|
1880 else
|
|
1881 cfg->Xdelta = GFX_write_char(hgfx, cfg, *(uint8_t *)pText, (tFont *)cfg->actualFont);
|
|
1882
|
|
1883 pText++;
|
|
1884 }
|
|
1885
|
|
1886 if(cfg->actualFont == (tFont *)cfg->TinyFont)
|
|
1887 cfg->Ydelta -= cfg->TinyFontExtraYdelta;
|
|
1888
|
|
1889 return cfg->Xdelta;
|
|
1890 }
|
|
1891
|
|
1892
|
|
1893 /**
|
|
1894 ******************************************************************************
|
|
1895 * @brief GFX write char. / Write non-inverted, non-colored with entire 8 bit range
|
|
1896 * @author heinrichs weikamp gmbh
|
|
1897 * @version V0.0.1
|
|
1898 * @date 22-April-2014
|
|
1899 ******************************************************************************
|
|
1900 *
|
|
1901 * @param hgfx: check gfx_engine.h.
|
|
1902 * @param Ydelta: input
|
|
1903 * @param character: character
|
|
1904 * @param *Font: pointer to font to be used for this char
|
|
1905 * @retval Ydelta: 0x0000FFFF if not successful or char_truncated
|
|
1906 */
|
|
1907
|
|
1908 static uint32_t GFX_write_char_doubleSize(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font)
|
|
1909 {
|
|
1910 uint32_t i, j;
|
|
1911 uint32_t width, height;
|
|
1912 uint32_t found;
|
|
1913 uint16_t* pDestination;
|
|
1914 uint32_t pSource;
|
|
1915 uint32_t OffsetDestination;
|
|
1916 uint32_t width_left;
|
|
1917 uint32_t height_left;
|
|
1918 uint32_t char_truncated_WidthFlag;
|
|
1919 uint32_t char_truncated_Height;
|
|
1920 uint8_t fill;
|
|
1921 uint32_t widthFont, heightFont;
|
|
1922 uint32_t nextLine;
|
|
1923 int32_t stepdir;
|
|
1924
|
|
1925 stepdir = 1;
|
|
1926
|
|
1927 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta))
|
|
1928 return 0x0000FFFF;
|
|
1929
|
|
1930 // -----------------------------
|
|
1931 found = 0;
|
|
1932 for(i=0;i<Font->length;i++)
|
|
1933 {
|
|
1934 if(Font->chars[i].code == character)
|
|
1935 {
|
|
1936 found = 1;
|
|
1937 break;
|
|
1938 }
|
|
1939 }
|
|
1940 if(!found)
|
|
1941 return cfg->Xdelta;
|
|
1942
|
|
1943 pSource = ((uint32_t)Font->chars[i].image->data);
|
|
1944 pDestination = (uint16_t*)(hgfx->Image->FBStartAdress);
|
|
1945
|
|
1946 heightFont = Font->chars[i].image->height;
|
|
1947 widthFont = Font->chars[i].image->width;
|
|
1948
|
|
1949 height = heightFont*2;
|
|
1950 width = widthFont*2;
|
|
1951
|
|
1952
|
|
1953 pDestination += (uint32_t)(hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */
|
|
1954 pDestination += (hgfx->WindowY0 + cfg->Ydelta); /* set pointer to delta colum */
|
|
1955
|
|
1956 OffsetDestination = (hgfx->Image->ImageHeight - height);
|
|
1957 nextLine = hgfx->Image->ImageHeight;
|
|
1958
|
|
1959 // -----------------------------
|
|
1960 char_truncated_WidthFlag = 0;
|
|
1961 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta);
|
|
1962 if(width_left < width)
|
|
1963 {
|
|
1964 char_truncated_WidthFlag = 1;
|
|
1965 width = width_left;
|
|
1966 widthFont = width/2;
|
|
1967 }
|
|
1968 // -----------------------------
|
|
1969
|
|
1970 char_truncated_Height = 0;
|
|
1971 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta);
|
|
1972 if(height_left < height)
|
|
1973 {
|
|
1974 char_truncated_Height = height - height_left;
|
|
1975 if((char_truncated_Height & 1) != 0)
|
|
1976 {
|
|
1977 height_left -= 1;
|
|
1978 char_truncated_Height += 1;
|
|
1979 }
|
|
1980 height = height_left;
|
|
1981 heightFont = height/2;
|
|
1982 }
|
|
1983
|
|
1984 OffsetDestination += char_truncated_Height;
|
|
1985 // -----------------------------
|
|
1986 if(height == 0)
|
|
1987 return 0x0000FFFF;
|
|
1988 // -----------------------------
|
|
1989
|
|
1990 if(cfg->singleSpaceWithSizeOfNextChar)
|
|
1991 {
|
|
1992 cfg->singleSpaceWithSizeOfNextChar = 0;
|
|
1993
|
|
1994 if(cfg->invert)
|
|
1995 fill = 0xFF;
|
|
1996 else
|
|
1997 fill = 0;
|
|
1998
|
|
1999 height /= 2;
|
|
2000 for(i = width; i > 0; i--)
|
|
2001 {
|
|
2002 for (j = height; j > 0; j--)
|
|
2003 {
|
|
2004 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color;
|
|
2005 pDestination += stepdir;
|
|
2006 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color;
|
|
2007 pDestination += stepdir;
|
|
2008 }
|
|
2009 pDestination += stepdir * OffsetDestination;
|
|
2010 }
|
|
2011 }
|
|
2012 else
|
|
2013 if(cfg->invert)
|
|
2014 {
|
|
2015 if((heightFont & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
|
|
2016 {
|
|
2017 heightFont /= 4;
|
|
2018 for(i = widthFont; i > 0; i--)
|
|
2019 {
|
|
2020 if(*(uint8_t*)pSource != 0x01)
|
|
2021 {
|
|
2022 for (j = heightFont; j > 0; j--)
|
|
2023 {
|
|
2024 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2025 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2026 pDestination += stepdir;
|
|
2027 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2028 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2029 pDestination += stepdir;
|
|
2030 pSource++;
|
|
2031
|
|
2032 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2033 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2034 pDestination += stepdir;
|
|
2035 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2036 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2037 pDestination += stepdir;
|
|
2038 pSource++;
|
|
2039
|
|
2040 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2041 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2042 pDestination += stepdir;
|
|
2043 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2044 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2045 pDestination += stepdir;
|
|
2046 pSource++;
|
|
2047
|
|
2048 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2049 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2050 pDestination += stepdir;
|
|
2051 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2052 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2053 pDestination += stepdir;
|
|
2054 pSource++;
|
|
2055 }
|
|
2056 pSource += char_truncated_Height;
|
|
2057 }
|
|
2058 else
|
|
2059 {
|
|
2060 pSource++;
|
|
2061 for (j = heightFont; j > 0; j--)
|
|
2062 {
|
|
2063 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2064 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2065 pDestination += stepdir;
|
|
2066 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2067 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2068 pDestination += stepdir;
|
|
2069 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2070 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2071 pDestination += stepdir;
|
|
2072 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2073 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2074 pDestination += stepdir;
|
|
2075 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2076 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2077 pDestination += stepdir;
|
|
2078 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2079 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2080 pDestination += stepdir;
|
|
2081 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2082 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2083 pDestination += stepdir;
|
|
2084 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2085 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2086 pDestination += stepdir;
|
|
2087 }
|
|
2088 }
|
|
2089 pDestination += (OffsetDestination + nextLine) * stepdir;
|
|
2090 }
|
|
2091 }
|
|
2092 else
|
|
2093 {
|
|
2094 heightFont /= 2;
|
|
2095 for(i = widthFont; i > 0; i--)
|
|
2096 {
|
|
2097 if(*(uint8_t*)pSource != 0x01)
|
|
2098 {
|
|
2099 for (j = heightFont; j > 0; j--)
|
|
2100 {
|
|
2101 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2102 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2103 pDestination += stepdir;
|
|
2104 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2105 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2106 pDestination += stepdir;
|
|
2107 pSource++;
|
|
2108
|
|
2109 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2110 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2111 pDestination += stepdir;
|
|
2112 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2113 *(__IO uint16_t*)(pDestination + nextLine) = (0xFF - *(uint8_t*)pSource) << 8 | cfg->color;
|
|
2114 pDestination += stepdir;
|
|
2115 pSource++;
|
|
2116 }
|
|
2117 pSource += char_truncated_Height;
|
|
2118 }
|
|
2119 else
|
|
2120 {
|
|
2121 pSource++;
|
|
2122 for (j = heightFont; j > 0; j--)
|
|
2123 {
|
|
2124 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2125 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2126 pDestination += stepdir;
|
|
2127 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2128 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2129 pDestination += stepdir;
|
|
2130 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2131 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2132 pDestination += stepdir;
|
|
2133 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2134 *(__IO uint16_t*)(pDestination + nextLine) = 0xFF << 8 | cfg->color;
|
|
2135 pDestination += stepdir;
|
|
2136 }
|
|
2137 }
|
|
2138 pDestination += (OffsetDestination + nextLine) * stepdir;
|
|
2139 }
|
|
2140 }
|
|
2141 } /* inverted */
|
|
2142 else
|
|
2143 {
|
|
2144 if((heightFont & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
|
|
2145 {
|
|
2146 heightFont /= 4;
|
|
2147 for(i = widthFont; i > 0; i--)
|
|
2148 {
|
|
2149 if(*(uint8_t*)pSource != 0x01)
|
|
2150 {
|
|
2151 for (j = heightFont; j > 0; j--)
|
|
2152 {
|
|
2153 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2154 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2155 pDestination += stepdir;
|
|
2156 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2157 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2158 pDestination += stepdir;
|
|
2159 pSource++;
|
|
2160
|
|
2161 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2162 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2163 pDestination += stepdir;
|
|
2164 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2165 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2166 pDestination += stepdir;
|
|
2167 pSource++;
|
|
2168
|
|
2169 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2170 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2171 pDestination += stepdir;
|
|
2172 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2173 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2174 pDestination += stepdir;
|
|
2175 pSource++;
|
|
2176
|
|
2177 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2178 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2179 pDestination += stepdir;
|
|
2180 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2181 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2182 pDestination += stepdir;
|
|
2183 pSource++;
|
|
2184 }
|
|
2185 pSource += char_truncated_Height;
|
|
2186 }
|
|
2187 else
|
|
2188 {
|
|
2189 pSource++;
|
|
2190 pDestination += stepdir * height;
|
|
2191 }
|
|
2192 pDestination += stepdir * (OffsetDestination + nextLine);
|
|
2193 }
|
|
2194 }
|
|
2195 else
|
|
2196 {
|
|
2197 heightFont /= 2;
|
|
2198 for(i = widthFont; i > 0; i--)
|
|
2199 {
|
|
2200 if(*(uint8_t*)pSource != 0x01)
|
|
2201 {
|
|
2202 for (j = heightFont; j > 0; j--)
|
|
2203 {
|
|
2204 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2205 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2206 pDestination += stepdir;
|
|
2207 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2208 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2209 pDestination += stepdir;
|
|
2210 pSource++;
|
|
2211
|
|
2212 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2213 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2214 pDestination += stepdir;
|
|
2215 *(__IO uint16_t*)pDestination = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2216 *(__IO uint16_t*)(pDestination + (stepdir * nextLine)) = *(uint8_t*)pSource << 8 | cfg->color;
|
|
2217 pDestination += stepdir;
|
|
2218 pSource++;
|
|
2219 }
|
|
2220 pSource += char_truncated_Height;
|
|
2221 }
|
|
2222 else
|
|
2223 {
|
|
2224 pSource++;
|
|
2225 pDestination += stepdir * height;
|
|
2226 }
|
|
2227 pDestination += stepdir * (OffsetDestination + nextLine);
|
|
2228 }
|
|
2229 }
|
|
2230 }
|
|
2231
|
|
2232 // -----------------------------
|
|
2233
|
|
2234 if(Font == &FontT105)
|
|
2235 width += 4;
|
|
2236
|
|
2237 // -----------------------------
|
|
2238
|
|
2239 if(char_truncated_WidthFlag)
|
|
2240 return 0x0000FFFF;
|
|
2241 else
|
|
2242 return cfg->Xdelta + width;
|
|
2243
|
|
2244 }
|
|
2245
|
|
2246
|
|
2247 /**
|
|
2248 ******************************************************************************
|
|
2249 * @brief GFX write char. / Write non-inverted, non-colored with entire 8 bit range
|
|
2250 * @author heinrichs weikamp gmbh
|
|
2251 * @version V0.0.1
|
|
2252 * @date 22-April-2014
|
|
2253 ******************************************************************************
|
|
2254 *
|
|
2255 * @param hgfx: check gfx_engine.h.
|
|
2256 * @param Ydelta: input
|
|
2257 * @param character: character
|
|
2258 * @param *Font: pointer to font to be used for this char
|
|
2259 * @retval Ydelta: 0x0000FFFF if not successful or char_truncated
|
|
2260 */
|
|
2261
|
|
2262 static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font)
|
|
2263 {
|
|
2264 if(cfg->doubleSize)
|
|
2265 {
|
|
2266 return GFX_write_char_doubleSize(hgfx, cfg, character, Font);
|
|
2267 }
|
|
2268
|
|
2269 uint32_t i, j;
|
|
2270 uint32_t width, height;
|
|
2271 uint32_t found;
|
|
2272 uint16_t* pDestination;
|
|
2273 uint32_t pSource;
|
|
2274 uint32_t OffsetDestination;
|
|
2275 uint32_t width_left;
|
|
2276 uint32_t height_left;
|
|
2277 uint32_t char_truncated_WidthFlag;
|
|
2278 uint32_t char_truncated_Height;
|
|
2279 uint8_t fill;
|
|
2280 uint32_t fillpattern;
|
|
2281 int16_t stepdir;
|
|
2282
|
|
2283 stepdir = 1;
|
|
2284
|
|
2285 if(hgfx->Image->ImageWidth <= (hgfx->WindowX0 + cfg->Xdelta))
|
|
2286 return 0x0000FFFF;
|
|
2287
|
|
2288 // -----------------------------
|
|
2289 found = 0;
|
|
2290 for(i=0;i<Font->length;i++)
|
|
2291 {
|
|
2292 if(Font->chars[i].code == character)
|
|
2293 {
|
|
2294 found = 1;
|
|
2295 break;
|
|
2296 }
|
|
2297 }
|
|
2298 if(!found)
|
|
2299 return cfg->Xdelta;
|
|
2300 // -----------------------------
|
|
2301 /*
|
|
2302 if(Font == &Font144)
|
|
2303 cfg->Xdelta += 3;
|
|
2304 else
|
|
2305 if(Font == &Font84)
|
|
2306 cfg->Xdelta += 2;
|
|
2307 */
|
|
2308 // -----------------------------
|
|
2309
|
|
2310
|
|
2311 pSource = ((uint32_t)Font->chars[i].image->data);
|
|
2312 pDestination = (uint16_t*)(hgfx->Image->FBStartAdress);
|
|
2313
|
|
2314
|
|
2315 height = Font->chars[i].image->height;
|
|
2316 width = Font->chars[i].image->width;
|
|
2317
|
|
2318 OffsetDestination = hgfx->Image->ImageHeight - height;
|
|
2319
|
|
2320
|
|
2321 /* Xyyyyy y= height */
|
|
2322 /* Xyyyyy x= width */
|
|
2323 /* Xyyyyy */
|
|
2324
|
|
2325 pDestination += (hgfx->WindowX0 + cfg->Xdelta) * hgfx->Image->ImageHeight; /* set pointer to delta row */
|
|
2326 pDestination += (hgfx->WindowY0 + cfg->Ydelta); /* set pointer to delta colum */
|
|
2327
|
|
2328 // -----------------------------
|
|
2329 char_truncated_WidthFlag = 0;
|
|
2330 width_left = hgfx->Image->ImageWidth - (hgfx->WindowX0 + cfg->Xdelta);
|
|
2331 if(width_left < width)
|
|
2332 {
|
|
2333 char_truncated_WidthFlag = 1;
|
|
2334 width = width_left;
|
|
2335 }
|
|
2336 // -----------------------------
|
|
2337 char_truncated_Height = 0;
|
|
2338 height_left = hgfx->Image->ImageHeight - (hgfx->WindowY0 + cfg->Ydelta);
|
|
2339 if(height_left < height)
|
|
2340 {
|
|
2341 char_truncated_Height = height - height_left;
|
|
2342 if((char_truncated_Height & 1) != 0)
|
|
2343 {
|
|
2344 height_left -= 1;
|
|
2345 char_truncated_Height += 1;
|
|
2346 }
|
|
2347 height = height_left;
|
|
2348 }
|
|
2349 OffsetDestination += char_truncated_Height;
|
|
2350 // -----------------------------
|
|
2351 if(height == 0)
|
|
2352 return 0x0000FFFF;
|
|
2353 // -----------------------------
|
|
2354
|
|
2355 if(cfg->singleSpaceWithSizeOfNextChar)
|
|
2356 {
|
|
2357 cfg->singleSpaceWithSizeOfNextChar = 0;
|
|
2358
|
|
2359 if(cfg->invert)
|
|
2360 fill = 0xFF;
|
|
2361 else
|
|
2362 fill = 0;
|
|
2363
|
|
2364 height /= 2;
|
|
2365 for(i = width; i > 0; i--)
|
|
2366 {
|
|
2367 for (j = height; j > 0; j--)
|
|
2368 {
|
|
2369 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color;
|
|
2370 pDestination += stepdir;
|
|
2371 *(__IO uint16_t*)pDestination = fill << 8 | cfg->color;
|
|
2372 pDestination += stepdir;
|
|
2373 }
|
|
2374 pDestination += stepdir * OffsetDestination;
|
|
2375 }
|
|
2376 }
|
|
2377 else
|
|
2378 if(cfg->invert)
|
|
2379 {
|
|
2380 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
|
|
2381 {
|
|
2382 height /= 4;
|
|
2383 for(i = width; i > 0; i--)
|
|
2384 {
|
|
2385 if(*(uint8_t*)pSource != 0x01)
|
|
2386 {
|
|
2387
|
|
2388 for (j = height; j > 0; j--)
|
|
2389 {
|
|
2390 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color;
|
|
2391 pDestination += stepdir;
|
|
2392 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color;
|
|
2393 pDestination += stepdir;
|
|
2394 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color;
|
|
2395 pDestination += stepdir;
|
|
2396 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color;
|
|
2397 pDestination += stepdir;
|
|
2398 }
|
|
2399 pSource += char_truncated_Height;
|
|
2400 }
|
|
2401 else /* empty line => fast fill */
|
|
2402 {
|
|
2403 pSource++;
|
|
2404 fillpattern = (( 0xFF << 8 | cfg->color) << 16) | ( 0xFF << 8 | cfg->color);
|
|
2405 for (j = height; j > 0; j--)
|
|
2406 {
|
|
2407 *(__IO uint32_t*)pDestination = fillpattern;
|
|
2408 pDestination += stepdir;
|
|
2409 pDestination += stepdir;
|
|
2410 *(__IO uint32_t*)pDestination = fillpattern;
|
|
2411 pDestination += stepdir;
|
|
2412 pDestination += stepdir;
|
|
2413 }
|
|
2414 }
|
|
2415 pDestination += stepdir * OffsetDestination;
|
|
2416 }
|
|
2417 }
|
|
2418 else
|
|
2419 {
|
|
2420 height /= 2;
|
|
2421 for(i = width; i > 0; i--)
|
|
2422 {
|
|
2423 if(*(uint8_t*)pSource != 0x01)
|
|
2424 {
|
|
2425 for (j = height; j > 0; j--)
|
|
2426 {
|
|
2427 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color;
|
|
2428 pDestination += stepdir;
|
|
2429 *(__IO uint16_t*)pDestination = (0xFF - *(uint8_t*)pSource++) << 8 | cfg->color;
|
|
2430 pDestination += stepdir;
|
|
2431 }
|
|
2432 pSource += char_truncated_Height;
|
|
2433 }
|
|
2434 else
|
|
2435 {
|
|
2436 pSource++;
|
|
2437 for (j = height; j > 0; j--)
|
|
2438 {
|
|
2439 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2440 pDestination += stepdir;
|
|
2441 *(__IO uint16_t*)pDestination = 0xFF << 8 | cfg->color;
|
|
2442 pDestination += stepdir;
|
|
2443 }
|
|
2444 }
|
|
2445 pDestination += stepdir * OffsetDestination;
|
|
2446 }
|
|
2447 }
|
|
2448 }
|
|
2449 else /* not inverted */
|
|
2450 {
|
|
2451 if((height & 3) == 0) /* unroll for perfomance, by 4 if possible, by 2 (16bit) otherwise */
|
|
2452 {
|
|
2453
|
|
2454 height /= 4;
|
|
2455
|
|
2456 for(i = width; i > 0; i--)
|
|
2457 {
|
|
2458 if(*(uint8_t*)pSource != 0x01)
|
|
2459 {
|
|
2460 for (j = height; j > 0; j--)
|
|
2461 {
|
|
2462 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color);
|
|
2463 pDestination += stepdir;
|
|
2464 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color);
|
|
2465 pDestination += stepdir;
|
|
2466 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color);
|
|
2467 pDestination += stepdir;
|
|
2468 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color);
|
|
2469 pDestination += stepdir;
|
|
2470 }
|
|
2471
|
|
2472 pSource += char_truncated_Height;
|
|
2473 }
|
|
2474 else /* clear line */
|
|
2475 {
|
|
2476 pSource++;
|
|
2477 fillpattern = (cfg->color << 16) | cfg->color;
|
|
2478
|
|
2479 for (j = height; j > 0; j--)
|
|
2480 {
|
|
2481 *(__IO uint32_t*)pDestination = fillpattern;
|
|
2482 pDestination += stepdir;
|
|
2483 pDestination += stepdir;
|
|
2484 *(__IO uint32_t*)pDestination = fillpattern;
|
|
2485 pDestination += stepdir;
|
|
2486 pDestination += stepdir;
|
|
2487 }
|
|
2488 }
|
|
2489 pDestination += stepdir * OffsetDestination;
|
|
2490 }
|
|
2491 }
|
|
2492 else
|
|
2493 {
|
|
2494 height /= 2;
|
|
2495 for(i = width; i > 0; i--)
|
|
2496 {
|
|
2497 if(*(uint8_t*)pSource != 0x01)
|
|
2498 {
|
|
2499 for (j = height; j > 0; j--)
|
|
2500 {
|
|
2501 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color);
|
|
2502 pDestination += stepdir;
|
|
2503 *(__IO uint16_t*)pDestination = ( *(uint8_t*)pSource++ << 8) | (cfg->color);
|
|
2504 pDestination += stepdir;
|
|
2505 }
|
|
2506 pSource += char_truncated_Height;
|
|
2507 }
|
|
2508 else /* clear line */
|
|
2509 {
|
|
2510 pSource++;
|
|
2511 for (j = height; j > 0; j--)
|
|
2512 {
|
|
2513 *(__IO uint16_t*)pDestination = cfg->color;
|
|
2514 pDestination += stepdir;
|
|
2515 *(__IO uint16_t*)pDestination = cfg->color;
|
|
2516 pDestination += stepdir;
|
|
2517 }
|
|
2518 }
|
|
2519 pDestination += stepdir * OffsetDestination;
|
|
2520 }
|
|
2521 }
|
|
2522 }
|
|
2523
|
|
2524 // -----------------------------
|
|
2525 if(Font == &FontT105)
|
|
2526 width += 2;
|
|
2527 /*
|
|
2528 else
|
|
2529 if(Font == &Font144)
|
|
2530 width += 3;
|
|
2531 else
|
|
2532 if(Font == &Font84)
|
|
2533 width += 1;
|
|
2534 */
|
|
2535 // -----------------------------
|
|
2536
|
|
2537 if(char_truncated_WidthFlag)
|
|
2538 return 0x0000FFFF;
|
|
2539 else
|
|
2540 return cfg->Xdelta + width;
|
|
2541 }
|
|
2542
|
|
2543 /**
|
|
2544 ******************************************************************************
|
|
2545 * @brief GFX write Modify Ydelta for align. / calc Ydelta for start
|
|
2546 * @author heinrichs weikamp gmbh
|
|
2547 * @version V0.0.1
|
|
2548 * @date 22-April-2014
|
|
2549 ******************************************************************************
|
|
2550 *
|
|
2551 * @param *hgfx: check gfx_engine.h.
|
|
2552 * @param *cfg: Ydelta, Font
|
|
2553 * @param *pText: character
|
|
2554 * @retval Ydelta: 0 if text has to start left ( and probably does not fit)
|
|
2555 */
|
|
2556
|
|
2557 static uint32_t GFX_write__Modify_Xdelta__Centered(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput)
|
|
2558 {
|
|
2559 char cText[101];
|
|
2560 uint32_t result;
|
|
2561 uint32_t Xsum;
|
|
2562 uint32_t j;
|
|
2563 uint32_t pText;
|
|
2564 uint16_t decodeUTF8;
|
|
2565 uint8_t tinyState = 0; /* used to identify the usage of tiny font */
|
|
2566 tFont* ptargetFont;
|
|
2567
|
|
2568 pText = (uint32_t)&cText[0];
|
|
2569 Xsum = 0;
|
|
2570 j = 0;
|
|
2571 ptargetFont = (tFont *)cfg->font;
|
|
2572 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size
|
|
2573 {
|
|
2574 if(*(char*)pText == '\016') /* request font change */
|
|
2575 {
|
|
2576 tinyState++;
|
|
2577 }
|
|
2578 if(*(char*)pText == '\017') /* request font reset */
|
|
2579 {
|
|
2580 tinyState = 0;
|
|
2581 }
|
|
2582
|
|
2583 if((ptargetFont == &FontT105) && ((*(char*)pText == '.') || (*(char*)pText == ':')))
|
|
2584 {
|
|
2585 tinyState++;
|
|
2586 }
|
|
2587
|
|
2588 if(tinyState > 1)
|
|
2589 {
|
|
2590 ptargetFont = (tFont *)cfg->TinyFont;
|
|
2591 }
|
|
2592 else
|
|
2593 {
|
|
2594 ptargetFont = (tFont *)cfg->font;
|
|
2595 }
|
|
2596
|
|
2597 decodeUTF8 = *(char*)pText; /* place ASCII char */
|
|
2598 if((*(char*)pText == '\005') || (*(char*)pText == '\006'))
|
|
2599 {
|
|
2600 Xsum += 45;
|
|
2601 }
|
|
2602 else
|
|
2603 {
|
|
2604 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */
|
|
2605 {
|
|
2606 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */
|
|
2607 pText++;
|
|
2608 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */
|
|
2609 }
|
|
2610 else
|
|
2611 {
|
|
2612 decodeUTF8 = *(char*)pText; /* place ASCII char */
|
|
2613 }
|
|
2614 Xsum += GFX_Character_Width(decodeUTF8, ptargetFont);
|
|
2615 }
|
|
2616
|
|
2617 pText++;
|
|
2618 j++;
|
|
2619 if((ptargetFont == &FontT105) && (*(char*)pText != 0))
|
|
2620 Xsum += 2;
|
|
2621 }
|
|
2622 pText -= j;
|
|
2623
|
|
2624 if(cfg->doubleSize)
|
|
2625 Xsum *= 2;
|
|
2626
|
|
2627 result = hgfx->WindowX1 - hgfx->WindowX0;
|
|
2628 if(Xsum < result)
|
|
2629 {
|
|
2630 result -= Xsum;
|
|
2631 result /= 2;
|
|
2632 }
|
|
2633 else
|
|
2634 result = 0;
|
|
2635 return result;
|
|
2636 }
|
|
2637
|
|
2638
|
|
2639 static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput)
|
|
2640 {
|
|
2641 uint32_t result;
|
|
2642 uint32_t Xsum;
|
|
2643 uint32_t j;
|
|
2644 tFont *font;
|
|
2645 char cText[101];
|
|
2646 uint32_t pText;
|
|
2647 uint16_t decodeUTF8;
|
|
2648 uint8_t tinyState = 0; /* used to identify the usage of tiny font */
|
|
2649
|
|
2650 cText[0] = 0;
|
|
2651
|
|
2652 // -----------------------------
|
|
2653 pText = (uint32_t)&cText[0];
|
|
2654 // -----------------------------
|
|
2655
|
|
2656 font = (tFont *)cfg->font;
|
|
2657 Xsum = 0;
|
|
2658 j = 0;
|
|
2659
|
|
2660 while (*(char*)pText != 0)// und fehlend: Abfrage window / image size
|
|
2661 {
|
|
2662 if(*(char*)pText == '\016') /* request font change */
|
|
2663 {
|
|
2664 tinyState++;
|
|
2665 }
|
|
2666 if(*(char*)pText == '\017') /* request font reset */
|
|
2667 {
|
|
2668 tinyState = 0;
|
|
2669 }
|
|
2670
|
|
2671 if((font == &FontT105) && ((*(char*)pText == '.') || (*(char*)pText == ':')))
|
|
2672 {
|
|
2673 tinyState++;
|
|
2674 }
|
|
2675
|
|
2676 if(tinyState > 1)
|
|
2677 {
|
|
2678 font = (tFont *)cfg->TinyFont;
|
|
2679 }
|
|
2680 else
|
|
2681 {
|
|
2682 font = (tFont *)cfg->font;
|
|
2683 }
|
|
2684
|
|
2685 if(*(char*)pText == ' ')
|
|
2686 {
|
|
2687 Xsum += font->spacesize;
|
|
2688 }
|
|
2689 else
|
|
2690 if((*(char*)pText == '\005') || (*(char*)pText == '\006'))
|
|
2691 {
|
|
2692 Xsum += 45;
|
|
2693 }
|
|
2694 else
|
|
2695 {
|
|
2696 if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */
|
|
2697 {
|
|
2698 decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */
|
|
2699 pText++;
|
|
2700 decodeUTF8 |= (*(char*)pText) & 0x3F; /* add lower 6bits as second part of the unicode */
|
|
2701 }
|
|
2702 else
|
|
2703 {
|
|
2704 decodeUTF8 = *(char*)pText;
|
|
2705 }
|
|
2706 Xsum += GFX_Character_Width(decodeUTF8, font); /* lookup character and add width */
|
|
2707 }
|
|
2708 pText++;
|
|
2709 j++;
|
987
45a2bd04b156
Removed Font144 references because Font cause a linker problem and is not used by Bootloader
Ideenmodellierer
diff
changeset
|
2710
|
985
|
2711 if((font == &FontT105) && (*(char*)pText != 0))
|
|
2712 Xsum += 2;
|
|
2713 }
|
|
2714 pText -= j;
|
|
2715
|
|
2716 if(cfg->doubleSize)
|
|
2717 Xsum *= 2;
|
|
2718
|
|
2719 result = hgfx->WindowX1 - hgfx->WindowX0 - 1;
|
|
2720 if(Xsum < result)
|
|
2721 result -= Xsum;
|
|
2722 else
|
|
2723 result = 0;
|
|
2724
|
|
2725 return result;
|
|
2726 }
|
|
2727
|
|
2728 void GFX_LTDC_Init(void)
|
|
2729 {
|
|
2730 GFX_LTDC_Init_display1();
|
|
2731 }
|
|
2732
|
|
2733 void GFX_LTDC_Init_display1(void)
|
|
2734 {
|
|
2735 /* Timing configuration */
|
|
2736 #define ActiveH_d1 800
|
|
2737 #define ActiveW_d1 480
|
|
2738
|
|
2739 #define Hsync_d1 2
|
|
2740 #define HFP_d1 8
|
|
2741 #define HBP_d1 8
|
|
2742
|
|
2743 #define Vsync_d1 2
|
|
2744 #define VFP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VFP_SET
|
|
2745 #define VBP_d1 4 // make sure this value * VSYNC is also set in display.c for OLED_VBP_SET
|
|
2746
|
|
2747 /* Horizontal synchronization width = Hsync - 1 */
|
|
2748 LtdcHandle.Init.HorizontalSync = Hsync_d1 - 1;
|
|
2749 /* Vertical synchronization height = Vsync - 1 */
|
|
2750 LtdcHandle.Init.VerticalSync = Vsync_d1 -1;
|
|
2751 /* Accumulated horizontal back porch = Hsync + HBP - 1 */
|
|
2752 LtdcHandle.Init.AccumulatedHBP = Hsync_d1 + HBP_d1 - 1;
|
|
2753 /* Accumulated vertical back porch = Vsync + VBP - 1 */
|
|
2754 LtdcHandle.Init.AccumulatedVBP = Vsync_d1 + VBP_d1 - 1;
|
|
2755 /* Accumulated active width = Hsync + HBP + Active Width - 1 */
|
|
2756 LtdcHandle.Init.AccumulatedActiveW = Hsync_d1 + HBP_d1 + ActiveW_d1 - 1;
|
|
2757 /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */
|
|
2758 LtdcHandle.Init.AccumulatedActiveH = Vsync_d1 + VBP_d1 + ActiveH_d1 - 1;
|
|
2759 /* Total width = Hsync + HBP + Active Width + HFP - 1 */
|
|
2760 LtdcHandle.Init.TotalWidth = Hsync_d1 + HBP_d1 + ActiveW_d1 + HFP_d1 - 1;
|
|
2761 /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */
|
|
2762 LtdcHandle.Init.TotalHeigh = Vsync_d1 + VBP_d1 + ActiveH_d1 + VFP_d1 - 1;
|
|
2763
|
|
2764 /* Configure R,G,B component values for LCD background color */
|
|
2765 LtdcHandle.Init.Backcolor.Red= 0;
|
|
2766 LtdcHandle.Init.Backcolor.Blue= 0;
|
|
2767 LtdcHandle.Init.Backcolor.Green= 0;
|
|
2768
|
|
2769 /* LCD clock configuration */
|
|
2770 /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
|
|
2771 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
|
|
2772 /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
|
|
2773 /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_8 = 48/4 = 6Mhz */
|
|
2774
|
|
2775 /* done in base.c SystemClockConfig
|
|
2776
|
|
2777 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
|
|
2778 PeriphClkInitStruct.PLLSAI.PLLSAIN = 192;
|
|
2779 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;
|
|
2780 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;
|
|
2781 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
|
|
2782 */
|
|
2783 /* Polarity */
|
|
2784 LtdcHandle.Init.HSPolarity = LTDC_HSPOLARITY_AL;
|
|
2785 LtdcHandle.Init.VSPolarity = LTDC_VSPOLARITY_AL;
|
|
2786 LtdcHandle.Init.DEPolarity = LTDC_DEPOLARITY_AL;
|
|
2787 LtdcHandle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;//LTDC_PCPOLARITY_IPC;
|
|
2788
|
|
2789 LtdcHandle.Instance = LTDC;
|
|
2790
|
|
2791 /* Configure the LTDC */
|
|
2792 if(HAL_LTDC_Init(&LtdcHandle) != HAL_OK) // initialize GPIO Pins, too
|
|
2793 {
|
|
2794 /* Initialization Error */
|
|
2795 GFX_Error_Handler();
|
|
2796 }
|
|
2797 }
|
|
2798
|
|
2799 void GFX_LTDC_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address)
|
|
2800 {
|
|
2801 LTDC_LayerCfgTypeDef Layercfg;
|
|
2802
|
|
2803 /* Layer Init */
|
|
2804 Layercfg.WindowX0 = 0;
|
|
2805 Layercfg.WindowX1 = 480;
|
|
2806 Layercfg.WindowY0 = 0;
|
|
2807 Layercfg.WindowY1 = 800;
|
|
2808 Layercfg.PixelFormat = LTDC_PIXEL_FORMAT_AL88;//LTDC_PIXEL_FORMAT_ARGB8888;
|
|
2809 Layercfg.FBStartAdress = FB_Address;
|
|
2810 Layercfg.Alpha = 255;
|
|
2811 Layercfg.Alpha0 = 0;
|
|
2812 Layercfg.Backcolor.Blue = 0;
|
|
2813 Layercfg.Backcolor.Green = 0;
|
|
2814 Layercfg.Backcolor.Red = 0;
|
|
2815 Layercfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
|
|
2816 Layercfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
|
|
2817 Layercfg.ImageWidth = 480;
|
|
2818 Layercfg.ImageHeight = 800;
|
|
2819
|
|
2820 HAL_LTDC_ConfigCLUT(&LtdcHandle, ColorLUT, CLUT_END, LayerIndex);
|
|
2821 HAL_LTDC_ConfigLayer(&LtdcHandle, &Layercfg, LayerIndex);
|
|
2822 HAL_LTDC_EnableCLUT(&LtdcHandle, LayerIndex);
|
|
2823 }
|
|
2824
|
|
2825 static uint32_t GFX_doubleBufferOne(void)
|
|
2826 {
|
|
2827 return SDRAM_DOUBLE_BUFFER_ONE;
|
|
2828 }
|
|
2829
|
|
2830
|
|
2831 static uint32_t GFX_doubleBufferTwo(void)
|
|
2832 {
|
|
2833 return SDRAM_DOUBLE_BUFFER_TWO;
|
|
2834 }
|
|
2835
|
|
2836 uint32_t getFrame(uint8_t callerId)
|
|
2837 {
|
|
2838 static uint8_t lastFrameProvided = 0;
|
|
2839 uint8_t i;
|
|
2840
|
|
2841 /* first iteration: look for a clear frame */
|
|
2842 i = lastFrameProvided;
|
|
2843 do
|
|
2844 {
|
|
2845 i++;
|
|
2846 if(i == MAXFRAMES)
|
|
2847 {
|
|
2848 i = 0;
|
|
2849 }
|
|
2850 } while((i != lastFrameProvided) && (frame[i].status != CLEAR));
|
|
2851
|
|
2852 if((i < MAXFRAMES) && (frame[i].status == CLEAR))
|
|
2853 {
|
|
2854 frame[i].status = BLOCKED;
|
|
2855 frame[i].caller = callerId;
|
|
2856 lastFrameProvided = i;
|
|
2857 return frame[i].StartAddress;
|
|
2858 }
|
|
2859
|
|
2860 /* second iteration: look for a frame which may be reused after clearing */
|
|
2861 i = lastFrameProvided;
|
|
2862 do
|
|
2863 {
|
|
2864 i++;
|
|
2865 if(i == MAXFRAMES)
|
|
2866 {
|
|
2867 i = 0;
|
|
2868 }
|
|
2869 }while((i != lastFrameProvided) && (frame[i].status != RELEASED));
|
|
2870
|
|
2871
|
|
2872 if((i < MAXFRAMES) && (frame[i].status == RELEASED))
|
|
2873 {
|
|
2874 GFX_clear_frame_immediately(frame[i].StartAddress);
|
|
2875 frame[i].status = BLOCKED;
|
|
2876 lastFrameProvided = i;
|
|
2877 return frame[i].StartAddress;
|
|
2878 }
|
|
2879 return 0;
|
|
2880 }
|
|
2881
|
|
2882
|
|
2883 void GFX_forceReleaseFramesWithId(uint8_t callerId)
|
|
2884 {
|
|
2885 for(int i=0; i<MAXFRAMES; i++)
|
|
2886 if((frame[i].caller == callerId) && (frame[i].status == BLOCKED))
|
|
2887 frame[i].status = RELEASED;
|
|
2888 }
|
|
2889
|
|
2890
|
|
2891 void releaseAllFramesExcept(uint8_t callerId, uint32_t frameStartAddress)
|
|
2892 {
|
|
2893 for(int i=0; i<MAXFRAMES; i++)
|
|
2894 if((frame[i].caller == callerId) && (frame[i].status == BLOCKED) && (frame[i].StartAddress != frameStartAddress))
|
|
2895 frame[i].status = RELEASED;
|
|
2896 }
|
|
2897
|
|
2898
|
|
2899 uint8_t releaseFrame(uint8_t callerId, uint32_t frameStartAddress)
|
|
2900 {
|
|
2901 static uint8_t countErrorCalls = 0;
|
|
2902
|
|
2903 if(frameStartAddress < FBGlobalStart)
|
|
2904 return 2;
|
|
2905
|
|
2906
|
|
2907 uint8_t i;
|
|
2908
|
|
2909 i = 0;
|
|
2910 while((i < MAXFRAMES) && (frame[i].StartAddress != frameStartAddress))
|
|
2911 i++;
|
|
2912
|
|
2913 if((i < MAXFRAMES) && (frame[i].StartAddress == frameStartAddress))
|
|
2914 {
|
|
2915 if(frame[i].caller == callerId)
|
|
2916 {
|
|
2917 frame[i].status = RELEASED;
|
|
2918 return 1;
|
|
2919 }
|
|
2920 else
|
|
2921 countErrorCalls++;
|
|
2922 }
|
|
2923 return 0;
|
|
2924 }
|
|
2925
|
|
2926
|
|
2927 uint16_t blockedFramesCount(void)
|
|
2928 {
|
|
2929 uint16_t count = MAXFRAMES;
|
|
2930
|
|
2931 for(int i = 0;i<MAXFRAMES;i++)
|
|
2932 if(frame[i].status == BLOCKED)
|
|
2933 count--;
|
|
2934
|
|
2935 return count;
|
|
2936 }
|
|
2937
|
|
2938
|
|
2939 uint8_t housekeepingFrame(void)
|
|
2940 {
|
|
2941 static uint8_t countLogClear = 0;
|
|
2942 uint8_t i;
|
|
2943 uint8_t retVal = 1;
|
|
2944
|
|
2945 if(DMA2D_at_work == 255)
|
|
2946 {
|
|
2947 i = 0;
|
|
2948 /* skip frame cleaning for actual frames which have not yet been replaced by new top/bottom frames */
|
|
2949 while((i < MAXFRAMES) && ((frame[i].status != RELEASED) || (frame[i].StartAddress == GFX_get_pActualFrameTop()) || (frame[i].StartAddress == GFX_get_pActualFrameBottom())))
|
|
2950 i++;
|
|
2951
|
|
2952 if((i < MAXFRAMES) && (frame[i].status == RELEASED))
|
|
2953 {
|
|
2954 if(frame[i].caller == 15)
|
|
2955 countLogClear++;
|
|
2956 GFX_clear_frame_dma2d(i);
|
|
2957 }
|
|
2958 else
|
|
2959 {
|
|
2960 retVal = 0; /* no more frame to be cleaned found */
|
|
2961 }
|
|
2962 }
|
|
2963 return retVal;
|
|
2964 }
|
|
2965
|
|
2966
|
|
2967 static void GFX_Dma2d_TransferComplete(DMA2D_HandleTypeDef* Dma2dHandle)
|
|
2968 {
|
|
2969 if(DMA2D_at_work < MAXFRAMES)
|
|
2970 frame[DMA2D_at_work].status = CLEAR;
|
|
2971
|
|
2972 DMA2D_at_work = 255;
|
|
2973 }
|
|
2974
|
|
2975
|
|
2976 static void GFX_Dma2d_TransferError(DMA2D_HandleTypeDef* Dma2dHandle)
|
|
2977 {
|
|
2978
|
|
2979 }
|
|
2980
|
|
2981 static void GFX_Error_Handler(void)
|
|
2982 {
|
|
2983 /* Turn LED3 on */
|
|
2984 // BSP_LED_On(LED3);
|
|
2985 while(1)
|
|
2986 {
|
|
2987 }
|
|
2988 }
|
|
2989
|
|
2990 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)
|
|
2991 {
|
|
2992 GFX_DrawCfgWindow hgfx;
|
|
2993
|
|
2994
|
|
2995 if(XrightGimpStyle > 799)
|
|
2996 XrightGimpStyle = 799;
|
|
2997 if(XleftGimpStyle >= XrightGimpStyle)
|
|
2998 XleftGimpStyle = 0;
|
|
2999 if(YtopGimpStyle > 479)
|
|
3000 YtopGimpStyle = 479;
|
|
3001
|
|
3002 hgfx.Image = tMscreen;
|
|
3003 hgfx.WindowNumberOfTextLines = 1;
|
|
3004 hgfx.WindowLineSpacing = 0;
|
|
3005 hgfx.WindowTab = 0;
|
|
3006
|
|
3007 hgfx.WindowX0 = XleftGimpStyle;
|
|
3008 hgfx.WindowX1 = XrightGimpStyle;
|
|
3009 hgfx.WindowY1 = 479 - YtopGimpStyle;
|
|
3010 if(hgfx.WindowY1 < Font->height)
|
|
3011 hgfx.WindowY0 = 0;
|
|
3012 else
|
|
3013 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
|
|
3014 GFX_write_string_color(Font, &hgfx, text, 0, color);
|
|
3015 }
|
|
3016
|
|
3017
|
|
3018 void gfx_write_topline_simple(GFX_DrawCfgScreen *tMscreen, const char *text, uint8_t color)
|
|
3019 {
|
|
3020 GFX_DrawCfgWindow hgfx;
|
|
3021 const tFont *Font = &FontT48;
|
|
3022
|
|
3023 hgfx.Image = tMscreen;
|
|
3024 hgfx.WindowNumberOfTextLines = 1;
|
|
3025 hgfx.WindowLineSpacing = 0;
|
|
3026
|
|
3027 hgfx.WindowTab = 0;
|
|
3028 hgfx.WindowX0 = 20;
|
|
3029 hgfx.WindowX1 = 779;
|
|
3030
|
|
3031 hgfx.WindowY1 = 479;
|
|
3032 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
|
|
3033 GFX_write_label(Font, &hgfx, text, color);
|
|
3034 }
|
|
3035
|
|
3036
|
|
3037 void gfx_write_page_number(GFX_DrawCfgScreen *tMscreen, uint8_t page, uint8_t total, uint8_t color)
|
|
3038 {
|
|
3039 GFX_DrawCfgWindow hgfx;
|
|
3040 const tFont *Font = &FontT48;
|
|
3041 char text[7];
|
|
3042 uint8_t i, secondDigitPage, secondDigitTotal;
|
|
3043
|
|
3044 if(total > 8)
|
|
3045 {
|
|
3046 Font = &FontT24;
|
|
3047 }
|
|
3048
|
|
3049 hgfx.Image = tMscreen;
|
|
3050 hgfx.WindowNumberOfTextLines = 1;
|
|
3051 hgfx.WindowLineSpacing = 0;
|
|
3052 hgfx.WindowTab = 0;
|
|
3053
|
|
3054 hgfx.WindowX1 = 779;
|
|
3055 if(Font == &FontT24)
|
|
3056 {
|
|
3057 hgfx.WindowX0 = hgfx.WindowX1 - (Font->spacesize*3);
|
|
3058 }
|
|
3059 else
|
|
3060 {
|
|
3061 hgfx.WindowX0 = hgfx.WindowX1 - (Font->spacesize2Monospaced*3);
|
|
3062 }
|
|
3063 hgfx.WindowY1 = 479;
|
|
3064 hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
|
|
3065 if(page > 99)
|
|
3066 page = 99;
|
|
3067 if(total > 99)
|
|
3068 total = 99;
|
|
3069
|
|
3070 i = 0;
|
|
3071 text[i++] = '\002';
|
|
3072
|
|
3073 secondDigitPage = page / 10;
|
|
3074 page -= secondDigitPage * 10;
|
|
3075
|
|
3076 secondDigitTotal = total / 10;
|
|
3077 total -= secondDigitTotal * 10;
|
|
3078
|
|
3079 if(secondDigitPage)
|
|
3080 text[i++] = '0' + secondDigitPage;
|
|
3081 text[i++] = '0' + page;
|
|
3082
|
|
3083 text[i++] = '/';
|
|
3084
|
|
3085 if(secondDigitTotal)
|
|
3086 text[i++] = '0' + secondDigitTotal;
|
|
3087 text[i++] = '0' + total;
|
|
3088
|
|
3089 text[i] = 0;
|
|
3090
|
|
3091 GFX_clear_window_immediately(&hgfx);
|
|
3092 GFX_write_label(Font, &hgfx, text, color);
|
|
3093 }
|
|
3094
|
|
3095
|
|
3096 uint8_t gfx_number_to_string(uint8_t max_digits, _Bool fill, char *pText, uint32_t input)
|
|
3097 {
|
|
3098 uint8_t digits[10];
|
|
3099 uint32_t number, divider;
|
|
3100 int first;
|
|
3101 uint8_t out;
|
|
3102
|
|
3103 number = input;
|
|
3104 first = 0;
|
|
3105 divider = 1000000000;
|
|
3106 for(int i=9;i>=0;i--)
|
|
3107 {
|
|
3108 digits[i] = (uint8_t)(number / divider);
|
|
3109 number -= digits[i] * divider;
|
|
3110 divider /= 10;
|
|
3111 if((first == 0) && (digits[i] != 0))
|
|
3112 first = i;
|
|
3113 }
|
|
3114
|
|
3115 if((first + 1) > max_digits)
|
|
3116 {
|
|
3117 for(int i = 0; i<max_digits; i++)
|
|
3118 pText[i] = '9';
|
|
3119 out = max_digits;
|
|
3120 }
|
|
3121 else if(fill)
|
|
3122 {
|
|
3123 int i = 0;
|
|
3124 for(int k = max_digits; k>0; k--)
|
|
3125 pText[i++] = digits[k -1] + '0';
|
|
3126 out = max_digits;
|
|
3127 }
|
|
3128 else
|
|
3129 {
|
|
3130 int i = 0;
|
|
3131 for(int k = first; k>=0; k--)
|
|
3132 pText[i++] = digits[k] + '0';
|
|
3133 out = i;
|
|
3134 }
|
|
3135
|
|
3136 return out;
|
|
3137 }
|
|
3138
|
|
3139
|
|
3140 /* output is
|
|
3141 * 0->
|
|
3142 * |
|
|
3143 * v
|
|
3144 *
|
|
3145 * input is
|
|
3146 *
|
|
3147 * ->
|
|
3148 * A
|
|
3149 * |
|
|
3150 * 0
|
|
3151 */
|
|
3152 void GFX_screenshot(void)
|
|
3153 {
|
|
3154 uint32_t pSource = GFX_get_pActualFrameTop();
|
|
3155 uint32_t pSourceBottom =GFX_get_pActualFrameBottom();
|
|
3156 uint32_t pBottomNew = getFrame(99);
|
|
3157 uint32_t pDestination = GFX_doubleBufferOne();
|
|
3158 uint32_t sourceNow;
|
|
3159
|
|
3160
|
|
3161 uint32_t bot_leftStart = FrameHandler.actualBottom.leftStart; // x0 z.B. 0
|
|
3162 uint32_t bot_bottomStart = FrameHandler.actualBottom.bottomStart; // y0 z.B. 25
|
|
3163 uint32_t bot_width = FrameHandler.actualBottom.width; // 800
|
|
3164 uint32_t bot_height = FrameHandler.actualBottom.height; // 390
|
|
3165
|
|
3166 struct split
|
|
3167 {
|
|
3168 uint8_t blue;
|
|
3169 uint8_t green;
|
|
3170 uint8_t red;
|
|
3171 uint8_t alpha;
|
|
3172 };
|
|
3173
|
|
3174 union inout_u
|
|
3175 {
|
|
3176 uint32_t in;
|
|
3177 struct split out;
|
|
3178 };
|
|
3179
|
|
3180 union inout_u value;
|
|
3181
|
|
3182 /* test
|
|
3183 uint32_t pSourceTemp = pSource + (2*479);
|
|
3184 for (int j = 0xFFFF; j > 0x00FF; j -= 0x0100)
|
|
3185 {
|
|
3186 *(__IO uint16_t*)pSourceTemp = j;
|
|
3187 pSourceTemp += 480*2;
|
|
3188 }
|
|
3189 */
|
|
3190 // Top Layer
|
|
3191 const unsigned width = 800, height = 480;
|
|
3192 const uint32_t heightX2 = height*2;
|
|
3193
|
|
3194 for(unsigned y = 0; y < height; y++)
|
|
3195 {
|
|
3196 sourceNow = pSource + 2 * ((height - 1) - y);
|
|
3197 for(unsigned x = 0; x < width; x++)
|
|
3198 {
|
|
3199 // sourceNow += 2 * height * x + 2 * (height - 1 - y);
|
|
3200 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)];
|
|
3201 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1);
|
|
3202
|
|
3203 *(__IO uint8_t*)(pDestination++) = value.out.red;
|
|
3204 *(__IO uint8_t*)(pDestination++) = value.out.green;
|
|
3205 *(__IO uint8_t*)(pDestination++) = value.out.blue;
|
|
3206 *(__IO uint8_t*)(pDestination++) = value.out.alpha;
|
|
3207 sourceNow += heightX2;
|
|
3208 }
|
|
3209 }
|
|
3210
|
|
3211 // Bottom Layer
|
|
3212 // build newBottom
|
|
3213 pSource = pSourceBottom;
|
|
3214 for(unsigned x = bot_leftStart; x < bot_leftStart+bot_width; x++)
|
|
3215 {
|
|
3216 for(unsigned y = bot_bottomStart; y < bot_bottomStart+bot_height; y++)
|
|
3217 {
|
|
3218 pDestination = pBottomNew + (2 * y);
|
|
3219 pDestination += heightX2 * x;
|
|
3220 *(__IO uint16_t*)(pDestination) = *(__IO uint16_t*)(pSource);
|
|
3221 pSource += 2;
|
|
3222 }
|
|
3223 }
|
|
3224
|
|
3225 // output Bottom Layer
|
|
3226 pSource = pBottomNew;
|
|
3227 pDestination = GFX_doubleBufferTwo();
|
|
3228
|
|
3229 for(unsigned y = 0; y < height; y++)
|
|
3230 {
|
|
3231 sourceNow = pSource + 2 * ((height - 1) - y);
|
|
3232 for(unsigned x = 0; x < width; x++)
|
|
3233 {
|
|
3234 // sourceNow = pSource + 2 * height * x + 2 * (height - 1 - y);
|
|
3235 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)];
|
|
3236 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1);
|
|
3237
|
|
3238 *(__IO uint8_t*)(pDestination++) = value.out.red;
|
|
3239 *(__IO uint8_t*)(pDestination++) = value.out.green;
|
|
3240 *(__IO uint8_t*)(pDestination++) = value.out.blue;
|
|
3241 *(__IO uint8_t*)(pDestination++) = value.out.alpha;
|
|
3242 sourceNow += heightX2;
|
|
3243 }
|
|
3244 }
|
|
3245 releaseFrame(99,pBottomNew);
|
|
3246 /*
|
|
3247 // das kommt dazu!
|
|
3248 unsigned yEnd = 480 - FrameHandler.actualBottom.bottomStart;
|
|
3249 unsigned yStart = yEnd - FrameHandler.actualBottom.height;
|
|
3250
|
|
3251 if(yStart > 0)
|
|
3252 {
|
|
3253 for(unsigned y = 0; y < yStart; y++)
|
|
3254 for(unsigned x = 0; x < width; x++)
|
|
3255 {
|
|
3256 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3257 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3258 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3259 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3260 }
|
|
3261 }
|
|
3262 for(unsigned y = yStart; y < yEnd; y++)
|
|
3263 for(unsigned x = 0; x < width; x++)
|
|
3264 {
|
|
3265 sourceNow = pSource + 2 * height * x + 2 * (height - 1 - y);
|
|
3266 value.in = ColorLUT[*(__IO uint8_t*)(sourceNow)];
|
|
3267 value.out.alpha = *(__IO uint8_t*)(sourceNow + 1);
|
|
3268
|
|
3269 *(__IO uint8_t*)(pDestination++) = value.out.red;
|
|
3270 *(__IO uint8_t*)(pDestination++) = value.out.green;
|
|
3271 *(__IO uint8_t*)(pDestination++) = value.out.blue;
|
|
3272 *(__IO uint8_t*)(pDestination++) = value.out.alpha;
|
|
3273 }
|
|
3274 if(yEnd < 480)
|
|
3275 {
|
|
3276 for(unsigned y = yEnd; y < 480; y++)
|
|
3277 for(unsigned x = 0; x < width; x++)
|
|
3278 {
|
|
3279 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3280 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3281 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3282 *(__IO uint8_t*)(pDestination++) = 0;
|
|
3283 }
|
|
3284 }
|
|
3285 */
|
|
3286 }
|
|
3287
|
|
3288 uint32_t GFX_Character_Width(uint8_t character, tFont *Font)
|
|
3289 {
|
|
3290 uint32_t i;
|
|
3291 for(i=0;i<Font->length;i++)
|
|
3292 {
|
|
3293 if(Font->chars[i].code == character)
|
|
3294 {
|
|
3295 return Font->chars[i].image->width;
|
|
3296 }
|
|
3297 }
|
|
3298
|
|
3299 return 0;
|
|
3300 }
|
|
3301
|
|
3302 void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor)
|
|
3303 {
|
|
3304 char *p = text;
|
|
3305 uint8_t index = 0;
|
|
3306
|
|
3307 while ((*p) && (index < MAX_COLOR_STRING_LENGTH))
|
|
3308 {
|
|
3309 if (*p == '\020')
|
|
3310 {
|
|
3311 if(!GFX_is_colorschemeDiveStandard())
|
|
3312 {
|
|
3313 *p = '\027';
|
|
3314 }
|
|
3315 else if(alternativeColor != 0)
|
|
3316 {
|
|
3317 *p += alternativeColor;
|
|
3318 }
|
|
3319 }
|
|
3320 p++;
|
|
3321 index++;
|
|
3322 }
|
|
3323 }
|
|
3324
|