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