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

📄 text.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
📖 第 1 页 / 共 3 页
字号:
     i = 0;
     
     while (i<charlen) 
     {
        OutTextTinySingle(row_dot,col_dot+FONTCOL*i,*charptr++);
        i++;
     }
}
#endif

//在设定的两点间画线,线型有实线和虚线;只能画横线和直线
void Line(INT8U row1,INT8U col1,INT8U row2, INT8U col2,INT8U linemode)
{
     INT8U i;
     INT8U *ptr;

     if (CheckPixelValid(row1,col1) == FALSE) return;
     if (CheckPixelValid(row2,col2) == FALSE) return;

     leftmod_col   = col1 - (col1 >> 3 << 3);        //col1 % 8;
     leftfull_col  = col1 >> 3;                      //col1 / 8;
     rightmod_col  = col2+1 - ((col2+1) >> 3 << 3);  //(col2+1) % 8;
     rightfull_col = col2 >> 3;                      //col2 / 8;

     if (row1 == row2)                              //画的是横线
     {	                        
        ptr = GetPosAddr(DplyImagMem,row1,leftfull_col,COLSIZE);
        
        if ( linemode == LINE_COMPLETE)             //类型是实线
        {	
             for(i=leftfull_col;i<=rightfull_col;i++) 
             {
                *ptr++ = 0xff;
             }
        } 
        else                                        //类型是虚线
        {							
             for(i=leftfull_col;i<=rightfull_col;i++) 
             {
                *ptr++ = 0xaa;
             }
        }
        
        ResumeSideBytes(row1);  
     } 
     else if (col1 == col2)                        //画的是竖线
     {	
        ptr = GetPosAddr(DplyImagMem,row1,leftfull_col,COLSIZE);
       
        if (linemode == LINE_COMPLETE)             //类型是实线 
        {	       
             for (i=row1;i<=row2;i++) 
             {
                  *ptr |= (0x01<<leftmod_col);
                  ptr += COLSIZE;
             }
        } 
        else                                       //类型是虚线
        {   							       
             i=row1;

             while(i<=row2) 
             {
                 *ptr|= (0x01<<leftmod_col);
                 ptr += COLSIZE;
                 i++;
                 
                 if (i<=row2) 
                 {
                    *ptr &= ~(0x01<<leftmod_col);
                    ptr += COLSIZE;
                    i++;
                 }   
             }
        }
        
    }  
}    

//在设定的两点间画一个框体,参数shadow决定框体是否有阴影
void DrawRect(INT8U row1,INT8U col1,INT8U row2,INT8U col2,INT8U shadow)
{
     INT8U temp;
     
     if ((CheckPixelValid(row1,col1) == FALSE) || (CheckPixelValid(row2,col2) == FALSE))  {
         return ;
     }    
     if (row1 > row2) {//如果前点大于后者,作转换处理
         temp = row2;
         row2 = row1;
         row1 = temp;
     }    
     if (col1 > col2) {
         temp = col2;
         col2 = col1;
         col1 = temp;
     }
         
     Line(row1,col1,row1,col2,LINE_COMPLETE);
     Line(row2,col1,row2,col2,LINE_COMPLETE);
     Line(row1,col1,row2,col1,LINE_COMPLETE);
     Line(row1,col2,row2,col2,LINE_COMPLETE);
     
     if (shadow) 
     {
        Line(row1+2,col2+1,row2+2,col2+1,LINE_COMPLETE);
        Line(row1+4,col2+2,row2+2,col2+2,LINE_COMPLETE);
        Line(row2+1,col1+2,row2+1,col2+2,LINE_COMPLETE);
        Line(row2+2,col1+4,row2+2,col2+2,LINE_COMPLETE);
     }
}

