⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于uc/gui的GPS/GPRS应用实例
💻 C
字号:
//=============================================
//串口发送地图到ARM,LCD 显示地图程序,调试通过
// 2004-8-5
//=============================================
/******************************
 * success to send a map     
 * 
******************************/

#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
#include "stdio.h"
#include "stdlib.h"

#include "GUI.H"
#include "WM.h"

extern const GUI_BITMAP bmucdragon;
extern const GUI_BITMAP bmgg;

extern const GUI_BITMAP bm1;
extern const GUI_BITMAP bm2;
extern const GUI_BITMAP bm3;
extern const GUI_BITMAP bm4;
extern const GUI_BITMAP bm5;
extern const GUI_BITMAP bm6;
extern const GUI_BITMAP bm7;
extern const GUI_BITMAP bm8;


/**********************************************************************
 *	main loop
 **********************************************************************/
void Main(void)
{  
  // U16 i,k;
 // U8 Mapbuf[2000]; 

 // U16 n,j,k,Type,Group,Num,HZ_num,IconNo,times=1;
 // S8 Z[3],HZ[60];
 // U8 Z1[3],HZ1[60];
 // GUI_POINT point[500];
 //   GROUPFACE Color;
 // U8 DotNameLoca,FontSize, DoubleRow;
  

/************/
    S8 aa;
    S8 *pstring;
    S32 num1,num2;
    U16 i,k,k1,k2;

    S32 Kinds,TypeCode,DotNumber,HZ_Number,HZ_Code;
    S8 *MapvStr;

    U32  FrameLineColor,FilledColor;
    S32  DotLocal,HZ_FontSize,DoubleRow;
   
    GUI_POINT point[500]; //memory the value of poly
    
    char string[]={0x03,0x00,0x04,0x00,0x00,0xff,0x00,0xff,0x00,
                            0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
                            0x00,0x01,0x30,0x00,0x00,0x00,0x30,0x00,0x00,'\0'};
   // char *s="12345"; /* ok */
   //char s[]={'1','1','1','1','1'} ; /*ok s is a string==== 'char'==== */
   // U32 color=0x00ff00; /*ok*/  
  /*  struct {
             GUI_POINT HZ_Local[60];
             U16 Z_Code[];
            }HZ_Point[60];
    */
   
    S8 Z[3],HZString[60];
/****************/


		
   rSYSCFG=CACHECFG;   // Using 8KB Cache//

   Port_Init();
   Uart_Init(0,57600);
   Delay(1000);
   Uart_Select(0); //Select UART0
    	
   GUI_Init(); 

   while(1)
    {
/*      GUI_Clear();
      GUI_DrawBitmap(&bmgg,0,0);
      WaitKey();
*/

      GUI_Clear();
      GUI_SetBkColor(GUI_BACKGROUND);
      GUI_SetColor(GUI_RED);
      GUI_SetFont(&GUI_Font_HZK16);
      GUI_DispString("\n\n你好,GPS世界!");
      GUI_DispString("\n\n广州信风通信技术有限公司");
      GUI_DispString("\n\nGPS车辆定位系统");
      GUI_DispString("\n\nGIS网络平台系统");
      GUI_DispString("\n\nKjava电子地图系统");
      
/**********send a stirngs successly *********/
/**********saved in the string of pstring,end of byte '\\\' ********/
  Uart_Printf("\n  Send data:");
  Delay(10);

  num1=0;
 // pstring=malloc(2185);
  MapvStr=malloc(1743);
  if(!MapvStr)
  {
   Uart_Printf("Allocation Error\n");
   exit(0); 
  }
 
  while(num1<1742)
    {
     aa=Uart_Getch();
     *(MapvStr+num1)=aa;
     num1++;  
    } 
  
     *(MapvStr+num1)='\0';
    // rewind(MapvStr);

  //   Uart_Printf("\n The data you have Sended:");
    Uart_Printf("\n");

    for (num2=0; num2<num1-2;num2++ ) 
        Uart_SendByte(MapvStr[num2]);
    Delay(100);

   // free(MapvStr);


/* ************ ********** */

//  WaitKey();

  Delay(10);
  GUI_SetPenSize(1);
  GUI_Clear();
  GUI_SetBkColor(GUI_BACKGROUND);
 // GUI_SetColor(atoi(FilledColor));
  
 while(1)
  {
    
    Kinds=*MapvStr++;                     
   

   if(Kinds==0x03)
   {  
       TypeCode=*MapvStr++; 
       DotNumber=*MapvStr++;

       k=*MapvStr++;
       k1=*MapvStr++;
       k2=*MapvStr++;
       FrameLineColor=k+256*k1+256*256*k2;

       k=*MapvStr++;
       k1=*MapvStr++;
       k2=*MapvStr++;
       FilledColor=k+256*k1+256*256*k2;

       for(i=0;i<DotNumber;i++)
                { k=*MapvStr++;  point[i].x = *MapvStr++;
                  point[i].x = k + 256*point[i].x;   

                  k=*MapvStr++;  point[i].y = *MapvStr++;
                  point[i].y = k + 256*point[i].y;

  
                /*  if(point[i].x>0x0140)
                    { 
                      point[i].x=point[i].x-0x0140-1;
                    }
                  if(point[i].y>0x00e6)
                    { 
                      point[i].y=point[i].x-0x00e6-1;
                    } */
                }
       
        GUI_SetColor(FilledColor);
        GUI_FillPolygon(point, DotNumber, 0, 0);

        GUI_SetColor(FrameLineColor);
        GUI_DrawPolyLine(point, DotNumber, 0, 0);
         
        HZ_Number=*MapvStr++;
        if(HZ_Number>0)
           { 
              for(i=0;i<HZ_Number;i++)
                { k=*MapvStr++;  point[i].x = *MapvStr++;
                  point[i].x = k + 256*point[i].x;   

                  k=*MapvStr++;  point[i].y = *MapvStr++;
                  point[i].y = k + 256*point[i].y;
                  Z[0]= *MapvStr++;  Z[1]= *MapvStr++; Z[2]='\0';

                  GUI_SetColor(GUI_BLACK);
                  GUI_DispStringAt(Z,point[i].x,point[i].y); 

               }

            }
          
        
   }

   if(Kinds==0x002)
   {
      TypeCode=*MapvStr++;
      DotNumber=*MapvStr++;
   
      for(i=0;i<DotNumber;i++)
         { k=*MapvStr++;  point[i].x = *MapvStr++;
           point[i].x = k + 256*point[i].x;   
           k=*MapvStr++;  point[i].y = *MapvStr++;
           point[i].y = k + 256*point[i].y;
         }
      GUI_SetColor(GUI_GREEN);
      GUI_DrawPolyLine(point, DotNumber, 0, 0);

      HZ_Number=*MapvStr++;      
      for(i=0;i<HZ_Number;i++)
              { k=*MapvStr++;  point[i].x = *MapvStr++;
                point[i].x = k + 256*point[i].x;   

                k=*MapvStr++;  point[i].y = *MapvStr++;
                point[i].y = k + 256*point[i].y;
                Z[0]= *MapvStr++;  Z[1]= *MapvStr++;// Z[2]='\0';
   
  
                GUI_SetColor(GUI_BLACK);
                GUI_DispStringAt(Z,point[i].x,point[i].y); 

               }

   }
 

   if(Kinds==0x01)
   {
     TypeCode=*MapvStr++;
     DotLocal=*MapvStr++;
     HZ_FontSize=*MapvStr++;
     DoubleRow=*MapvStr++;
     
 
      k=*MapvStr++;
      point[0].x = *MapvStr++;
      point[0].x = k + 256*point[0].x;
      k=*MapvStr++;
      point[0].y = *MapvStr++;
      point[0].y = k + 256*point[0].y;
    
 
      HZ_Number=*MapvStr++; 
      memcpy(HZString,MapvStr,HZ_Number);
      HZString[HZ_Number]='\0';
      MapvStr += HZ_Number;
     
      GUI_SetColor(GUI_BLACK);
      GUI_DispStringAt(HZString,point[0].x,point[0].y);

 
      if(DoubleRow) 
      { 
       
      }

   }
   
   if((*MapvStr)==NULL) break;
}
  
  free(MapvStr);
 // free(pstring);

/********
      GUI_SetPenSize(1);
      GUI_Clear();
      GUI_SetBkColor(GUI_BACKGROUND);
      GUI_SetColor(GUI_GRAY);
      GUI_FillPolygon(aPoints29, 4, 0, 0);
      GUI_SetColor(GUI_YELLOW);
      GUI_DrawPolyLine(aPoints29, 5, 0, 0);
      GUI_SetColor(GUI_GREEN);
      GUI_FillPolygon(bPoints, 3, 0, 0);
      GUI_SetColor(GUI_BLUE);
      GUI_FillPolygon(bPoints3, 13, 0, 0);
      GUI_SetColor(GUI_WHITE);
      GUI_FillPolygon(bPoints4, 12, 0, 0);
      GUI_FillPolygon(bPoints5, 10, 0, 0);
      GUI_SetColor(GUI_GRAY);
      GUI_DrawPolyLine(cPoints, 2, 0, 0);
      GUI_SetColor(GUI_RED);
      GUI_SetPenSize(3);
      GUI_DrawPolyLine(cPoints6, 3, 0, 0);
      GUI_SetColor(GUI_GRAY);
      GUI_SetPenSize(5);
      GUI_DrawPolyLine(cPoints7, 4, 0, 0);
      GUI_SetColor(GUI_RED);
      GUI_SetPenSize(3);
      GUI_DrawPolyLine(cPoints7, 4, 0, 0);
      GUI_SetColor(GUI_BLACK);
      GUI_DrawBitmap(&bm7,141,232);
      GUI_DispStringAt("广州腾辉汽修厂",141,232); 
*/
      WaitKey();

   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -