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

📄 lcd.c.bak

📁 port of ARM to NOkia 3310 display
💻 BAK
📖 第 1 页 / 共 2 页
字号:
        LcdChr( *dataPtr++ );
    }
}

/*
	LED
*/
void led_to_nokia(int NUM)
{
	
	unsigned char count = 0x00, row = 0x01;
	int aa, bb, cc;
	unsigned char A, B, C, D;
	unsigned char eerow;

	//CALCULATE THE DIGITS
	aa = NUM%1000;
	A=(NUM-aa)/1000;
	
	bb = aa%100;
	B=(aa-bb)/100;
	
	cc = bb%10;
	C=(bb-cc)/10;
	
	D=cc;
        
        
	//SHOW THE DIGITS
	//led #1
	nokia_gotoxy(4,row);
	for (eerow=0;eerow!=68;eerow++) 
	{
		bytefornokia=LED[A][eerow];		// and get it				
		nokia_write_data();			// send data to nokia
		
		count++;	
		if(count ==17)
		{
			row += 1;
			nokia_gotoxy(4,row);
			count=0;
		}
		
		
	}
	
	//led #2
	count = 0x00; row = 1;
	nokia_gotoxy(23,row);
	for (eerow=0;eerow!=68;eerow++) 
	{
		bytefornokia=LED[B][eerow];		// and get it				
		nokia_write_data();			// send data to nokia
		count++;	
		if(count ==17)
		{
			row += 1;
			nokia_gotoxy(23,row);
			count=0;
		}
		
		
	}
	
	
	//led #3
	count = 0x00; row = 1;
	nokia_gotoxy(42,row);
	for (eerow=0;eerow!=68;eerow++) 
	{
		bytefornokia=LED[C][eerow];		// and get it				
		nokia_write_data();			// send data to nokia
		count++;	
		if(count ==17)
		{
			row += 1;
			nokia_gotoxy(42,row);
			count=0;
		}
		
		
	}
	
	
	//led #4
	count=0x00; row = 1;
	nokia_gotoxy(61,row);
	for (eerow=0;eerow!=68;eerow++) 
	{
		bytefornokia=LED[D][eerow];		// and get it				
		nokia_write_data();			// send data to nokia
		count++;	
		if(count ==17)
		{
			row += 1;
			nokia_gotoxy(61,row);
			count=0;
		}
		
		
	}
	
	
	
	return;
}


//Draw a circle on the LCD
//        GLCD_Circle (char u8CenterX, char u8CenterY, char u8Radius)
//		u8CenterX = Center absciss (in pixels)
//		u8CenterY = Center ordinate (in pixels) 
//		u8Radius  = Radius (in pixels)
//

void LCDCircle(unsigned char CenterX, unsigned char CenterY, unsigned char Radius, unsigned char mode)
{
        signed int s16tswitch, s16y, s16x;
        unsigned char u8d;

        s16tswitch = s16y = s16x = 0;
	u8d = CenterY - CenterX;
	s16y = Radius;
	s16tswitch = 3 - 2 * Radius;

	while (s16x <= s16y) 
	{
		//LcdSetDot(u8CenterX + s16x, u8CenterY + s16y);
                LcdPixel ( CenterX + s16x, CenterY + s16y, mode );

		//LcdSetDot(u8CenterX + s16x, u8CenterY - s16y);
		LcdPixel ( CenterX + s16x, CenterY - s16y, mode );

		//LcdSetDot(u8CenterX - s16x, u8CenterY + s16y);
                LcdPixel ( CenterX - s16x, CenterY + s16y, mode );

		//LcdSetDot(u8CenterX - s16x, u8CenterY - s16y);
                LcdPixel ( CenterX - s16x, CenterY - s16y, mode );
		
		//LcdSetDot(u8CenterY + s16y - u8d, u8CenterY + s16x);
                LcdPixel ( CenterY + s16y - u8d, CenterY + s16x, mode );

		//LcdSetDot(u8CenterY + s16y - u8d, u8CenterY - s16x);
                LcdPixel ( CenterY + s16y - u8d, CenterY - s16x, mode );

		//LcdSetDot(u8CenterY - s16y - u8d, u8CenterY + s16x); 
                LcdPixel ( CenterY - s16y - u8d, CenterY + s16x, mode );

		//LcdSetDot(u8CenterY - s16y - u8d, u8CenterY - s16x);
                LcdPixel ( CenterY - s16y - u8d, CenterY - s16x, mode );

		if (s16tswitch < 0) 
			s16tswitch += (4 * s16x + 6);
		else 
		{
			s16tswitch += (4 * (s16x - s16y) + 10);
			s16y--;
		}
	
		s16x++;
	}
        return;
}