//画箭头,用于滚动显示时指示方向。
void DrawArrow(INT8U row_dot,INT8U col_dot,INT8U direct,INT8U on_off )
{
     if (CheckPixelValid(row_dot,col_dot) == FALSE) return;
     
     switch (direct) 
     {
        case ARROW_UP:		//是向上的箭头
           if (on_off == ON) 
           {
              Line(row_dot,col_dot,row_dot,col_dot,LINE_COMPLETE);
              Line(row_dot+1,col_dot-1,row_dot+1,col_dot+1,LINE_COMPLETE);
              Line(row_dot+2,col_dot-2,row_dot+2,col_dot+2,LINE_COMPLETE);
           } 
           else 
           {
              ClearArea(row_dot,col_dot-2,3,5);
           }   
           break;
        case ARROW_DOWN:	//是向下的箭头
           if (on_off == ON) 
           {
              Line(row_dot,col_dot,row_dot,col_dot,LINE_COMPLETE);
              Line(row_dot-1,col_dot-1,row_dot-1,col_dot+1,LINE_COMPLETE);
              Line(row_dot-2,col_dot-2,row_dot-2,col_dot+2,LINE_COMPLETE);
           } 
           else 
           {
              ClearArea(row_dot-2,col_dot-2,3,5);
           }
           break;
        case ARROW_LEFT:	//是向左的箭头
           if (on_off == ON) 
           {
              Line(row_dot,col_dot,row_dot,col_dot+2,LINE_COMPLETE);
              Line(row_dot+1,col_dot+1,row_dot+1,col_dot+2,LINE_COMPLETE);
              Line(row_dot-1,col_dot+1,row_dot-1,col_dot+2,LINE_COMPLETE);
              Line(row_dot+2,col_dot+2,row_dot+2,col_dot+2,LINE_COMPLETE);
              Line(row_dot-2,col_dot+2,row_dot-2,col_dot+2,LINE_COMPLETE);
           } 
           else 
           {
              ClearArea(row_dot-2,col_dot,5,3);   
           }   
           break;
        case ARROW_RIGHT:	//是向右的箭头
           if (on_off == ON) 
           {
              Line(row_dot,col_dot-2,row_dot,col_dot,LINE_COMPLETE);
              Line(row_dot+1,col_dot-2,row_dot+1,col_dot-1,LINE_COMPLETE);
              Line(row_dot-1,col_dot-2,row_dot-1,col_dot-1,LINE_COMPLETE);
              Line(row_dot+2,col_dot-2,row_dot+2,col_dot-2,LINE_COMPLETE);
              Line(row_dot-2,col_dot-2,row_dot-2,col_dot-2,LINE_COMPLETE);
           } 
           else 
           {
              ClearArea(row_dot-2,col_dot-2,5,3);
           }      
           break;
        default:
           break;
     }          
}
//在设定位置画图片,采用寻址方式查找gpdata的地址,gpdata类似字库,放在rom中
void GraphiDraw(INT8U row_dot,INT8U col_dot,INT8U gpsizerow,INT8U gpsizecol,INT8U* gpdata)
{    
     INT8U  i,j;
     INT8U  *ptr;
     INT8U  fullcolcnt,gpfull_col;
     INT32U temp32a;

     if (IsAreaValid(row_dot,col_dot,gpsizerow,gpsizecol) == FALSE) return;
     
     leftmod_col   = col_dot - (col_dot>>3<<3);                                    //col_dot % 8;
     leftfull_col  = col_dot >> 3;                                                 //col_dot / 8;
     rightmod_col  = (col_dot + gpsizecol) - ((col_dot + gpsizecol) >> 3 << 3);    //(col_dot + gpsizecol) % 8;
     rightfull_col = (col_dot + gpsizecol - 1) >> 3;                               //(col_dot + gpsizecol - 1) / 8;
     
     gpfull_col = gpsizecol >> 3;                                                  //gpsizecol / 8;
     fullcolcnt = rightfull_col - leftfull_col;

     for (i=row_dot;i<gpsizerow+row_dot;i++) 
     {
        shiftstrm[0] = 0;
        shiftstrm[1] = 0;
        shiftstrm[2] = 0;
        shiftstrm[3] = 0;
         
        ptr = GetPosAddr(DplyImagMem,i,leftfull_col,COLSIZE);
        leftbyte = *ptr;		                                                  //临界区左边数据
        ptr = GetPosAddr(DplyImagMem,i,rightfull_col,COLSIZE);
        rightbyte = *ptr;	                                                      //临界区右边数据
        
        for (j=0;j<gpfull_col;j++) 
        {
            temp32a = *(gpdata + (i-row_dot)*gpfull_col + j);	                  //temp32a放置第i行的数据
            //shiftstrm[j/4] |= temp32a<<((j%4)*8);		                          //按行来依次存放到shiftstrm[]中
            shiftstrm[j>>2] |= temp32a<<((3-(j-(j>>2<<2)))<<3);
        }
        
        if (leftmod_col) 
        {
           temp32a = shiftstrm[2];		                                          //每个shiftstrm[]向左移动leftmod_col
           shiftstrm[3] <<= leftmod_col;
           temp32a >>= (32 - leftmod_col); 
           shiftstrm[3] |= temp32a;
           
           temp32a = shiftstrm[1];
           shiftstrm[2] <<= leftmod_col;
           temp32a >>= (32 - leftmod_col);
           shiftstrm[2] |= temp32a;
           
           temp32a = shiftstrm[0];
           shiftstrm[1] <<= leftmod_col;
           temp32a >>= (32 - leftmod_col);
           shiftstrm[1] |= temp32a;
           
           shiftstrm[0] <<= leftmod_col;
        }
        
        ptr = GetPosAddr(DplyImagMem,i,leftfull_col,COLSIZE);
        
        for (j=0;j<=fullcolcnt;j++) 
        {
           //将SHIFTSTRM[]写入DplyImagMem
           *ptr++ = (shiftstrm[j>>2]>>((3-(j-(j>>2<<2)))<<3)) & 0xff;
        }
        
        ResumeSideBytes(i);
     }
}	

