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