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

📄 ili9320_430.c

📁 cc2500无线传感与msp430的接口代码
💻 C
📖 第 1 页 / 共 2 页
字号:
void Pattern4()		//vertical 				
{
	unsigned int i,j;
    dis_area(100,219,50,299);
	for(i=0;i<250;i++)
	{
		for (j=0;j<120;j++)         
		{
			WriteDAT(0xff,0xff);
			WriteDAT(0x00,0x00);
		}
	}
}

void Pattern5()		//horizontal 				
{
	unsigned int i,j;
    addr();
	for(i=0;i<160;i++)
	{
		for (j=0;j<240;j++)   
			WriteDAT(0xff,0xff);
		for (j=0;j<240;j++)   
			WriteDAT(0x00,0x00);
	}
}

void Pattern6()		//snow 								
{
	unsigned int i,j;
    addr();
	
	for(i=0;i<160;i++)
	{
		for (j=0;j<120;j++)
		{
			WriteDAT(0xff,0xff);
			WriteDAT(0x00,0x00);
		}

		for (j=0;j<120;j++)
		{
			WriteDAT(0x00,0x00);
			WriteDAT(0xff,0xff);
		}
	}
}



void Pattern7()		//All on				
{
	unsigned int i,j;

	WriteRegister(0x4200);
	WriteRegister(0x4300);
	WriteRegister(0x4400);
	
	for(i=0;i<320;i++)
	{		
		for (j=0;j<240;j++)
		{
			WriteDAT(0xff,0xff);
		}		
	}
}


void Pattern9()										
{
	unsigned int i,j;
    addr();
	for(i=0;i<320;i++)
	{
		for (j=0;j<40;j++)
			WriteDAT(0xf8,0x00);//R
		for (j=0;j<40;j++)
			WriteDAT(0x07,0xe0);//G
		for (j=0;j<40;j++)
			WriteDAT(0x00,0x1f);//B
		for (j=0;j<40;j++)
			WriteDAT(0xff,0xe0);//RG
	    for (j=0;j<40;j++)
			WriteDAT(0xf8,0x1f);//RB
         for (j=0;j<40;j++)
			WriteDAT(0x07,0xff);//GB
	}
}


void delayms(int count)   // X10ms  
{
        int i,j;
        for(i=0;i<count;i++)		
                for(j=0;j<500;j++);
}

//////////////////////////////////////////////////////////////////////
//  startx,starty开始位置
//  uchar *p 为字库中的起始位置
//  color为字符颜色, color_b为字符背景颜色
/////////////////////////////////////////////////////////////////////
void dis_asc_8_16(uchar startx,uchar starty,uchar *p,uint color,uint color_b)					
{
	unsigned char a,b,c,aa,bb,ff,k;
    a = color >> 8 ;
    b = color & 0xff ;
    aa = color_b >> 8 ;
    bb = color_b & 0xff ;
    dis_area(startx,startx+7,starty,starty+15);
        for(ff=0;ff<16;ff++)    //16 行
            {
                c = p[ff];
                for(k=0;k<8;k++)    //每字节 8 位
                    {
                       if((c & BIT7 ) == BIT7 )
                              WriteDAT(a,b);  
                        else
                              WriteDAT(aa,bb);  
                        c = c << 1 ;
                    }
            }
}

//////////////////////////////////////////////////////////////////////
//  startx,starty开始位置
//  uchar *p 为字库中的起始位置
//  color为字符颜色, color_b为字符背景颜色
/////////////////////////////////////////////////////////////////////
void dis_hz_16_16(uchar startx,uchar starty,uchar *p,uint color,uint color_b)					
{
	unsigned char a,b,c,aa,bb,ff,k,j;
    a = color >> 8 ;
    b = color & 0xff ;
    aa = color_b >> 8 ;
    bb = color_b & 0xff ;
    dis_area(startx,startx+15,starty,starty+15);
    for(ff=0;ff<16;ff++)    //16 行
        {
            for(j=0;j<2;j++)
                {
                    c = p[(ff<<1)+j];
                    for(k=0;k<8;k++)    //每字节 8 位
                        {
                           if((c & BIT7 ) == BIT7 )
                                  WriteDAT(a,b);  
                            else
                                  WriteDAT(aa,bb);  
                            c = c << 1 ;
                        }
                }
        }
}

void Pattern77(uint x,uint y)	                 // Display All  Red				
{
	unsigned int i;
    dis_area(x,x+7,y,y+15);
    for(i=0;i<16*8;i++)
                WriteDAT(0xf8,0x00);    
}