void LcdInfo(unsigned char X, unsigned char Y, unsigned char * msg)
{
    LcdGotoXY(X,Y);
    LcdStr(&msg[0]);
    LcdUpdate();
 
    return;
}




void EcosLogo(void)
{
    int count, nok_graph = 504;
    
    // init B/W Lcd
    nokia_init(LcdContr); cls();
    
    //init Color Lcd
    color_nokia_init();
           
    ///////////////////////////////////////////////////// LOGO eCos //////////////////////////////////////////////////////////////////////
     for(count=0;count != nok_graph;count++)
	{
		bytefornokia=ecos4[count];
		nokia_write_data();
	}
hal_delay_us(500000);

for(count=0;count != nok_graph;count++)
	{
		bytefornokia=ecos3[count];
		nokia_write_data();
	}
hal_delay_us(300000);


for(count=0;count != nok_graph;count++)
	{
		bytefornokia=ecos2[count];
		nokia_write_data();
	}
 hal_delay_us(300000);


for(count=0;count != nok_graph;count++)
	{
		bytefornokia=ecos1[count];
		nokia_write_data();
	}
 hal_delay_us(300000);

for(count=0;count != nok_graph;count++)
	{
		bytefornokia=eCos[count];
		nokia_write_data();
	}
 hal_delay_us(4000000);  
 
 /////////////////////////////////////////////////////// uBlox /////////////////////////////////////////////////////////////////////////////////
 for(count=0;count != nok_graph;count++)
       {
		bytefornokia=uBlox[count];
		nokia_write_data();
	}
 hal_delay_us(3000000);  
 /////////////////////////////////////////////////////// SD /////////////////////////////////////////////////////////////////////////////////
 for(count=0;count != nok_graph;count++)
       {
		bytefornokia=sd[count];
		nokia_write_data();
	}
 hal_delay_us(3000000);  
 /////////////////////////////////////////////////////// ARM /////////////////////////////////////////////////////////////////////////////////
 for(count=0;count != nok_graph;count++)
       {
		bytefornokia=arm[count];
		nokia_write_data();
	}
 hal_delay_us(3000000);  
 
 return;    
}