//在设定位置画图片。处理方法类似GraphiDraw,但图片数据gpdata放在ROM中,即图片数据gpdata放在FONTLIB.C中
void GraphiDraw_FromROM(INT8U row_dot,INT8U col_dot,INT8U gpsizerow,INT8U gpsizecol, INT8U* gpdata) 
{   

     INT8U  i,j;
     INT8U  *ptr;
     INT8U  fullcolcnt,gpfull_col;
     INT32U temp32a;

     if (IsAreaValid(row_dot,col_dot,gpsizerow,gpsizecol) == FALSE) return;     
     
     leftmod_col   = col_dot - (col_dot>>3<<3);                                    //col_dot % 8;
     leftfull_col  = col_dot >> 3;                                                 //col_dot / 8;
     rightmod_col  = (col_dot + gpsizecol) - ((col_dot + gpsizecol) >> 3 << 3);    //(col_dot + gpsizecol) % 8;
     rightfull_col = (col_dot + gpsizecol - 1) >> 3;                               //(col_dot + gpsizecol - 1) / 8;
     

     gpfull_col = gpsizecol >> 3;                                                  //gpsizecol / 8;
     fullcolcnt = rightfull_col - leftfull_col;

     for (i=row_dot;i<gpsizerow+row_dot;i++) 
     {
        shiftstrm[0] = 0;
        shiftstrm[1] = 0;
        shiftstrm[2] = 0;
        shiftstrm[3] = 0;
        
        ptr = GetPosAddr(DplyImagMem,i,leftfull_col,COLSIZE);
        leftbyte = *ptr;		                                                  //临界区左边数据
        ptr = GetPosAddr(DplyImagMem,i,rightfull_col,COLSIZE);
        rightbyte = *ptr;	                                                      //临界区右边数据
        
        for (j=0;j<gpfull_col;j++) 
        {
           temp32a = *(gpdata + (i-row_dot)*gpfull_col + j);	                  //temp32a放置第i行的数据
           //shiftstrm[j/4] |= temp32a<<((j%4)*8);		                          //按行来依次存放到shiftstrm[]中
           shiftstrm[j>>2] |= temp32a<<((3-(j-(j>>2<<2)))<<3);
        }
            
        if (leftmod_col) 
        {
           temp32a = shiftstrm[2];		                                          //每个shiftstrm[]向左移动leftmod_col
           shiftstrm[3] <<= leftmod_col;
           temp32a >>= (32 - leftmod_col); 
           shiftstrm[3] |= temp32a;
           
           temp32a = shiftstrm[1];
           shiftstrm[2] <<= leftmod_col;
           temp32a >>= (32 - leftmod_col);
           shiftstrm[2] |= temp32a;
           
           temp32a = shiftstrm[0];
           shiftstrm[1] <<= leftmod_col;
           temp32a >>= (32 - leftmod_col);
           shiftstrm[1] |= temp32a;
           
           shiftstrm[0] <<= leftmod_col;
        }
        
        ptr = GetPosAddr(DplyImagMem,i,leftfull_col,COLSIZE);
        
        for (j=0;j<=fullcolcnt;j++) 
        {
           //将SHIFTSTRM[]写入DplyImagMem
           *ptr++ = (shiftstrm[j>>2]>>((3-(j-(j>>2<<2)))<<3)) & 0xff;
        }
        
        ResumeSideBytes(i);
     }
}

⌨️ 快捷键说明

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