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