/*
       Create BASH prompt
*/
void lcd(char *message)
{
       unsigned char x,len;
       
       len=strlen(message);
       
       if(len > 16) len=15;
       if(len > 0 ) 
       {
           //Create 6 rows x 15 chars each 	
    	    if(Row<6)
    	    {
    	        strncpy(lcd_buff_5, ".", 15);
    	        
    	        strncpy( lcd_buff_5, message, len );
    	        lcd_buff_5[15]='\0';
    	        nokia_gotoxy(0,Row);
    	        nokia_printmessage( &lcd_buff_5[0],0); 
    	        Row++;
    	    }
    	    else
    	    {
    	         //
                //0
    	        strncpy( lcd_buff_0, " ", 15);
    	        
    	        strncpy( lcd_buff_0, lcd_buff_1, 15);  
    	        lcd_buff_0[15]='\0';
    	        nokia_gotoxy(0,0);
               nokia_printmessage( &lcd_buff_0[0],0); 
               
    	        //1
    	        strncpy( lcd_buff_1, " ", 15);
    	        
    	        strncpy( lcd_buff_1, lcd_buff_2, 15);
    	        lcd_buff_1[15]='\0';
    	        nokia_gotoxy(0,1);
               nokia_printmessage(&lcd_buff_1[0],0); 
              
    	        //2
    	        strncpy( lcd_buff_2, " ", 15);
    	        
    	        strncpy( lcd_buff_2,  lcd_buff_3, 15 );
    	        lcd_buff_2[15]='\0';
    	        nokia_gotoxy(0,2);
               nokia_printmessage(&lcd_buff_2[0],0); 
               
    	        //3
    	        strncpy( lcd_buff_3, " ", 15);
    	        
    	        strncpy( lcd_buff_3, lcd_buff_4, 15);
    	        lcd_buff_3[15]='\0';
    	        nokia_gotoxy(0,3);
               nokia_printmessage(&lcd_buff_3[0],0); 
               
    	        //4
    	        strncpy( lcd_buff_4, " ", 15);
    	        
    	        strncpy( lcd_buff_4,  lcd_buff_5, 15 );
    	        lcd_buff_4[15]='\0';
    	        nokia_gotoxy(0,4);
               nokia_printmessage(&lcd_buff_4[0],0); 
                            
    	        //5
    	        strncpy( lcd_buff_5, " ", 15);
    	        
    	        strncpy( lcd_buff_5,message, len );
    	        lcd_buff_5[15]='\0';
    	        nokia_gotoxy(0,5);
               nokia_printmessage(&lcd_buff_5[0],0); 
         }     
         
       
       }
       
       
       return;
}


void clear(unsigned char x, unsigned char y, unsigned char zero)
{
    unsigned char count;
    
    nokia_gotoxy(x,y);
    for(count=0;count != zero;count++){
	        	bytefornokia=0x00;
		        nokia_write_data();
    }
    return;
}

/////////////////////////////////////////////////////////////////////////// COLOR LCD   98x67 ///////////////////////////////////////////////

void color_nokia_init(void)
{

       unsigned int i;
	unsigned char  s,a;

      (*(volatile unsigned long *)ASHLING_IODIR) |= 0x01<< 24  ; 
      (*(volatile unsigned long *)ASHLING_IODIR) |= 0x01<< 4  ; 
      (*(volatile unsigned long *)ASHLING_IODIR) |= 0x01<< 5  ; 
      (*(volatile unsigned long *)ASHLING_IODIR) |= 0x01<< 6  ; 
       

    	//init port
        
	
	// LCD Hardware Reset
	hal_delay_us(5000);
	RESET_0;
	hal_delay_us(5000);
	RESET_1;
	
	CS_1;
	SCLK_1;
	SDATA_1;
	
	send(0x01, CMD);		// LCD Software Reset
	cs();
	hal_delay_us(5000);
	
	send(0xC6, CMD);		// Initial Escape
	cs();
	
	send(0xB9, CMD);		// Refresh set
	send(0x00, DATA);
	cs();
	
	send(0xB6, CMD);		// Display Control
	send(128, DATA);
	send(128, DATA);
	send(129, DATA);
	send(84, DATA);
	send(69, DATA);
	send(82, DATA);
	send(67, DATA);
	cs();
	
	send(0xB3, CMD);		// Gray Scale Position
	send(1, DATA);
	send(2, DATA);
	send(4, DATA);
	send(8, DATA);
	send(16, DATA);
	send(30, DATA);
	send(40, DATA);
	send(50, DATA);
	send(60, DATA);
	send(70, DATA);
	send(80, DATA);
	send(90, DATA);
	send(100, DATA);
	send(110, DATA);
	send(127, DATA);
	cs();
	
	send(0xB5, CMD);		// Gamma Curve Set
	send(1, DATA);
	cs();
	
	send(0xBE, CMD);		// Power Control
	send(4, DATA);
	cs();
	
	send(0x11, CMD);		// Sleep out
	cs();
	
	send(0xB7, CMD);		// Temperature gradient set
	for(i=0; i<14; i++) {
		send(0, DATA);
	}
	cs();
	
	send(0x03, CMD);		// Booster Voltage ON
	cs();
	
		hal_delay_us(40000);

	
	send(0x20, CMD);		// Inversion control
	cs();
	
	send(0x25, CMD);		// Write contrast
	send(85, DATA);           //was 63
	cs();

	send(0x29, CMD);		// Display On
	cs();

	send(0x2C, CMD);		// Memory Write
		
	
for(a=0;a<4;a++)
{

	s=0;
	for(i=0; i<294; i++) {
		if(s == 0) send(15, DATA);			//	15
		else if(s == 1) send(240, DATA);	//  240
		else if(s == 2) send(255, DATA);	//	255
		
		if(++s == 3)
			s = 0;
	}
	

	s=0;
	for(i=0; i<294; i++) {
		if(s == 0) send(240, DATA);
		else if(s == 1) send(255, DATA);
		else if(s == 2) send(15, DATA);
		
		if(++s == 3)
			s = 0;
	}
	

	s=0;
	for(i=0; i<294; i++) {
		if(s == 0) send(255, DATA);
		else if(s == 1) send(15, DATA);
		else if(s == 2) send(240, DATA);
		if(++s == 3)
			s = 0;
	}
	

	s=0;
	for(i=0; i<294; i++) {
		if(s == 0) send(0, DATA);
		else if(s == 1) send(240, DATA);
		else if(s == 2) send(15, DATA);
		
		if(++s == 3)
			s = 0;
	}
	
				
	s=0;
	for(i=0; i<294; i++) {
		if(s == 0) send(15, DATA);  
		else if(s == 1) send(0, DATA);
		else if(s == 2) send(240, DATA);
		
		if(++s == 3)
			s = 0;
	}
	

	s=0;
	for(i=0; i<294; i++) {
		if(s == 0) send(240, DATA);
		else if(s == 1) send(15, DATA);
		else if(s == 2) send(0, DATA);
		
		if(++s == 3)
			s = 0;
	}
	

	for(i=0; i<294; i++) {
		send(0, DATA);
	}
	

	for(i=0; i<294; i++) {
		send(255, DATA);
	}
	cs();
	}
	
	send(0x29, CMD);		// Display On
	cs();
      
       return;
}



