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