/*------------------------------------------------------------------------------------*/ void DrawIcon(IconName _IconName, IconStatus _Status) { LCD_SetColors(LCD_COLOR_BLACK, LCD_COLOR_WHITE); switch (_IconName) { case Icon_TopBar_Clock: LCD_DrawChar(3, (20-Image_TopBar_Clock.height)/2, (ptImage)&Image_TopBar_Clock); break; case Icon_TopBar_Battery: LCD_DrawBMP(297, (20-Image_TopBar_Battery.height)/2, (ptImage)&Image_TopBar_Battery, 0); break; case Icon_TopBar_FlyTime: LCD_DrawBMP(142, (20-Image_TopBar_FlyTime.height)/2, (ptImage)&Image_TopBar_FlyTime, 0); break; case Icon_TopBar_Temper: LCD_DrawBMP(214, (20-Image_TopBar_Temper.height)/2, (ptImage)&Image_TopBar_Temper, 0); break; case Icon_TopBar_DesatTime: LCD_DrawBMP(74, (20-Image_TopBar_DesatTime.height)/2, (ptImage)&Image_TopBar_DesatTime, 0); break; case Icon_BottomBar_ArrowUp: LCD_DrawBMP(112, ((20-Image_BottomBar_ArrowUp.height)/2)+220, (ptImage)&Image_BottomBar_ArrowUp, 0); break; case Icon_BottomBar_ArrowDown: LCD_DrawBMP(185, ((20-Image_BottomBar_ArrowUp.height)/2)+220, (ptImage)&Image_BottomBar_ArrowUp, 2); break; case Icon_BottomBar_ArrowLeft: LCD_DrawBMP(40, ((20- Image_BottomBar_ArrowLeft.height)/2)+220, (ptImage)&Image_BottomBar_ArrowLeft, 0); break; case Icon_BottomBar_Select: LCD_DrawBMP(258, ((20-Image_BottomBar_Select.height)/2)+220, (ptImage)&Image_BottomBar_Select, 0); break; case Icon_HomeMenu_GoDive: switch(_Status) { case Select: LCD_SetColors(Black, White); LCD_FillRect(26, 30, 57, 57, Blue); break; default: LCD_SetColors(White, Black); LCD_FillRect(26, 30, 57, 57, Black); break; } LCD_DrawChar((26+((57-Image_HomeMenu_GoDive.width)/2)), 34,(ptImage)&Image_HomeMenu_GoDive); break; default: LCD_FillRect(0, 120, 120, 3, LCD_COLOR_RED);//Error notification break; } }
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str, const struct LabelDesc *desc, u8 is_selected) { u16 txt_w, txt_h; u16 txt_x, txt_y; // This is used to align text vertically u16 offset = (desc->font==NARROW_FONT.font) ? 1 : 0; LCD_SetFont(desc->font); LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++; if (obj_w == 0) obj_w = txt_w; if (obj_h == 0) obj_h = txt_h; if (desc->style == LABEL_LISTBOX) { LCD_FillRect(obj_x, obj_y, obj_w, obj_h, is_selected ? Display.listbox.fg_color : Display.listbox.bg_color); } else if (desc->style == LABEL_FILL) { LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color); } else { GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h); } if (desc->style != LABEL_LISTBOX && desc->fill_color != desc->outline_color) { LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color); obj_x+=2; obj_w-=4; } if (desc->style == LABEL_RIGHT) { txt_x = obj_x + obj_w - txt_w; } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT)) { txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2; } else { txt_x = obj_x+1; } txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2; if (desc->style == LABEL_LISTBOX) { LCD_SetFontColor(is_selected ? Display.listbox.fg_select : Display.listbox.bg_select); } else { if (desc->style != LABEL_FILL && is_selected) { LCD_SetFontColor(~desc->font_color); } else { LCD_SetFontColor(desc->font_color); } } LCD_PrintStringXY(txt_x, txt_y, str); }
// fill a rounded rectangle! void LCD_FillRoundRect(u16 x, u16 y, u16 w, u16 h, u16 r, u16 color) { // smarter version LCD_FillRect(x+r, y, w-2*r, h, color); // draw four corners fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color); fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color); }
// args are x0, x1, y0, y1, color const char* JSON_evalFilledRect(const char* ptr) { const char* data[4] = {NULL}; if(getAmountOfArgs(&ptr, data, 4) != 4) { // how do I recover? do all the other elements die? return ptr; // error! } LCD_FillRect(atoi(data[0]), atoi(data[2]), atoi(data[1]), atoi(data[3]), atoi(ptr-1)); return ptr; }
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str, const struct LabelDesc *desc, u8 is_selected) { u16 txt_w, txt_h; u16 txt_x, txt_y; u16 offset = (LCD_DEPTH > 1 && desc->font==NARROW_FONT.font) ? 1 : 0; LCD_SetFont(desc->font); LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++; if (obj_w == 0) obj_w = txt_w; if (obj_h == 0) obj_h = txt_h; if (offset && obj_y >= offset) { obj_y -= offset; } if (desc->style == LABEL_BOX) { // draw round rect for the textsel widget when it is pressable if (is_selected) { LCD_FillRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1); } else { GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h); LCD_DrawRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1); } } else if (desc->style == LABEL_FILL) { LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color); } else { GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h); } if (desc->fill_color != desc->outline_color) { LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color); obj_x+=2; obj_w-=4; } if (desc->style == LABEL_RIGHT) { txt_x = obj_x + obj_w - txt_w; } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT)) { txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2; } else { txt_x = obj_x+1; } txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2; if (desc->style != LABEL_FILL && is_selected) { LCD_SetFontColor(~desc->font_color); } else { LCD_SetFontColor(desc->font_color); } LCD_PrintStringXY(txt_x, txt_y, str); }
void prvLCDTask( void *pvParameters ) { xLCDMessage xMessage; portCHAR cY = mainLCD_CHAR_HEIGHT; const portCHAR * const pcString = "www.FreeRTOS.org"; const portCHAR * const pcBlankLine = " "; DRAW_Init(); #if mainINCLUDE_BITMAP == 1 DRAW_SetImage( pucImage, mainBITMAP_Y, mainBITMAP_X, bmpBITMAP_HEIGHT, bmpBITMAP_WIDTH ); #endif LCD_SetScreenOrientation( V9 ); DRAW_DisplayString( mainURL_Y, mainURL_X, pcString, strlen( pcString ) ); vTaskDelay( mainSPLASH_SCREEN_DELAY ); LCD_FillRect( 0, 0, CHIP_SCREEN_WIDTH, CHIP_SCREEN_HEIGHT, RGB_WHITE ); for( ;; ) { /* Wait for a message to arrive that requires displaying. */ while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS ); /* Check the message type. */ if( xMessage.xMessageType == mainUPDATE_BALL_MESSAGE ) { /* Read the MEMS and update the ball display on the LCD if required. */ MEMS_Handler(); POINTER_Handler(); } else { /* A text string was sent. First blank off the old text string, then draw the new text on the next line down. */ DRAW_DisplayString( 0, cY, pcBlankLine, strlen( pcBlankLine ) ); cY -= mainLCD_CHAR_HEIGHT; if( cY <= ( mainLCD_CHAR_HEIGHT - 1 ) ) { /* Wrap the line onto which we are going to write the text. */ cY = mainLCD_MAX_Y; } /* Display the message. */ DRAW_DisplayString( 0, cY, xMessage.pcMessage, strlen( xMessage.pcMessage ) ); } } }
void GUI_ClearRect(int x0, int y0, int x1, int y1) { GUI_DRAWMODE PrevDraw; GUI_LOCK(); PrevDraw = LCD_SetDrawMode(GUI_DRAWMODE_REV); #if GUI_WINSUPPORT WM_ADDORG(x0,y0); WM_ADDORG(x1,y1); WM_ITERATE_START(NULL) { #endif LCD_FillRect(x0,y0,x1,y1); #if GUI_WINSUPPORT } WM_ITERATE_END(); #endif LCD_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
void LCD_DrawWindowedImageFromFile(u16 x, u16 y, const char *file, s16 w, s16 h, u16 x_off, u16 y_off) { FILE *fh; u32 black, white; u8 buf[48]; u16 img_w = 0, img_h = 0; fh = fopen(file, "rb"); if(! fh) { printf("DEBUG: LCD_DrawWindowedImageFromFile: Image not found: %s\n", file); if (w > 0 && h > 0) LCD_FillRect(x, y, w, h, 0); return; } if (! image_read_header(fh, &img_w, &img_h, &black, &white)) { fclose(fh); return; } //printf("DEBUG: LCD_DrawWindowedImageFromFile: %s %dx%d %06x %06x\n", file, img_w, img_h, black, white); if (img_w > sizeof(buf)*8) { printf("DEBUG: LCD_DrawWindowedImageFromFile: Image is too wide: %d > %d\n", img_w, sizeof(buf)*8); fclose(fh); return; } if (w < 0) w = img_w; if (h < 0) h = img_h; LCD_DrawStart(x, y, x + w - 1, y + h -1, DRAW_NWSE); unsigned bytes = (img_w + 7) / 8; fseek(fh, bytes * y_off, SEEK_CUR); for (int i = 0; i < h; i++) { int ret = fread(buf, bytes, 1, fh); if (ret != 1) { //printf("DEBUG: LCD_DrawWindowedImageFromFile: Buffer read issue? (%s, %d, %d)\n", file, ret, i); break; } for (int j = 0; j < w; j++) { unsigned val = buf[(j + x_off) / 8] & (1 << (7 - ((j + x_off) % 8))); LCD_DrawPixelXY(x+j, y+i, val ? black : white); } } fclose(fh); LCD_DrawStop(); }
/********************************************************************* * * GUI_FillRect */ void GUI_FillRect(int x0, int y0, int x1, int y1) { #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); #if (GUI_WINSUPPORT) WM_ADDORG(x0,y0); WM_ADDORG(x1,y1); r.x0 = x0; r.x1 = x1; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r); { #endif LCD_FillRect(x0,y0,x1,y1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_UNLOCK(); }
/********************************************************************* * * GUIPROP_DispChar * * Purpose: * This is the routine that displays a character. It is used by all * other routines which display characters as a subroutine. */ void GUIPROP_DispChar(U16P c) { int BytesPerLine; GUI_DRAWMODE DrawMode = GUI_Context.TextMode; const GUI_FONT_PROP GUI_UNI_PTR * pProp = GUIPROP_FindChar(GUI_Context.pAFont->p.pProp, c); if (pProp) { GUI_DRAWMODE OldDrawMode; const GUI_CHARINFO GUI_UNI_PTR * pCharInfo = pProp->paCharInfo+(c-pProp->First); BytesPerLine = pCharInfo->BytesPerLine; OldDrawMode = LCD_SetDrawMode(DrawMode); if (GUI_MoveRTL) { GUI_Context.DispPosX -= pCharInfo->XDist * GUI_Context.pAFont->XMag; } LCD_DrawBitmap( GUI_Context.DispPosX, GUI_Context.DispPosY, pCharInfo->XSize, GUI_Context.pAFont->YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, /* Bits per Pixel */ BytesPerLine, pCharInfo->pData, &LCD_BKCOLORINDEX ); /* Fill empty pixel lines */ if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) { int YMag = GUI_Context.pAFont->YMag; int YDist = GUI_Context.pAFont->YDist * YMag; int YSize = GUI_Context.pAFont->YSize * YMag; if (DrawMode != LCD_DRAWMODE_TRANS) { LCD_COLOR OldColor = GUI_GetColor(); GUI_SetColor(GUI_GetBkColor()); LCD_FillRect(GUI_Context.DispPosX, GUI_Context.DispPosY + YSize, GUI_Context.DispPosX + pCharInfo->XSize, GUI_Context.DispPosY + YDist); GUI_SetColor(OldColor); } } LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */ if (!GUI_MoveRTL) { GUI_Context.DispPosX += pCharInfo->XDist * GUI_Context.pAFont->XMag; } } }
/********************************************************************* * * GUI_SIF_DispChar */ static void _GUI_SIF_DispChar(U16P c) { const U8 * pCharInfo, * pData; pCharInfo = _GetpCharInfo(GUI_Context.pAFont, c); if (pCharInfo) { GUI_DRAWMODE DrawMode, OldDrawMode; GUI_SIF_CHARINFO CharInfo; CharInfo.XSize = GUI__Read16(&pCharInfo); CharInfo.XDist = GUI__Read16(&pCharInfo); CharInfo.BytesPerLine = GUI__Read16(&pCharInfo); GUI__Read16(&pCharInfo); /* Dummy */ CharInfo.OffData = GUI__Read32(&pCharInfo); pData = (const U8 *)GUI_Context.pAFont->p.pFontData + CharInfo.OffData; DrawMode = GUI_Context.TextMode; OldDrawMode = LCD_SetDrawMode(DrawMode); LCD_DrawBitmap(GUI_Context.DispPosX, GUI_Context.DispPosY, CharInfo.XSize, GUI_Context.pAFont->YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, CharInfo.BytesPerLine, pData, &LCD_BKCOLORINDEX); /* Fill empty pixel lines */ if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) { int YMag = GUI_Context.pAFont->YMag; int YDist = GUI_Context.pAFont->YDist * YMag; int YSize = GUI_Context.pAFont->YSize * YMag; if (DrawMode != LCD_DRAWMODE_TRANS) { LCD_COLOR OldColor = GUI_GetColor(); GUI_SetColor(GUI_GetBkColor()); LCD_FillRect(GUI_Context.DispPosX, GUI_Context.DispPosY + YSize, GUI_Context.DispPosX + CharInfo.XSize, GUI_Context.DispPosY + YDist); GUI_SetColor(OldColor); } } LCD_SetDrawMode(OldDrawMode); /* Restore draw mode */ GUI_Context.DispPosX += CharInfo.XDist; } }
/********************************************************************* * * GUI_InvertRect */ void GUI_InvertRect(int x0, int y0, int x1, int y1) { GUI_DRAWMODE PrevDraw; #if (GUI_WINSUPPORT) GUI_RECT r; #endif GUI_LOCK(); PrevDraw = GUI_SetDrawMode(GUI_DRAWMODE_XOR); #if (GUI_WINSUPPORT) WM_ADDORG(x0, y0); WM_ADDORG(x1, y1); r.x0 = x0; r.x1 = x1; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r); { #endif LCD_FillRect(x0, y0, x1, y1); #if (GUI_WINSUPPORT) } WM_ITERATE_END(); #endif GUI_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
/********************************************************************* * * GUI_ClearRect */ void GUI_ClearRect(int x0, int y0, int x1, int y1) { GUI_DRAWMODE PrevDraw; #if GUI_WINSUPPORT GUI_RECT r; #endif GUI_LOCK(); PrevDraw = LCD_SetDrawMode(GUI_DRAWMODE_REV); #if GUI_WINSUPPORT WM_ADDORG(x0,y0); WM_ADDORG(x1,y1); r.x0 = x0; r.x1 = x1; r.y0 = y0; r.y1 = y1; WM_ITERATE_START(&r) { #endif LCD_FillRect(x0,y0,x1,y1); #if GUI_WINSUPPORT } WM_ITERATE_END(); #endif LCD_SetDrawMode(PrevDraw); GUI_UNLOCK(); }
/**********************特定类型文件浏览器***************************/ u16 FileExplorer(u16 num,FileType ft) { u16 cnt = 0; u16 index=0; //返回的文件名索引 u16 curruntIndex=0; //当前显示的页数,每页8行,页数从0开始,每次加减8 EXPLORER_BUTTON eb; u8 fresh=1; LCD_Clear(White); //白色背景 LCD_FillRect(0, 0, 20, 400,BackColor); //蓝色标题栏 LCD_FillRect(0, 220, 20, 400,BackColor);//蓝色菜单栏 LCD_FillRect(360, 20, 200, 40,BackColor);//蓝色滚动条 LCD_SetTextColor(Black); LCD_SetBackColor(BackColor); LCD_DisplayString(10,2,"文件浏览器"); LCD_DisplayString(5,222,"选择"); LCD_DisplayString(360,222,"返回"); LCD_SetBackColor(ButtonColor); LCD_DisplayString(360+12,20+12,"∧"); LCD_DisplayString(360+12,220-12-16,"∨"); LCD_DrawLine(0,20,400,Horizontal); //黑色分割线 LCD_DrawLine(0,220,400,Horizontal); for(cnt=1;cnt<8;cnt++)LCD_DrawLine(0,cnt*25+20,360,Horizontal); while(1) { if(fresh) { //文件显示 switch(ft) { case MP3: for (cnt = 1;cnt<9&&cnt+curruntIndex<=num;cnt++) { ShowImage("/icon/mp3.bmp",0,cnt*25-5); LCD_FillRect(30,cnt*25,16,330,White); LCD_DisplayString(30,cnt*25,musicFile[cnt+curruntIndex]); } break; case BMP: for (cnt = 1;cnt<9&&cnt+curruntIndex<=num;cnt++) { ShowImage("/icon/bmp.bmp",0,cnt*25-5); LCD_FillRect(30,cnt*25,16,330,White); LCD_DisplayString(30,cnt*25,photoFile[cnt+curruntIndex]); } break; case TXT: for (cnt = 1;cnt<9&&cnt+curruntIndex<=num;cnt++) { ShowImage("/icon/txt.bmp",0,cnt*25-5); LCD_FillRect(30,cnt*25,16,330,White); LCD_DisplayString(30,cnt*25,bookFile[cnt+curruntIndex]); } break; case UNKNOWN: break; } for(;cnt<9;cnt++)LCD_FillRect(0,cnt*25-3,23,360,White); //不足一页,清楚上页内容 fresh=0; } if(penPoint.keyState==Down) { eb=GetExplorerIndex(); switch(eb) { case BACK: goto RT; case TURNUP: if(curruntIndex>0)curruntIndex-=8; fresh=1; break; case TURNDOWN: if(curruntIndex<num)curruntIndex+=8; fresh=1; break; default: index=eb+curruntIndex; goto RT; } } } RT: return index; }
void LCD_Clear(unsigned int val) { LCD_FillRect(0, 0, LCD_WIDTH, LCD_HEIGHT, val); }
/********************************************************************* * * _DrawBitmap_RLE8 */ static void _DrawBitmap_RLE8(int x0,int y0,int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) { LCD_PIXELINDEX aColorIndex[2]; LCD_PIXELINDEX PixelIndex; int xi,y; int xL, yL; const U8 GUI_UNI_PTR * pPixelOrg = pPixel; char NoTrans = !(GUI_Context.DrawMode & LCD_DRAWMODE_TRANS); const LCD_PIXELINDEX* pTrans =NULL; char IsMagnified = ((yMag | xMag) != 1); aColorIndex[0] = LCD_ACOLORINDEX[0]; aColorIndex[1] = LCD_ACOLORINDEX[1]; /* Handle color translation */ if ((pLogPal) && (pLogPal->pPalEntries)) { if ((pTrans = LCD_GetpPalConvTable(pLogPal)) == NULL) { return; } } /* Check if we can limit the number of lines due to clipping) */ if (yMag == 1) { if (ysize > GUI_Context.ClipRect.y1 - y0 + 1) ysize = GUI_Context.ClipRect.y1 - y0 + 1; } /* Init variables for looping */ xi=0; y =0; /* Check if we can use the cache to save some unnecessary iterations */ if (!IsMagnified) { int yDiff = GUI_Context.ClipRect.y0 - y0; if ((Cache.pPixelStart == pPixel) && (yDiff > Cache.y)) { /* Accept cache values */ y = Cache.y; xi = Cache.x; pPixel = Cache.pPixel; } } /* Init values for caching */ Cache.pPixel = Cache.pPixelStart = pPixelOrg; Cache.x = Cache.y = 0; /* Repeat until we have reached bottom */ for (; y < ysize; ) { U8 Cmd = *pPixel++; U8 Data = *pPixel++; if (Cmd) { /* Save cache info */ Cache.pPixel = pPixel-2; Cache.x = xi; Cache.y = y; LCD_ACOLORINDEX[1] = pTrans ? *(pTrans+Data) : Data; while (Cmd) { int xi1 = xi+Cmd; if (xi1>=xsize) xi1 = xsize; Cmd -= (xi1-xi); if (Data || NoTrans) { /* Skip transparent pixels */ if (IsMagnified) { xL = xMag * xi + x0; yL = yMag * y + y0; LCD_FillRect(xL, yL, xL + xMag * (xi1 - xi) -1 , yL + yMag - 1); } else { LCD_DrawHLine(x0+xi, y + y0, xi1+x0-1); } } xi =xi1; if (xi1==xsize) { y++; xi=0; } } } else { do { U8 Index = *pPixel++; if (Index || NoTrans) { /* Skip transparent pixels */ int x = x0+xi; PixelIndex = pTrans ? *(pTrans+Index) : Index; if (IsMagnified) { LCD_SetColorIndex(PixelIndex); xL = xMag * xi + x0; yL = yMag * y + y0; LCD_FillRect(xL, yL, xL + xMag -1 , yL + yMag - 1); } else { #if 1 /* High speed variant */ if (y + y0>= GUI_Context.ClipRect.y0) if (x >= GUI_Context.ClipRect.x0) if (x <= GUI_Context.ClipRect.x1) LCDDEV_L0_SetPixelIndex(x, y + y0, PixelIndex); #else LCD_SetPixelIndex(x, y + y0, PixelIndex); #endif } } if (++xi >= xsize) { xi=0; y++; if (y >= ysize) break; } } while (--Data); } } LCD_ACOLORINDEX[0] = aColorIndex[0]; LCD_ACOLORINDEX[1] = aColorIndex[1]; }
//--------------------------------------------------------------------------- static void ZoneList_Draw(app_menu_t *pMenu, menu_item_t *pItem) // Draws the 'zone list' screen. Gets visible when ENTERING that item in the app-menu. // { int i, n_visible_items, sel_flags = SEL_FLAG_NONE; lcd_context_t dc; char cRadio; // character code for a selected or unselected "radio button" char sz20[22]; scroll_list_control_t *pSL = &pMenu->scroll_list; // Draw the COMPLETE screen, without clearing it initially to avoid flicker LCD_InitContext( &dc ); // init context for 'full screen', no clipping Menu_GetColours( sel_flags, &dc.fg_color, &dc.bg_color ); ScrollList_AutoScroll( pSL ); // modify pSL->scroll_pos to make the FOCUSED item visible dc.font = LCD_OPT_FONT_12x24; LCD_Printf( &dc, "\tZone %d/%d\r", (int)(pSL->focused_item+1), (int)pSL->num_items ); LCD_HorzLine( dc.x1, dc.y++, dc.x2, dc.fg_color ); // spacer between title and scrolling list LCD_HorzLine( dc.x1, dc.y++, dc.x2, dc.bg_color ); i = pSL->scroll_pos; // zero-based array index of the topmost VISIBLE item n_visible_items = 0; // find out how many items fit on the screen while( (dc.y < (LCD_SCREEN_HEIGHT-8)) && (i<pSL->num_items) ) { if(! ZoneList_ReadNameByIndex( i, sz20 ) ) // oops.. shouldn't have reached the last item yet ! { break; } if( i == pSL->current_item ) // this is the CURRENTLY ACTIVE zone : { cRadio = 0x02; // character code for a 'selected radio button', see applet/src/font_8_8.c } else { cRadio = 0x01; // character code for 'unselected radio button' } if( i == pSL->focused_item ) { sel_flags = SEL_FLAG_FOCUSED; # if( CONFIG_MORSE_OUTPUT ) // Announcement of the CURRENTLY FOCUSED item for the Morse generator: sprintf( pMenu->sz40MorseTextFromFocusedLine, "\x09zone %d\x10%s",i+1, sz20 ); // '\x09' = space and lower pitch (kind of 'highlight'), // '\x10' = space and back to the normal CW pitch (tone). # endif } else if( i == pSL->current_item ) // this is the CURRENTLY ACTIVE zone : { sel_flags = SEL_FLAG_CURRENT; // additional highlighting (besides the selected button) } else { sel_flags = SEL_FLAG_NONE; } Menu_GetColours( sel_flags, &dc.fg_color, &dc.bg_color ); dc.x = 0; dc.font = LCD_OPT_FONT_8x16; LCD_Printf( &dc, " " ); dc.font = LCD_OPT_FONT_16x16; // ex: codepage 437, but the useless smileys are radio buttons now, // to imitate Tytera's zone list (at least a bit) ! LCD_Printf( &dc, "%c", cRadio ); // 16*16 pixels for a circle, not a crumpled egg dc.font = LCD_OPT_FONT_8x16; LCD_Printf( &dc, " %02d %s\r", i+1, sz20 ); // '\r' clears to the end of the line, '\n' doesn't i++; n_visible_items++; } // If necessary, fill the rest of the screen (at the bottom) with the background colour: Menu_GetColours( SEL_FLAG_NONE, &dc.fg_color, &dc.bg_color ); LCD_FillRect( 0, dc.y, LCD_SCREEN_WIDTH-1, LCD_SCREEN_HEIGHT-1, dc.bg_color ); pMenu->redraw = FALSE; // "done" (screen has been redrawn).. except: if( n_visible_items > pSL->n_visible_items ) // more items visible than initially assumed ? { pSL->n_visible_items = n_visible_items; // adapt parameters for the scrollbar, pMenu->redraw = ScrollList_AutoScroll( pSL ); // and redraw everything (KISS) } } // ZoneList_Draw()
void GUIMONO_DispChar(U16P c) { int c0, c1; U8 * pd; int x = GUI_Context.DispPosX; int y = GUI_Context.DispPosY; /* do some checking if drawing is actually necessary ... */ const GUI_FONT_MONO* pMono = GUI_Context.pAFont->p.pMono; unsigned int FirstChar = pMono->FirstChar; /* translate character into 2 characters to display : c0,c1 Check if regular character first. */ if ((c >= (U16P)FirstChar) &&(c <= (U16P)pMono->LastChar)) { pd = (U8*)pMono->pData; c0 = ((int)c) - FirstChar; c1 = -1; } else { /* Check if character is in translation table */ GUI_FONT_TRANSINFO const* pti = pMono->pTrans; pd = (U8*)pMono->pTransData; if (pti) { FirstChar = pti->FirstChar; if ((c >= (U16P)FirstChar) && (c <= (U16P)pti->LastChar)) { GUI_FONT_TRANSLIST const* ptl; c -= pti->FirstChar; ptl = pti->pList; ptl += c; c0 = ptl->c0; c1 = ptl->c1; } else { c0 = c1 = -1; } } else { c0 = c1 = -1; } } /* Draw first character if it is valid */ if (c0!=-1) { int BytesPerChar = GUI_Context.pAFont->YSize*pMono->BytesPerLine; GUI_DRAWMODE DrawMode; int XSize = pMono->XSize; int YSize = GUI_Context.pAFont->YSize; /* Select the right drawing mode */ DrawMode = GUI_Context.TextMode; /* call drawing routine */ { U8 OldMode = LCD_SetDrawMode(DrawMode); LCD_DrawBitmap( x, y, XSize, YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, /* Bits per Pixel */ pMono->BytesPerLine, pd + c0* BytesPerChar, &LCD_BKCOLORINDEX ); if (c1 != -1) { LCD_SetDrawMode(DrawMode | LCD_DRAWMODE_TRANS); LCD_DrawBitmap( x, y, XSize, YSize, GUI_Context.pAFont->XMag, GUI_Context.pAFont->YMag, 1, /* Bits per Pixel */ pMono->BytesPerLine, pd + c1* BytesPerChar, &LCD_BKCOLORINDEX ); } /* Fill empty pixel lines */ if (GUI_Context.pAFont->YDist > GUI_Context.pAFont->YSize) { int YMag = GUI_Context.pAFont->YMag; int YDist = GUI_Context.pAFont->YDist * YMag; int YSize = GUI_Context.pAFont->YSize * YMag; if (DrawMode != LCD_DRAWMODE_TRANS) { LCD_SetDrawMode(DrawMode ^ LCD_DRAWMODE_REV); /* Reverse so we can fill with BkColor */ LCD_FillRect(x, y + YSize, x + XSize, y + YDist); } } LCD_SetDrawMode(OldMode); } } GUI_Context.DispPosX+=pMono->XDist; }
void GUI_DrawLabelHelper(u16 obj_x, u16 obj_y, u16 obj_w, u16 obj_h, const char *str, const struct LabelDesc *desc, u8 is_selected) { u16 txt_w, txt_h; u16 txt_x, txt_y; u16 offset = (LCD_DEPTH > 1 && desc->font==NARROW_FONT.font) ? 1 : 0; LCD_SetFont(desc->font); LCD_GetStringDimensions((const u8 *)str, &txt_w, &txt_h); txt_w++; if (obj_w == 0) obj_w = txt_w; if (obj_h == 0) obj_h = txt_h; if (offset && obj_y >= offset) { obj_y -= offset; } if (desc->style != LABEL_TRANSPARENT) { GUI_DrawBackground(obj_x, obj_y, obj_w, obj_h); } if (desc->style == LABEL_BOX || desc->style == LABEL_BRACKET || desc->style == LABEL_SQUAREBOX) { // draw round rect for the textsel widget when it is pressable if (is_selected) { if (desc->style == LABEL_SQUAREBOX ||obj_w < 5) LCD_FillRect(obj_x, obj_y, obj_w, obj_h , 1); else LCD_FillRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1); } else { if (desc->style == LABEL_SQUAREBOX) if (desc->fill_color == 0) LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, 1); else LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color); else if (desc->style == LABEL_BRACKET) { struct pos { int i1; int i2; int i3; int i4;}; struct { union { int p[4]; struct pos pos;} u;} x[2], y[2]; //int x[2][4]; //int y[2][4]; if (obj_h > 2 * obj_w) { x[0].u.pos = (struct pos){ 0, 2, obj_w -3, obj_w -1}; y[0].u.pos = (struct pos){ 2, 0, 0, 2}; x[1].u.pos = x[0].u.pos; y[1].u.pos = (struct pos){ obj_h -3, obj_h -1, obj_h -1, obj_h -3}; } else { x[0].u.pos = (struct pos){ 2, 0, 0, 2}; y[0].u.pos = (struct pos){ 0, 2, obj_h -3, obj_h -1}; x[1].u.pos = (struct pos){ obj_w -3, obj_w -1, obj_w -1, obj_w -3}; y[1].u.pos = y[0].u.pos; } for(int oc = 0; oc < 2; oc++) { for(int i = 0; i < 3; i++) { LCD_DrawLine(obj_x + x[oc].u.p[i], obj_y+y[oc].u.p[i], obj_x+x[oc].u.p[i+1], obj_y + y[oc].u.p[i+1], 1); } } } else LCD_DrawRoundRect(obj_x, obj_y, obj_w, obj_h , 3, 1); } } else if (desc->style == LABEL_FILL) { LCD_FillRect(obj_x, obj_y, obj_w, obj_h, desc->fill_color); } else if (desc->style == LABEL_INVERTED || is_selected) { LCD_FillRect(obj_x, obj_y, obj_w, obj_h, 0xffff); } if (desc->style == LABEL_TRANSPARENT || (LCD_DEPTH > 1 && desc->fill_color != desc->outline_color)) { LCD_DrawRect(obj_x, obj_y, obj_w, obj_h, desc->outline_color); obj_x+=2; obj_w-=4; } if (desc->style == LABEL_RIGHT) { txt_x = obj_x + obj_w - txt_w; } else if (obj_w > txt_w && !(desc->style == LABEL_LEFT || desc->style == LABEL_NO_BOX || desc->style == LABEL_UNDERLINE)) { txt_x = obj_x+1 + (obj_w - txt_w + 1) / 2; } else { txt_x = obj_x+1; } txt_y = obj_y + offset + (obj_h - txt_h + 1) / 2; if (desc->style == LABEL_UNDERLINE) { LCD_DrawFastHLine(--txt_x, txt_y + txt_h - 1, obj_w, 1); } if (desc->style == LABEL_BLINK) { blink_fontcolor = ~blink_fontcolor; LCD_SetFontColor(blink_fontcolor); } else if (desc->style == LABEL_INVERTED || (desc->style != LABEL_FILL && is_selected)) { LCD_SetFontColor(~desc->font_color); } else { LCD_SetFontColor(desc->font_color); } LCD_PrintStringXY(txt_x, txt_y, str); }
void LCD_DrawWindowedImageFromFile(u16 x, u16 y, const char *file, s16 w, s16 h, u16 x_off, u16 y_off) { u16 i, j; FILE *fh; u8 transparent = 0; u8 row_has_transparency = 0; (void)row_has_transparency; u8 buf[480 * 2]; if (w == 0 || h == 0) return; fh = fopen(file, "rb"); if(! fh) { printf("DEBUG: LCD_DrawWindowedImageFromFile: Image not found: %s\n", file); if (w > 0 && h > 0) LCD_FillRect(x, y, w, h, 0); return; } setbuf(fh, 0); u32 img_w, img_h, offset, compression; if(fread(buf, 0x46, 1, fh) != 1 || buf[0] != 'B' || buf[1] != 'M') { fclose(fh); printf("DEBUG: LCD_DrawWindowedImageFromFile: Buffer read issue?\n"); return; } compression = *((u32 *)(buf + 0x1e)); if(*((u16 *)(buf + 0x1a)) != 1 /* 1 plane */ || *((u16 *)(buf + 0x1c)) != 16 /* 16bpp */ || (compression != 0 && compression != 3) /* BI_RGB or BI_BITFIELDS */ ) { fclose(fh); printf("DEBUG: LCD_DrawWindowedImageFromFile: BMP Format not correct\n"); return; } if(compression == 3) { if(*((u16 *)(buf + 0x36)) == 0x7c00 && *((u16 *)(buf + 0x3a)) == 0x03e0 && *((u16 *)(buf + 0x3e)) == 0x001f && *((u16 *)(buf + 0x42)) == 0x8000) { transparent = 1; } else if(*((u16 *)(buf + 0x36)) != 0xf800 || *((u16 *)(buf + 0x3a)) != 0x07e0 || *((u16 *)(buf + 0x3e)) != 0x001f) { fclose(fh); printf("DEBUG: LCD_DrawWindowedImageFromFile: BMP Format not correct second check\n"); return; } } offset = *((u32 *)(buf + 0x0a)); img_w = *((u32 *)(buf + 0x12)); img_h = *((u32 *)(buf + 0x16)); if(w < 0) w = img_w; if(h < 0) h = img_h; if((u16)w + x_off > img_w || (u16)h + y_off > img_h) { printf("DEBUG: LCD_DrawWindowedImageFromFile: Dimensions asked for are out of bounds\n"); printf("size: (%d x %d) bounds(%d x %d)\n", (u16)img_w, (u16)img_h, (u16)(w + x_off), (u16)(h + y_off)); fclose(fh); return; } offset += (img_w * (img_h - (y_off + h)) + x_off) * 2; fseek(fh, offset, SEEK_SET); LCD_DrawStart(x, y, x + w - 1, y + h - 1, DRAW_SWNE); /* Bitmap start is at lower-left corner */ for (j = 0; j < h; j++) { if (fread(buf, 2 * w, 1, fh) != 1) break; u16 *color = (u16 *)buf; if(transparent) { #ifdef TRANSPARENT_COLOR //Display supports a transparent color for (i = 0; i < w; i++ ) { u32 c; if((*color & 0x8000)) { //convert 1555 -> 565 c = ((*color & 0x7fe0) << 1) | (*color & 0x1f); } else { c = TRANSPARENT_COLOR; } LCD_DrawPixel(c); color++; } #else u8 last_pixel_transparent = row_has_transparency; row_has_transparency = 0; for (i = 0; i < w; i++ ) { if((*color & 0x8000)) { //convert 1555 -> 565 u16 c = ((*color & 0x7fe0) << 1) | (*color & 0x1f); if(last_pixel_transparent) { LCD_DrawPixelXY(x + i, y + h - j - 1, c); last_pixel_transparent = 0; } else { LCD_DrawPixel(c); } } else { //When we see a transparent pixel, the next real pixel // will need to be drawn with XY coordinates row_has_transparency = 1; last_pixel_transparent = 1; } color++; } #endif } else { for (i = 0; i < w; i++ ) { if (LCD_DEPTH == 1) *color = (*color & 0x8410) == 0x8410 ? 0 : 0xffff; LCD_DrawPixel(*color++); } } if((u16)w < img_w) { fseek(fh, 2 * (img_w - w), SEEK_CUR); } } LCD_DrawStop(); fclose(fh); }
void GUI_DrawXYGraph(struct guiObject *obj) { struct guiBox *box = &obj->box; struct guiXYGraph *graph = (struct guiXYGraph *)obj; u32 x, y; #define VAL_TO_X(xval) \ (u32)(box->x + (((s32)(xval)) - graph->min_x) * box->width / (1 + graph->max_x - graph->min_x)) #define VAL_TO_Y(yval) \ (u32)(box->y + box->height - (((s32)(yval)) - graph->min_y) * box->height / (1 + graph->max_y - graph->min_y)) _GUI_DrawMappedStart(); _GUI_ClearMappedBox(box, Display.xygraph.bg_color); if (graph->grid_x) { int xval; for (xval = graph->min_x + graph->grid_x; xval < graph->max_x; xval += graph->grid_x) { if (! xval) continue; x = VAL_TO_X(xval); //LCD_DrawDashedVLine(x, box->y, box->height, 5, RGB888_to_RGB565(0x30, 0x30, 0x30)); LCD_DrawFastVLine(x, box->y, box->height, Display.xygraph.grid_color); } } if (graph->grid_y) { int yval; for (yval = graph->min_y + graph->grid_y; yval < graph->max_y; yval += graph->grid_y) { if (! yval) continue; y = VAL_TO_Y(yval); //LCD_DrawDashedHLine(box->x, y, box->width, 5, RGB888_to_RGB565(0x30, 0x30, 0x30)); LCD_DrawFastHLine(box->x, y, box->width, Display.xygraph.grid_color); } } if (graph->min_x < 0 && graph->max_x > 0) { int x = box->x + box->width * (0 - graph->min_x) / (graph->max_x - graph->min_x); LCD_DrawFastVLine(x, box->y, box->height, Display.xygraph.axis_color); } if (graph->min_y < 0 && graph->max_y > 0) { y = box->y + box->height - box->height * (0 - graph->min_y) / (graph->max_y - graph->min_y); LCD_DrawFastHLine(box->x, y, box->width, Display.xygraph.axis_color); } u16 lastx = box->x; u16 lasty = box->y + box->height -1; LCD_DrawStart(box->x, box->y, box->x + box->width - 1, box->y + box->height - 1, DRAW_NWSE); for (x = 0; x < box->width; x++) { s32 xval, yval; xval = graph->min_x + x * (1 + graph->max_x - graph->min_x) / box->width; yval = graph->CallBack(xval, graph->cb_data); y = (yval - graph->min_y) * box->height / (1 + graph->max_y - graph->min_y); //printf("(%d, %d - %d, %d) -> (%d, %d)\n", // (int)lastx, (int)lasty, (int)x, (int)y, (int)xval, (int)yval); if (x != 0) { LCD_DrawLine(lastx, lasty, x + box->x, box->y + box->height - y - 1, Display.xygraph.fg_color); //Yellow } lastx = x + box->x; lasty = box->y + box->height - y - 1; } LCD_DrawStop(); if (graph->point_cb) { u8 pos = 0; s16 xval, yval; while (graph->point_cb(&xval, &yval, pos++, graph->cb_data)) { s16 x1 = VAL_TO_X(xval); s16 y1 = VAL_TO_Y(yval); s16 x2 = x1 + 2; s16 y2 = y1 + 2; //bounds check x1 = ( x1 < 2 + box->x) ? box->x : x1 - 2; y1 = ( y1 < 2 + box->y) ? box->y : y1 - 2; if ( x2 >= box->x + box->width) x2 = box->x + box->width - 1; if ( y2 >= box->y + box->height) y2 = box->y + box->height - 1; LCD_FillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, Display.xygraph.point_color); } } if(Display.xygraph.outline_color != Display.xygraph.bg_color) LCD_DrawRect(box->x, box->y, box->width, box->height, Display.xygraph.outline_color); _GUI_DrawMappedStop(); }
void GUI_Release(){ // create GUI static int i, j; //indexes //if z-index == 0 eq hide for(j = 1; j < MAX_Z_INDEX; j++ ){ for(i = 0; i < MAX_OBJECTS_Q; i++){ if(GUI_Objects[i].z_index == j){ if(GUI_Objects[i].existance){ LCD_SetColorPixel(GUI_Objects[i].color); // set the font, color of font and the color of line switch(GUI_Objects[i].type){ case LINE_TYPE: LCD_DrawLine(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2], GUI_Objects[i].params[3]); break; case VERTICAL_LINE_TYPE: break; case HORIZONTAL_LINE_TYPE: DrawFastLineHorizontal(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]); break; case POLYGON_TYPE: break; case TEXT_STRING: LCD_InitParams(0, GUI_Objects[i].params[6], GUI_Objects[i].color, (sFONT*) GUI_Objects[i].params[5]); LCD_DisplayStringAt(GUI_Objects[i].params[0], GUI_Objects[i].params[1], (uint8_t*)GUI_Objects[i].params[2], (Text_AlignModeTypdef) GUI_Objects[i].params[3], (uint8_t)GUI_Objects[i].params[4]); break; case CIRCLE_TYPE: LCD_DrawCircle(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]); break; case FILLED_CIRCLE_TYPE: LCD_DrawFullCircle(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]); break; case FILLED_RECT_TYPE: LCD_FillRect(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2], GUI_Objects[i].params[3]); break; case RECT_TYPE: LCD_DrawRect((uint16_t)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1], (uint16_t)GUI_Objects[i].params[2], (uint16_t)GUI_Objects[i].params[3]); break; case IMAGE_FAST_FILL: LCD_Fill_Image((ImageInfo *)GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]); break; case IMAGE_WITH_TRANSP: LCD_Fill_ImageTRANSP((ImageInfo *)GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2]); break; case FILLED_TRIANGLE: LCD_FillTriangle(GUI_Objects[i].params[0], GUI_Objects[i].params[1], GUI_Objects[i].params[2], GUI_Objects[i].params[3], GUI_Objects[i].params[4], GUI_Objects[i].params[5]); break; case FILLED_POLY: LCD_FillPolygon((pPoint)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1]); break; case POLY_TYPE: LCD_DrawPolygon((pPoint)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1]); break; case ROTATING_FILLED_POLY_TYPE: StorePoly((pPoint)(GUI_Objects[i].params[0]),(uint16_t)(GUI_Objects[i].params[1])); RotatePoly((pPoint)(GUI_Objects[i].params[0]), (uint16_t)(GUI_Objects[i].params[1]),(pPoint)GUI_Objects[i].params[2], GUI_Objects[i].params[3]); LCD_FillPolygon((pPoint)GUI_Objects[i].params[0], (uint16_t)GUI_Objects[i].params[1]); RestorePoly((pPoint)(GUI_Objects[i].params[0]),(uint16_t)(GUI_Objects[i].params[1])); break; } } } } } }
/********************************************************************* * * _DrawBitmap */ static void _DrawBitmap(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag, tLCDDEV_Index2Color * pfIndex2Color) { const U32 * pData; int y, OldIndex, Mag, BytesPerLine, UseDrawBitmap = 0; U32 PrevColor; GUI_USE_PARA(pLogPal); OldIndex = LCD_GetColorIndex(); PrevColor = GUI_INVALID_COLOR; pData = (const U32 *)pPixel; Mag = (xMag | yMag); BytesPerLine = xsize * 4; /* Check if bitmaps color format fits to the current color conversion */ if (Mag == 1) { #if GUI_SUPPORT_MEMDEV if (!GUI_Context.hDevData) { #else { #endif if (LCD_GetpfIndex2ColorEx(GUI_Context.SelLayer) == pfIndex2Color) { UseDrawBitmap = 1; } } } if (UseDrawBitmap) { LCD_DrawBitmap(x0, y0, xsize, ysize, 1, 1, 24, BytesPerLine, pPixel, 0); } else { if (Mag == 1) { /* Perform clipping */ int x1, y1, Diff; y1 = y0 + ysize - 1; x1 = x0 + xsize - 1; /* Clip Y */ if (y0 < GUI_Context.ClipRect.y0) { Diff = GUI_Context.ClipRect.y0 - y0; y0 = GUI_Context.ClipRect.y0; #if GUI_SUPPORT_LARGE_BITMAPS /* Required only for 16 bit CPUs if some bitmaps are >64kByte */ pData += (U32)Diff * (U32)BytesPerLine / 4; #else pData += (unsigned)Diff * (unsigned)BytesPerLine / 4; #endif ysize -= Diff; } Diff = y1 - GUI_Context.ClipRect.y1; if (Diff > 0) { ysize -= Diff; } if (ysize <=0) { return; } /* Clip right side */ Diff = x1 - GUI_Context.ClipRect.x1; if (Diff > 0) { xsize -= Diff; } /* Clip left side */ if (x0 < GUI_Context.ClipRect.x0) { Diff = GUI_Context.ClipRect.x0 - x0; xsize -= Diff; pData += Diff; x0 += Diff; } if (xsize <=0) { return; } /* Simple, unmagnified output using LCD_L0_SetPixel() */ for (y = 0; y < ysize; y++) { int x; const U32 * p = pData; for (x = 0; x < xsize; x++) { U32 Color; Color = *p++; if (Color != PrevColor) { LCD_SetColor(pfIndex2Color(Color)); PrevColor = Color; } LCDDEV_L0_SetPixelIndex(x + x0, y + y0, LCD_COLORINDEX); } pData += BytesPerLine / 4; } } else { /* Magnified output using LCD_FillRect() */ int x,y; int yi; for (y = y0, yi = 0; yi < ysize; yi++, y += yMag, pPixel += BytesPerLine) { int yMax; yMax = y + yMag - 1; /* Draw if within clip area */ if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) { int xi; const U32 GUI_UNI_PTR * p = pData; for (x = x0, xi = 0; xi < xsize; xi++, x += xMag) { U32 Color; Color = *p++; if (Color != PrevColor) { LCD_SetColor(pfIndex2Color(Color)); PrevColor = Color; } LCD_FillRect(x, y, x + xMag - 1, yMax); } } pData += BytesPerLine / 4; } } GUI_SetColorIndex(OldIndex); } } /********************************************************************* * * _DrawBitmap_565 */ static void _DrawBitmap_888(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) { _DrawBitmap(x0, y0, xsize, ysize, pPixel, pLogPal, xMag, yMag, GUI_BitmapMethods888.pfIndex2Color); }
void _gui_draw_background(int x, int y, int w, int h) { LCD_FillRect(x, y, w, h, 0x0); // clear the area }
void LCD_ClearScreen () { // we can use the fillrect function LCD_FillRect(0,0,LCD_Width()-1, LCD_Height()-1, background); }