void send(unsigned char data, unsigned char cd) {
	
	unsigned char c;
	
	CS_0;


	SCLK_0;
	if(cd == CMD)
		SDATA_0;
	else
		SDATA_1;
	SCLK_1;

	for (c=8;c>0;c--) {
		SCLK_0;
		if ((data&0x80)==0){
		SDATA_0;
	}
		else {
		SDATA_1;
		}
		SCLK_1;
		data=data<<1;
	}
       return;
}

void cs(void) {
	CS_1;	// CS = 1
}




void Lcd_setframe(unsigned char Lcd_left, unsigned char Lcd_top, unsigned char Lcd_width, unsigned char Lcd_height )
{
    send(0x2A , 0);
    send(Lcd_left, 1);
    send(Lcd_width, 1);
    cs();
    send(0x2B , 0);
    send(Lcd_top,1);
    send(Lcd_height, 1);
    cs();
    send(0x2C ,0);
    
    return;
}


void Lcd_setcolor(unsigned char Forecolor, unsigned char Backcolor)
{
    Lcd_fcolor = Forecolor;
    Lcd_bcolor = Backcolor;
    
    return;
}

void Lcd_setdoublesize(unsigned char size)
{
    Lcd_doublesize = size;
    return;
}

//
void Lcd_cls(void)
{
    unsigned int R;
    
    Lcd_setframe(0,0,97,67);
    
    for(R=1; R!=6566; R++)
    {
        send(0xEE, 1);
    }
    
    return;
}



void Lcd_print(unsigned char * Lcd_text)
{
    unsigned int R;
    unsigned char A, B, C, D, E, F, G;
    unsigned char * zeichnen;
    
    send(0x36, 0);
    send(0x20, 1);
    send(0x2C, 0);
    
    for(R=1; R!= strlen(Lcd_text);R++)
    {
        strncpy(zeichnen, Lcd_text, R);
    }

    return;
}


//eof

⌨️ 快捷键说明

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