/******************************************************************** * * _SendToPrinter * * Function description * Shows the contents of a memory device on the display * In "real life", this routine would send the contents of the memory * device to the printer. */ static void _SendToPrinter(GUI_MEMDEV_Handle hMem, int yOff) { int xSize, ySize, x, y, Offset, Bit; U8 * pData; /* Get the size of the memory device */ xSize = GUI_MEMDEV_GetXSize(hMem); ySize = GUI_MEMDEV_GetYSize(hMem); pData = (U8 *)GUI_MEMDEV_GetDataPtr(hMem); /* Get the data pointer of the memory device */ /* Draw the pixels of the memory device on the screen */ for (y = 0; y < ySize; y++) { for (x = 0; x < xSize; x++) { U8 Index; Offset = x >> 3; Bit = 7 - (x & 7); Index = *(pData + Offset); Index &= (1 << Bit); /* The index could be 0 or 1, so use black and white */ if (Index == 0 ) { GUI_SetColor(GUI_BLACK); } else { GUI_SetColor(GUI_WHITE); } /* Draw the pixel. At this point for example a printer output routine can be called */ GUI_DrawPixel(x, y + yOff); } pData += (xSize + 7) / 8; } }
/** * @brief Update the text area display * @param None * @retval None */ void USER_LCD_LOG_UpdateDisplay (void) { #ifndef __USER_USE_SOLID_BK_ GUI_MEMDEV_Handle tempMem; void *pbk; void *ptemp; #endif uint8_t cnt = 0 ; uint16_t length = 0 ; uint16_t ptr = 0, index = 0; if((USER_LCD_CacheBuffer_yptr_bottom < (USER_YWINDOW_SIZE -1)) && (USER_LCD_CacheBuffer_yptr_bottom >= USER_LCD_CacheBuffer_yptr_top)) { if(u8_enable_display) { USER_LCD_LOG_DisplayStringAtLine ((USER_YWINDOW_MIN + Y0/GUI_GetFontSizeY()+ USER_LCD_CacheBuffer_yptr_bottom), (char *)(USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].line), USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].color); } } else { if(USER_LCD_CacheBuffer_yptr_bottom < USER_LCD_CacheBuffer_yptr_top) { /* Virtual length for rolling */ length = USER_LCD_CACHE_DEPTH + USER_LCD_CacheBuffer_yptr_bottom ; } else { length = USER_LCD_CacheBuffer_yptr_bottom; } ptr = length - USER_YWINDOW_SIZE + 1; GUI_SetFont(&USER_LCD_LOG_TEXT_FONT); #ifdef __USER_USE_SOLID_BK_ for (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++) { index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ; if(u8_enable_display) { USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), (char *)(USER_LCD_CacheBuffer[index].line), USER_LCD_CacheBuffer[index].color); } } #else tempMem=GUI_MEMDEV_Create(GUI_MEMDEV_GetXPos(backgroundDisplayMem),GUI_MEMDEV_GetYPos(backgroundDisplayMem),GUI_MEMDEV_GetXSize(backgroundDisplayMem),GUI_MEMDEV_GetYSize(backgroundDisplayMem)); if(tempMem) { pbk=GUI_MEMDEV_GetDataPtr(backgroundDisplayMem); ptemp=GUI_MEMDEV_GetDataPtr(tempMem); memcpy((uint8_t *)ptemp,(uint8_t *)pbk,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem)); GUI_MEMDEV_Select(backgroundDisplayMem); for (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++) { index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ; if(u8_enable_display) { USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), (char *)(USER_LCD_CacheBuffer[index].line), USER_LCD_CacheBuffer[index].color); } } GUI_MEMDEV_CopyToLCD(backgroundDisplayMem); GUI_MEMDEV_Select(0); memcpy((uint8_t *)pbk,(uint8_t *)ptemp,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem)); GUI_MEMDEV_Delete(tempMem); tempMem=0; } #endif } }