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

📄 splc501user.c

📁 基于凌阳和ad9850实现的正弦波信号发生器程序
💻 C
📖 第 1 页 / 共 2 页
字号:
			x+=Err_d;
			LCD501_PutPixel(x,y);
		}	
	}
	else
	{
		while(y!=e_y)
		{
			if(Offset_k>0)
			{
				x+=Err_d;
				Offset_k += (Offset_x-Offset_y);
			}
			else Offset_k += Offset_x;
			y+=1;
			LCD501_PutPixel(x,y);
		}
	}
}
//***************************************************************************//
//程序:void LCD501_Circle(unsigned int x,unsigned int y,unsigned int r,
//							unsigned int Mode)
//描述:画圆程序
//参数:x 要画的圆心的x坐标   y 要画的圆心的y坐标  r 半径  Mode:绘点模式……
//		Mode = M_DOT_CLEAR 0 画圆框    Mode = M_DOT_SET 1 画实心圆
//声明:小丑	20050521	sunnorth  Mz Design
//注意:画实心圆需要用较长时间,用户需要做好清看门狗的操作
//***************************************************************************//
void W_Red_Err(int *a,int *b,int *r);
void LCD_PaintRed_Dot(int x,int y,int a,int b,int mode)
{
    if(mode>0)
    {
       LCD501_Line(x+a,y+b,x-a,y+b);
       LCD501_Line(x+a,y-b,x-a,y-b);
    }
    else
    {
       LCD501_PutPixel(x+a,y+b);
       LCD501_PutPixel(x-a,y+b);
       LCD501_PutPixel(x+a,y-b);
       LCD501_PutPixel(x-a,y-b);
    }
}
void LCD501_Circle(unsigned int x,unsigned int y,unsigned int r,unsigned int Mode)
{
	int arx1=0,ary1,arx2,ary2=0;
	unsigned int uiTemp;
     ary1=r;
     arx2=r;
     uiTemp = LCD501_GetPaintMode();
     LCD501_SetPaintMode(PAINT_COVER);
     while(1)
     {
     	Clear_Watchdog();
        LCD_PaintRed_Dot(x,y,arx1,ary1,Mode);
        W_Red_Err(&arx1,&ary1,&r);
        if(arx1==arx2)
        {
           LCD_PaintRed_Dot(x,y,arx1,ary1,Mode);
           break; 
        }
        LCD_PaintRed_Dot(x,y,arx2,ary2,Mode);
        W_Red_Err(&ary2,&arx2,&r);
        if(arx1==arx2) 
        {
           LCD_PaintRed_Dot(x,y,arx2,ary2,Mode);
           break;
        }
     }
     LCD501_SetPaintMode(uiTemp);
}
//***************************************************************************//
//程序:void LCD501_Rectangle(unsigned left, unsigned top, 
//							unsigned right, unsigned bottom, unsigned Mode)
//描述:画矩形程序
//参数:left - 矩形的左上角横坐标,范围0到118
//		top - 矩形的左上角纵坐标,范围0到50
//		right - 矩形的右下角横坐标,范围1到119
//		bottom - 矩形的右下角纵坐标,范围1到51
//		Mode - 绘制模式,可以是下列数值之一:
//				PAINT_HOLLOW:	矩形框(空心矩形)
//				PAINT_SOLID:	矩形面(实心矩形)
//声明:xinqiang	20050521	sunnorth  Mz Design
//注意:无
//***************************************************************************//
void LCD501_Rectangle(unsigned left, unsigned top, unsigned right, unsigned bottom, unsigned Mode)
{
	unsigned uiTemp;
	if(left>right)
	{
		uiTemp = left;
		left = right;
		right = left;
	}
	if(top>bottom)
	{
		uiTemp = top;
		top = bottom;
		bottom = uiTemp;
	}
	if(Mode==PAINT_HOLLOW)
	{
		LCD501_Line(left,top,left,bottom);
		LCD501_Line(left,top,right,top);
		LCD501_Line(right,bottom,left+1,bottom);
		LCD501_Line(right,bottom,right,top+1);
	}
	else
	{
		for(uiTemp=top;uiTemp<=bottom;uiTemp++)
		{
			LCD501_Line(left,uiTemp,right,uiTemp);
			Clear_Watchdog();
		}
	}
}
//***************************************************************************//
//程序:void LCD501_Bitmap(unsigned int x,unsigned int y,unsigned int *word)
//描述:OSD取的汉字字模显示函数  C语言调用 
//参数:x 显示字符的起始列(0~128)   y 要显示的字模的起始行(0~64-y_whide)
//		*word 要显示的汉字字模的数据首地址
//声明:小丑	20050519	sunnorth  Mz Design
//注意:只显示用OSD取字模软件所取的汉字字模数据
//***************************************************************************//
unsigned int Shift_Buff[4];
unsigned int Shift_Data_buf[4];
unsigned int Cover_Data_buf[4];
void F_Cover_Initial(unsigned int Number_Bit,unsigned int Number_Shif);
void F_Data_Cover(unsigned int* word,unsigned int S_Number,unsigned int Y_W,unsigned int Y_WW);
void LCD501_Bitmap(unsigned int x,unsigned int y,unsigned int *word)
{
	unsigned int untype,Shift_Num,Read_Back;
	int i,j,m,n;
	unsigned int x_low,x_hight;
	unsigned int y_whide,y_Number,y_Number_8;
	Shift_Num = y&0x07;						//Get the Shift Number
	untype = *(word++);
	i = untype>>8;
	j = (untype&0xff);						//Get the whide
	if((x+j)>128||(y+i)>64||y>64)
		return;
	y = (y>>3)+M_LCD_COL_PAGE;
	x = x+4;
	y_whide = i>>4;							//Get the y whide (16bit one word)
	if(i&0x000f)y_whide+=1;
	//test
	F_Cover_Initial(i,Shift_Num);			//Model the Mask Data
	//test
	y_Number = i+Shift_Num;
	y_Number_8 = y_Number;
	i = y_Number&0x0f;
	y_Number = y_Number>>4;
	if(i)y_Number++;
	i = i&0x07;
	y_Number_8 = y_Number_8>>3;
	if(i&&y_Number_8!=8)y_Number_8++;
	
	for(n=0;n<j;n++)
	{
		x_low = (x&0x000f);				//定位列地址设置的低位指令
		x_hight = ((x>>4)&0x000f)+0x10;		//定位列地址设置的高位指令
		x++;
		for(m=0;m<4;m++)Shift_Data_buf[m] = 0;
		for(m=0;m<y_Number_8;m++)
		{
			F_SPLC501_Write_Com(y+m);
			F_SPLC501_Write_Com(x_low);	//设置初始地址 
			F_SPLC501_Write_Com(x_hight);
			Read_Back = F_SPLC501_Read_Data();
			untype = m>>1;
			if(m&0x01)
				Shift_Buff[3-untype] = Shift_Buff[3-untype]|(Read_Back<<8);
			else
				Shift_Buff[3-untype] = Read_Back;
		}
		F_Data_Cover(word,Shift_Num,y_Number,(y_whide<<4));
		for(m=0;m<y_Number_8;m++)
		{
			F_SPLC501_Write_Com(y+m);
			F_SPLC501_Write_Com(x_low);	//设置初始地址 
			F_SPLC501_Write_Com(x_hight);
			untype = m>>1;
			if(m&0x01)
				Read_Back = Shift_Data_buf[3-untype]>>8;// = Shift_Buff[3-untype]|(Read_Back<<8);
			else
				Read_Back = Shift_Data_buf[3-untype];// = Read_Back;
			F_SPLC501_Write_Data(Read_Back);
		}
		word = word+y_whide;
	}
}
//****************************************************************************************//
//程序:void LCD501_FontSet(unsinged int Font)     [8x16] [6X8]
//描述: 选择显示字符的大小类型
//参数:Font	字符的类型选择 1 8X16   0 6X8
//声明: xinqiang		20050519	sunnorth  Mz Design
//注意: 只针对显示驱动中包含的ASCII码显示
//*****************************************************************************************//
void LCD501_FontSet(unsigned int Font)
{
	if(Font) CurASCIIFont = 1;
	else CurASCIIFont = 0;
}
//****************************************************************************************//
//程序:unsigned int LCD501_FontGet(void)     [8x16] [6X8]
//描述: 获取当前显示字符的大小类型
//返回:Font	字符的类型选择 1 8X16   0 6X8
//声明: xinqiang		20050519	sunnorth  Mz Design
//注意: 只针对显示驱动中包含的ASCII码显示
//*****************************************************************************************//
unsigned int LCD501_FontGet(void)
{
	return CurASCIIFont;
}
//****************************************************************************************//
//程序:void F_LCD_WASII(int x,int page,unsigned int a)     [8x16] [6X8]
//描述: 显时8X16、6X8的自带ASCII字符,定Page显示,不能任意行定位
//参数:x 显示字符的起始列(0~128)   page 显示字符的起始页(0~6)
//		a ASCII码					  Font	字符的类型选择 1 8X16   0 6X8
//声明: xinqiang		20050519	sunnorth  Mz Design
//注意: 
//*****************************************************************************************//
void F_LCD_WASII(int x,int page,unsigned int a)       
{
     int i,j,X_Witch,Y_Witch,y_com;            //数据暂存
     int *p_data;
     a -=32; 
     x=x+4;
 
     if(CurASCIIFont)
     {
         X_Witch = 4;
         Y_Witch = 2;
         p_data = &Asii16;                    //字符表首址
         a=a<<3;
     }
     else
     {
         p_data = &Asii8;                     //字符表首址
         X_Witch=a<<1;
         a+=X_Witch;
         X_Witch = 3;
         Y_Witch = 1;
     }
     p_data +=a;                               //要写字符的首地址
     for(j=0;j<Y_Witch;j++)
     {
		if((page+j)<8)
		{
			y_com = page+0xb0;
			F_SPLC501_Write_Com(y_com+j);
			F_SPLC501_Write_Com(((x&0xf0) >> 4)|0x10);	//设置初始地址 
			F_SPLC501_Write_Com(x&0x0f);
			for(i=0;i<X_Witch;i++,p_data++)
			{   
				if((x+(i<<1))<132)
				{
					F_SPLC501_Write_Data(((*p_data)>>8)&0xff);
					F_SPLC501_Write_Data((*p_data)&0xff);
				}    
            }
        }
    }
}   
//********************************************************************************************//
//程序:void LCD501_PutChar(int x,int y,unsigned int a)      [8x16] [6X8]
//描述: 显时8X16、6X8的自带ASCII字符,任意行定位
//参数:x 显示字符的起始列(0~128)   y 显示字符的起始行(0~63)
//		a ASCII码					 
//声明: xinqiang		20050519	sunnorth  Mz Design
//注意: 
//********************************************************************************************//
void LCD501_PutChar(int x,int y,unsigned int a)       
{
     int i,j,X_Witch,Y_Witch=0,y_com=0;            //数据暂存
     unsigned int uiData1,uiData2;
     unsigned int uiMask_low=0x00ff,uiMask = 0x00ff,uiMask_mid = 0x00ff,uiMask_mid2 = 0x00ff;
     unsigned int Read_Back;					//读回的数据
     unsigned int Shift_Num;					//左移的个数
     int *p_data;
     a -=32; 
     x=x+4;
     Shift_Num = y&0x07;						//只取低三位
     y = y>>3;//&uiMask_low;
     if(Shift_Num){Y_Witch++;}
     if(CurPaintMode==PAINT_COVER)//||CurPaintMode==PAINT_SET)
     {
		 uiMask = uiMask>>Shift_Num;				//得到掩膜数
		 uiMask_low = (uiMask_low<<(8-Shift_Num))&0x00ff;			//得到低位掩模数
		 uiMask_mid2 = uiMask_low>>(8-Shift_Num);
		 uiMask_mid = uiMask<<Shift_Num;
	}
     if(CurASCIIFont)
     {
         X_Witch = 4;
         Y_Witch = Y_Witch+2;
         p_data = &Asii16;                    //字符表首址
         a=a<<3;
     }
     else
     {
         p_data = &Asii8;                     //字符表首址
         X_Witch=a<<1;
         a+=X_Witch;
         X_Witch = 3;
         Y_Witch++;
     }
     p_data +=a;                               //要写字符的首地址
     
     for(j=0;j<Y_Witch;j++)
     {
		if((y+j)<8)
		{
			y_com = y+0xb0;
			F_SPLC501_Write_Com(y_com+j);				//设置初始页地址
			F_SPLC501_Write_Com(((x&0xf0) >> 4)|0x10);	//设置初始列地址 
			F_SPLC501_Write_Com(x&0x0f);
			F_SPLC501_Write_Com(0xe0);					//设置为读写改模式
			for(i=0;i<X_Witch;i++,p_data++)
			{   
				if((x+(i<<1))<128)
				{
					if(j==0)
					{
						uiData2 = F_SPLC501_Read_Data();
						uiData1 = (*p_data)>>8;
						uiData1 = (uiData1&uiMask)<<Shift_Num;
						uiData2 = (uiData2&uiMask_mid2);//>>Shift_Num;
					}
					else if(j==(Y_Witch-1)&&Shift_Num!=0)
					{
						uiData1 = (*(p_data-X_Witch)>>8)&0x00ff;
						uiData2 = F_SPLC501_Read_Data();
						uiData2 = (uiData2&uiMask_mid);
						uiData1 = (uiData1&uiMask_low)>>(8-Shift_Num);//>>Shift_Num;
					}
					else
					{
						uiData1 = (*(p_data-X_Witch)>>8)&0x00ff;
						uiData2 = ((*p_data)>>8)&0x00ff;
						uiData1 = uiData1>>(8-Shift_Num);
						uiData2 = uiData2<<Shift_Num;
						uiData1 = uiData1|uiData2;
					}
					switch(CurPaintMode)
					{
						case PAINT_CLR: uiData2 = F_SPLC501_Read_Data();Read_Back = (~uiData1)&uiData2;
							break;
						case PAINT_REV: uiData2 = F_SPLC501_Read_Data();Read_Back = uiData1^uiData2;
							break;
						case PAINT_SET: uiData2 = F_SPLC501_Read_Data(); Read_Back = uiData2|uiData1;
							break;
						default: Read_Back = uiData2|uiData1;
							break;
					}
					F_SPLC501_Write_Data(Read_Back);
					if(j==0)
					{
						uiData2 = F_SPLC501_Read_Data();
						uiData1 = *p_data;
						uiData1 = (uiData1&uiMask)<<Shift_Num;
						uiData2 = (uiData2&uiMask_mid2);//>>Shift_Num;
					}
					else if(j==(Y_Witch-1)&&Shift_Num!=0)
					{
						uiData1 = (*(p_data-X_Witch))&0x00ff;
						uiData2 = F_SPLC501_Read_Data();
						uiData2 = (uiData2&uiMask_mid);
						uiData1 = (uiData1&uiMask_low)>>(8-Shift_Num);//>>Shift_Num;
					}
					else
					{
						uiData1 = (*(p_data-X_Witch))&0x00ff;
						uiData2 = (*p_data)&0x00ff;
						uiData1 = uiData1>>(8-Shift_Num);
						uiData2 = uiData2<<Shift_Num;
						uiData1 = uiData1|uiData2;
					}
					switch(CurPaintMode)
					{
						case PAINT_CLR: uiData2 = F_SPLC501_Read_Data();Read_Back = (~uiData1)&uiData2;
							break;
						case PAINT_REV: uiData2 = F_SPLC501_Read_Data();Read_Back = uiData1^uiData2;
							break;
						case PAINT_SET: uiData2 = F_SPLC501_Read_Data();Read_Back = uiData2|uiData1;
							break;
						default: Read_Back = uiData2|uiData1;
							break;
					}
					F_SPLC501_Write_Data(Read_Back);//(*p_data)&0xff);
				}    
            }
            F_SPLC501_Write_Com(0xee);					//读改写模式结束指令
        }
    }
}   
//********************************************************************************************//
//程序:void LCD501_PutString(int x,int y,unsigned int a)      [8x16] [6X8]
//描述: 显时8X16、6X8的自带ASCII字符,任意行定位
//参数:x 显示字符的起始列(0~128)   y 显示字符的起始行(0~63)
//		a ASCII码					  
//声明: xinqiang		20050519	sunnorth  Mz Design
//注意: 
//********************************************************************************************//
void LCD501_PutString(int x,int y,unsigned int * string)       
{
	unsigned int x_err=6,y_err=8;
	if(CurASCIIFont)
	{
		x_err = 8;
		y_err = 16;
	}
	while(*string!=0)
	{
		if((x+x_err)>127)
		{
			x = 0;
			y = y+y_err;
		}
		if(y>63) y =0;
		LCD501_PutChar(x,y,*string);
		string++;
		x+=x_err;
	}
}   

⌨️ 快捷键说明

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