//////////////////////////////////////////////////////////////////////
//  在指定位置打点
//  x的长度(0-240-startx),y的长度(0-320-starty)
//  color为颜色
/////////////////////////////////////////////////////////////////////
void dot_9320(uint x,uint y,uint color)
    {
        dis_area(x,x,y,y);
        WriteDAT(color>>8,color&0x0ff);
    }

//////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////
void LCD_DrawLine(uint x1, uint y1, uint x2, uint y2,uint color)
{
	uint x, y, t;
	if((x1 == x2) & (y1 == y2))
        {
            dot_9320(x1, y1,color);
        }
	else if(abs(y2 - y1) > abs(x2 - x1))
	{
		if(y1 > y2)
		{
			t = y1;
			y1 = y2;
			y2 = t;
			t = x1;
			x1 = x2;
			x2 = t;
		}
		for(y = y1; y <= y2; y ++)
		{
			x = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
			dot_9320(x, y,color);
		}
	}
	else
	{
		if(x1 > x2)
		{
			t = y1;
			y1 = y2;
			y2 = t;
			t = x1;
			x1 = x2;
			x2 = t;
		}
		for(x = x1; x <= x2; x ++)
		{
			y = (x - x1) * (y2 - y1) / (x2 - x1) + y1;
			dot_9320(x, y,color);
		}
	}
}


//////////////////////////////////////////////////////////////////////
//  在指定范围显示指定的颜色光带
//  startx,starty开始位置
//  lengx为x的长度(0-220-startx),lengy为y的长度(0-176-starty)
//  color为颜色
/////////////////////////////////////////////////////////////////////
void dis_guangdai(uchar startx,uchar starty,uchar lengx,uchar lengy,uint color)	   //Display  All  Green					
{
	unsigned char i,j,a,b;
    a = color >> 8 ;
    b = color & 0xff ;
    dis_area(startx,startx+lengx,starty,starty+lengy);
	for(i=0;i<lengx;i++)                       
	{		
		for (j=0;j<lengy;j++)     
			WriteDAT(a,b);  
	}
}




main()
{
    uint i;
    WDTCTL = WDTPW + WDTHOLD;  
    BCSCTL1 &= ~XT2OFF;                       // XT2on
    do
        {
            IFG1 &= ~OFIFG;                           // Clear OSCFault flag
            for (i = 0xFF; i > 0; i--);               // Time for flag to set
        }
    while ((IFG1 & OFIFG));                   // OSCFault flag still set?
    BCSCTL2 |= SELM_2 + SELS;                 // MCLK = SMCLK = XT2 (safe)
    P3DIR = 0XFF;
    P4DIR = 0XFF;
    P5DIR = 0XFF;

    P1DIR |= BIT7 ;
    P1OUT |= BIT7 ;
    
    P3OUT |= BIT0;
    delayms(20);
    P3OUT &= ~BIT0;
    delayms(10);
    P3OUT |= BIT0;
    delayms(20);
    
    ILI9320_CMO22_Initial();
    	  
	while(1)
	{
    	Pattern0();	  LCD_CS_1; 
        for(i=0;i<300;i++)
            dis_asc_8_16((i%30)<<3,(i/30)<<4,(uchar *)(asc_8_16+16*i),0x07e0,0x001f);
    	Pattern1();	  LCD_CS_1;   // Display All  Red 
    	Pattern2();	  LCD_CS_1;   // Display All  Red 
    	Pattern4();	  LCD_CS_1;   // Display All  Red 
        Pattern9();
        for(i=0;i<100;i++)
            dis_hz_16_16((i%30)<<4,(i/15)<<4,(uchar *)(ziku+32*i),0x07e0,0x001f);

        LCD_DrawLine(0, 0, 66, 88,0xf870) ;
        LCD_DrawLine(100, 200, 166, 88,0xf870) ;
        LCD_DrawLine(0, 220, 66, 310,0xf870) ;
        LCD_DrawLine(200, 110, 66, 310,0xf870) ;
        LCD_DrawLine(120, 10, 230, 300,0xf870) ;
        dis_guangdai(0,0,220,176,0xf870)	;   //Display  All  Green					
        dis_guangdai(0,0,176,220,0x07e0)	;   //Display  All  Green					
  /*      LCD_EnterSleep_ILI9320();
        delay(60000);  delay(60000);  delay(60000);  // Display All  Red 
        delay(60000);  delay(60000);  delay(60000);  // Display All  Red 
        delay(60000);  delay(60000);  delay(60000);  // Display All  Red 
        delay(60000);  delay(60000);  delay(60000);  // Display All  Red 
        delay(60000);  delay(60000);  delay(60000);  // Display All  Red 
        delay(60000);  delay(60000);  delay(60000);  // Display All  Red 
        LCD_ExitSleep_ILI9320();    */

      }
}

⌨️ 快捷键说明

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