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