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