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

📄 avr_lcd_3510i.i

📁 dds 9850 的驱动代码
💻 I
📖 第 1 页 / 共 3 页
字号:
   send(90, 0); 
   send(100, 0); 
   send(110, 0); 
   send(127, 0); 
   cs(); 
    
   send(0xB5, 4);      // Gamma Curve Set 
   send(1, 0); 
   cs(); 
    
   send(0xBE, 4);      // Power Control 
   send(3, 0); 
   cs(); 
    
   send(0x11, 4);      // Sleep out 
   cs(); 
    
   send(0xB7, 4);      // Temperature gradient set 
   for(i=0; i<14; i++) { 
      send(0, 0); 
   } 
   cs(); 
    
   send(0x03, 4);      // Booster Voltage ON 
   cs(); 
    
   for(i=0; i<8; i++) {   // Booster Voltage stabilisieren lassen 
      delay_ms(5); 
   } 
    
   send(0x20, 4);      // Inversion control 
   cs(); 
    
   send(0x25, 4);      // Write contrast 
   send(63, 0); 
   cs();
   send(0x29, 4);      // Display On 
   cs();
   delay_ms(5);
}
void send           (unsigned char data,unsigned char cd) { //register unsigned char i=0;
// CS auf Low setzen
PORTD.4=0;
// Kommando oder Daten? 
PORTD.0=0;
if(cd == 4)      PORTD.3=0;
else               PORTD.3=1;
PORTD.0=1;
//for(i=0;i<8;i++){   Bit_op(data<<i,0x80);   }//用循环可减少 44 words
   
do{PORTD.0=0;if((data & 0x80) == 0x80)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x40) == 0x40)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x20) == 0x20)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x10) == 0x10)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x08) == 0x08)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x04) == 0x04)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x02) == 0x02)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
do{PORTD.0=0;if((data & 0x01) == 0x01)      PORTD.3=1;else  PORTD.3=0;PORTD.0=1;}while(0);
} 
void cs             (void){PORTD.4=1;}
void LCD_DrawPoint  (unsigned char x, unsigned char y,unsigned char R,unsigned char G,unsigned char B){
	send(0x2a,4);		//column address set
	send(x,0);
	send(x,0);
	cs();

	send(0x2b,4);		//page address set
	send(y,0);
	send(y,0);
	cs();
	
	send(0x2c,4);		//memory write
	send((R<<4)|G,0);
	send((B<<4)|R,0);
	cs();
	
}
void LCD_ClearScreen(unsigned char BG_color){
        unsigned int x;
        send(0x2a,4);		//column address set
        send(0,0);
        send(98,0);
        cs();
        
        send(0x2b,4);		//page address set
        send(0,0);
        send(67,0);
        cs();
        
        send(0x2c,4);		//memory write
        for (x=0;x<((98+49)*67);x++)
        		send(BG_color,0);
        cs();
}
//LCD_PaintPixel (0,20,66,40,10,2,1);
void LCD_PaintPixel (unsigned char x1, unsigned char y1,unsigned char x2, unsigned char y2,unsigned char R,unsigned char G,unsigned char B){
unsigned char y=0;
	for(x1= x1; x1 < x2; x1 ++){
        	for(y = 0; y<y2; y ++){
        	        if(y>y1){LCD_DrawPoint(x1,y,R,G,B);}
        	}
	}
}
void LCD_WritePixel (unsigned char x1, unsigned char y1,unsigned char *b,unsigned char R,unsigned char G,unsigned char B,unsigned char X_wide,unsigned char Y_high){
unsigned char x,y,temp;
	for(x= 0; x < X_wide; x ++){
	temp=*(b ++);
        	for(y = 0; y < Y_high; y ++){
        		if(temp & (0x01<<y)){LCD_DrawPoint(x1+x,y1+y,R,G,B);}
        	}
	}
}
void LCD_Write_Text (unsigned char *s,unsigned char x, unsigned char y,unsigned char R,unsigned char G,unsigned char B){
unsigned int temp;unsigned char i=0,F=1;
	while(*s){
		if((*s < 0x80) && (*s >= 0x20)){        temp=*s;
                        if((*s=='/') &&(*(s+1)=='n')){y+=12;x=0;s++;}
                        else{LCD_WriteASC(x, y, &(ASCII[*s-' '][1]), R, G, B);x += 6;if(*s=='.')x-=3;}
                               
                        
                        F=1;i=0;
		}
		else if((*s > 0x80) && (*(s + 1) >= 0x40)){        temp=((unsigned int)*s<<8)| *(s + 1);
		        while((F==1) &&(i<GBK_end)){
        		        if(GBK[i][0]==temp)        F=0;
        		        else   		        i++;
        		}
		        if(F!=1){       LCD_WriteGB(x, y, &(GBK[i][1]), R, G, B);F=1;i=0;
        			        x += 12;s ++;
			}
		}
		s ++;
		if(!((*s=='/') &&(*(s+1)=='n')))
		if((x > 92)){x = 0;y += 12;}		
	}
}
void LCD_WriteASC   (unsigned char x1, unsigned char y1,flash unsigned char *b,unsigned char R,unsigned char G,unsigned char B){
char x,y;unsigned char temp,temp_1=0x80;
	for(y= 0; y < 12; y ++){
	temp=*(b ++);
        	for(x = 0; x <8; x ++){
        		if(temp & temp_1){LCD_DrawPoint(x1+x,y1+y,R,G,B);}
        		temp_1=temp_1>>1;
        	}
        	temp_1=0x80;
	}
}
void LCD_WriteGB    (unsigned char x1, unsigned char y1,flash unsigned int *b,unsigned char R,unsigned char G,unsigned char B){
char x,y,z=0;unsigned int temp,temp_1=0x8000;
	for(x= 0; x < 12; x +=2){
	temp=*(b ++);
	        for(z = 0; z <2; z ++){
        	for(y = 0; y <8; y ++){
        		if(temp & temp_1){LCD_DrawPoint(x1+x+z,y1+y,R,G,B);}
        		temp_1=temp_1>>1;
        	}
        	}
        	temp_1=0x8000;
	}
	for(x= 0; x < 12; x +=2){
	temp=*(b ++);
	        for(z = 0; z <2; z ++){
        	for(y = 0; y <8; y ++){
        		if(temp & temp_1){LCD_DrawPoint(x1+x+z,y1+y+8,R,G,B);}
        		temp_1=temp_1>>1;
        	}
        	}
        	temp_1=0x8000;
	}	
}
/*void LCD_WritePixel_pic(unsigned char x1, unsigned char y1, flash unsigned char *b,unsigned char c3){
	unsigned char x, y,y2,x2;
	//unsigned int sum;
	b=b+2;
	x2=*(b)+x1-1;
	send(0x2a,CMD);		//column address set
	send(x1,DATA);
	send(x2,DATA);
	
	cs();
        b=b+2;
        y2=*(b)+y1;b=b+4;
	send(0x2b,CMD);		//page address set
	send(y1,DATA);
	send(y2,DATA);
	cs();
	
	send(0x2c,CMD);		//memory write
	//x=(x2-x1)*(y2-y1)*3/2;
	//for(y=0;y<x;y++)
	if (c3==0){;}
	else if (c3==1){b++;}
	else if (c3==2){b+=2;}
//	sum=(y2-y1)*(x2-x1)/2;
	//b++;b++;
//	for (x=0;x<sum;x++){
	for(y = y1; y < y2; y ++)
		{for(x = x1; x < x2; x +=2)
		          {send(0xff-*(++b),DATA);send(0xff-*(++b),DATA);send(0xff-*(++b),DATA); }
		          //b--;
		          }
	cs();
}
*/
void Num2String     (long int Num,unsigned char *s,unsigned char Long,unsigned char Point){
long int temp=0;char sign=1;unsigned char Long_actual=0,index=0;
if(Num<0)     {Num=-Num;sign=-sign;}
temp=Num;
for(Num=Num;Num>1;Num=Num/10){Long_actual++;if(Point==Long_actual){s[index++]='.';Long_actual++;}s[index++]=(unsigned char)(temp-Num/10*10)+'0';temp=temp/10;}
if(temp==1) {Long_actual++;s[index++]='1';}
if(Long>Long_actual){unsigned char i=0;for(i=Long-Long_actual;i>0;i--){s[index++]='0';}Long_actual=Long;}//
if(sign==-1){s[index++]='-';Long_actual++;}
temp=index;
for(sign=Long_actual/2;sign>0;sign--){s[temp]=s[--index];s[index]=s[Long_actual-index-1];s[Long_actual-index-1]=s[temp];}
s[temp]=0;//test//for(test_i=0;test_i<=4;test_i++){LCD_WriteNumberS(test_i,6, 0,1,1,8,1,0);LCD_WriteNumberS(s[test_i],6, 0,1,15,15,3,0);if(x_LCD_WriteNumber>80){y_LCD_WriteNumber+=12;x_LCD_WriteNumber=0;}}
}

/*void Flash_Words    (char *s,unsigned char x,unsigned char y,unsigned char delay,unsigned char Play_times){
unsigned char rr=0,bb=0,gg=0,i,j=1,k=0;
while(k<Play_times){
        
        for(i=0;i<15;i++){
                if(k & 0x01){
                        LCD_Write_Text (s,x,y,rr+=j,gg,bb);
                        delay_ms(delay);
                        }
                if(k & 0x02){
                        LCD_Write_Text (s,x,y,rr,gg+=j,bb);
                        delay_ms(delay);
                        }
                if(k & 0x04){
                        LCD_Write_Text (s,x,y,rr,gg,bb+=j);
                        delay_ms(delay);
                        }
                }
                j=-j;if(j==1)k++;
        }
        
}*/

    

⌨️ 快捷键说明

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