예제 #1
0
//在指定位置显示加载到RAM中的PNG图片(PNG图片不能缩放!)
//PNGFileName:图片在SD卡或者其他存储设备中的路径(需文件系统支持!)
//mode:显示模式
//		0 在指定位置显示,有参数x,y确定显示位置
//		1 在LCD中间显示图片,当选择此模式的时候参数x,y无效。
//x:图片左上角在LCD中的x轴位置(当参数mode为1时,此参数无效)
//y:图片左上角在LCD中的y轴位置(当参数mode为1时,此参数无效)
//返回值:0 显示正常,其他 失败
int displaypng(char *PNGFileName,U8 mode,U32 x,U32 y)
{
	U16 bread;
	char *pngbuffer;
	char result;
	int XSize,YSize;
	
	#if SYSTEM_SUPPORT_OS
		CPU_SR_ALLOC();
	#endif

	result = f_open(&PNGFile,(const TCHAR*)PNGFileName,FA_READ);	//打开文件
	//文件打开错误或者文件大于JPEGMEMORYSIZE
	if((result != FR_OK) || (PNGFile.fsize>PNGMEMORYSIZE)) 	return 1;

	pngbuffer=mymalloc(SRAMEX,PNGFile.fsize);
	if(pngbuffer == NULL) return 2;
	
	#if SYSTEM_SUPPORT_OS
		OS_CRITICAL_ENTER();	//临界区
	#endif
		
	result = f_read(&PNGFile,pngbuffer,PNGFile.fsize,(UINT *)&bread); //读取数据
	f_close(&PNGFile);		//关闭PNGFile文件
	if(result != FR_OK) return 3;
		
	#if SYSTEM_SUPPORT_OS
		OS_CRITICAL_EXIT();	//退出临界区
	#endif
	
	XSize = GUI_PNG_GetXSize(pngbuffer,PNGFile.fsize);	//获取PNG图片的X轴大小
	YSize = GUI_PNG_GetYSize(pngbuffer,PNGFile.fsize);	//获取PNG图片的Y轴大小
	switch(mode)
	{
		case 0:	//在指定位置显示图片
			GUI_PNG_Draw(pngbuffer,PNGFile.fsize,x,y);//显示PNG图片
			break;
		case 1:	//在LCD中间显示图片
			GUI_PNG_Draw(pngbuffer,PNGFile.fsize,(LCD_GetXSize()-XSize)/2-1,(LCD_GetYSize()-YSize)/2-1);	
			break;
	}

	myfree(SRAMEX,pngbuffer);
	return 0;
}
예제 #2
0
파일: mainwin.c 프로젝트: zkan51/NEVTEX
/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
	
	WM_HWIN hWin;
	WM_HWIN hText;
	const WM_KEY_INFO* pInfo;
	WM_HWIN  hItem  = 0;
  int     i  = 0;
  int     NCode;
  int     Id;
	hWin = pMsg->hWin;
  // USER START (Optionally insert additional variables)
  // USER END
  switch (pMsg->MsgId) 
	{
		  case USER_MSG_LANGUAGE:
					    InfoSel(0,1);
					    break;
				case WM_PAINT:
									GUI_SetBkColor(GUI_WHITE);
									GUI_Clear();
									GUI_SetColor(GUI_BLACK);
									GUI_AA_DrawLine(190,0,220,60);
									GUI_AA_DrawLine(220,60,800,60);
// 				     if (Language == 0)
// 									{
// 									   GUI_DispStringAt("所处      页/共      页",560,435);	
// 									}
// 									else
// 									{
//   										GUI_DispStringAt (pLanguage->Page,560,435);
// 									}
// 										 	GUI_DispDecAt(thispage,605,435,3);
// 							   		GUI_DispDecAt(pageNum,700,435,3);
									//GUI_DispStringAt("高电压警告",230,28);
				     GUI_PNG_Draw(&acPOWER,sizeof(acPOWER),755,35);

									break;
		
		case WM_INIT_DIALOG:
			
			    pLanguage = &Lgumainwin[Language];
							hButton = WM_GetDialogItem (hWin,ID_BUTTON_0);
							BUTTON_SetBkColor (hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);
							BUTTON_SetTextColor (hButton,BUTTON_CI_UNPRESSED,GUI_BLACK);
							BUTTON_SetTextAlign (hButton,GUI_TA_HCENTER|GUI_TA_VCENTER);
							BUTTON_SetText(hButton,pLanguage->ButtonInfo[0]);
							BUTTON_SetFocusColor (hButton,GUI_WHITE);
							WIDGET_SetEffect (hButton,&WIDGET_Effect_None);
							WM_SetCallback (hButton,&mybutton);
							WM_SetFocus (hButton);
							hListview = WM_GetDialogItem (hWin,ID_LV_0);
							hListhead = LISTVIEW_GetHeader(hListview);
							LISTVIEW_SetFont(hListview,&GUI_Font30);
							LISTVIEW_SetRowHeight(hListview,40);
							LISTVIEW_SetHeaderHeight(hListview,30);
							LISTVIEW_SetBkColor (hListview,LISTVIEW_CI_SELFOCUS,GUI_GRAY);
							LISTVIEW_SetBkColor (hListview,LISTVIEW_CI_SEL,GUI_WHITE);
							LISTVIEW_SetTextColor (hListview,LISTVIEW_CI_SEL,GUI_BLACK);
							LISTVIEW_SetTextColor(hListview,LISTVIEW_CI_SELFOCUS,GUI_WHITE);
							WIDGET_SetEffect(hListhead,&WIDGET_Effect_3D);
							HEADER_SetBkColor (hListhead,GUI_BLACK);
							HEADER_SetTextColor(hListhead,GUI_WHITE);
							HEADER_SetFont(hListhead,&GUI_Font24);
							LISTVIEW_AddColumn(hListview,80,"序号",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_AddColumn(hListview,100,"信息编码",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_AddColumn(hListview,130,"yyy/mm/dd",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_AddColumn(hListview,90,"hh:mm",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_AddColumn(hListview,120,"频道",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_AddColumn(hListview,100,"信息类型",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_AddColumn(hListview,100,"信息状态",GUI_TA_HCENTER|GUI_TA_VCENTER);
							LISTVIEW_SetTextAlign(hListview,6,GUI_TA_LEFT|GUI_TA_VCENTER);
							
							// WM_HWIN - TEXT
							mainwinText[0] = WM_GetDialogItem(hWin,ID_TEXT_3); //高压警告
							mainwinText[1] = WM_GetDialogItem(hWin,ID_TEXT_0); //INT
							mainwinText[2] = WM_GetDialogItem(hWin,ID_TEXT_1); //loc1,loc2,chs
							mainwinText[3] = WM_GetDialogItem(hWin,ID_TEXT_2); //time
							mainwinText[4] = WM_GetDialogItem(hWin,ID_TEXT_4); //page
							
							WM_SetCallback(mainwinText[1],&mytext);
							WM_SetCallback(mainwinText[2],&mytext);			
							
							TEXT_SetText(mainwinText[0],"");
							
							TEXT_SetFont(mainwinText[4],&GUI_Font30);
							TEXT_SetTextAlign(mainwinText[4],TEXT_CF_RIGHT);
							TEXT_SetText(mainwinText[4],"所处 01页/共 02页");
							//time
							TEXT_SetTextAlign(mainwinText[3],TEXT_CF_VCENTER);
							TEXT_SetFont(mainwinText[3],&GUI_Font30);
							TEXT_SetText(mainwinText[3],"UTC 2015.10.24 17:30");
							for (i=0;	i<16; i++)
							{
									INFO_add(&TESTDATA[i]);
							}
							if (rowNum < 8)
							 	pageNum = 1;
							else if (rowNum%8 == 0)
						 		pageNum = rowNum/8;
							else pageNum = rowNum/8+1;	
							InfoSel(0,1);
							//DisPage();	 
					 	WM_SetCallback (hListview,&mylistview);
							
					  break;
						
		 default:
       WM_DefaultProc(pMsg);
       break;
	}
}
예제 #3
0
/*********************************************************************
*
*       _TileScreen
*
*  Function description
*    Fills the screen with PNG-tiles from an OpenStreetMap-server.
*    Receiving the tiles works asynchronous with non blocking sockets.
*    Tiles are requested by the following GET request:
*
*    "GET <URL of TileServer>/<Zoom factor>/<X-value>/<Y-value>.png\r\nUser-Agent: xxx\r\n\r\n"
*
*  Parameters:
*    x    - X-value for URL of tile calculated by longitude and zoom factor
*    y    - Y-value for URL of tile calculated by latitude and zoom factor
*    Zoom - A value between 1-16 where 16
*/
static void _TileScreen(int x, int y, int Zoom) {
  TILE * pTileFirst;
  TILE * pTile;
  int xSize, ySize, xPos, yPos, nx, ny, i, j, Ready;
  U32 IPAddr;

  xSize = LCD_GetXSize();
  ySize = LCD_GetYSize();
  xPos = (xSize - TILE_SIZE) / 2;
  yPos = (ySize - TILE_SIZE) / 2;
  nx = ny = 1;
  while (xPos > 0) {
    nx += 2;
    xPos -= TILE_SIZE;
    x--;
  }
  while (yPos > 0) {
    ny += 2;
    yPos -= TILE_SIZE;
    y--;
  }
  pTileFirst = NULL;
  //
  // Create list of all tiles
  //
  for (i = 0; i < nx; i++) {
    for (j = 0; j < ny; j++) {
      pTile = calloc(1, sizeof(TILE));
      if (pTileFirst == NULL) {
        pTileFirst = pTile;
      } else {
        pTile->pNext = pTileFirst;
        pTileFirst = pTile;
      }
      pTileFirst->x = x + i;
      pTileFirst->y = y + j;
      pTileFirst->Zoom = Zoom;
      pTileFirst->xPos = xPos + i * TILE_SIZE;
      pTileFirst->yPos = yPos + j * TILE_SIZE;
    }
  }
  //
  // Request and drawing of all tiles
  //
  IPAddr = _GetIPAddr(TILE_SERVER_URL);
  do {
    Ready = 1;
    for (pTile = pTileFirst; pTile; pTile = pTile->pNext) {
      if (pTile->State < STATE_DRAW) {
        //
        // Tile not available: Keep receiving
        //
        _ReceiveTile(pTile, IPAddr);
        Ready = 0;
      } else {
        if (pTile->State == STATE_DRAW) {
          //
          // Tile already received: Draw and remove
          //
          GUI_PNG_Draw(pTile->pImage, pTile->SizeOfImage, pTile->xPos, pTile->yPos);
          free(pTile->pImage);
          pTile->State = STATE_DONE;
          Ready = 0;
        }
      }
    }
  } while (Ready == 0);
  //
  // Remove tiles
  //
  while (pTileFirst) {
    pTile = pTileFirst;
    pTileFirst = pTileFirst->pNext;
    free(pTile);
  }
}