Ejemplo n.º 1
0
/*
*@功能:在指定位置显示一个字符,包括部分字符
*@输入:x:0~127,y:0~7,size:选择字体 16/12 
*/
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr)
{      	
		uint8_t c=0,i=0;	
		c=chr-' ';//得到偏移后的值			
		if(x>Max_Column-1)
		{
			x=0;
			y=y+2;
		}
		if(SIZE ==16)
		{
			OLED_Set_Pos(x,y);	
			for(i=0;i<8;i++)
				OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);
			OLED_Set_Pos(x,y+1);
			for(i=0;i<8;i++)
				OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);
		}
		else 
		{	
			OLED_Set_Pos(x,y+1);
			for(i=0;i<6;i++)
				OLED_WR_Byte(F6x8[c][i],OLED_DATA);	
		}
}
Ejemplo n.º 2
0
void OLED_Draw_Curve(unsigned char *data)
{
  unsigned char i,temp1,y1,temp2,y2;
  
  for(i=0;i<128;i+=2)   
  {
    y1=7-(data[i]>>3);   //获取行号
    y2=7-(data[i+1]>>3);
    temp1=1<<(7-(data[i]%8));
    temp2=1<<(7-(data[i+1]%8));
    if(y1==y2)
    {
      
      OLED_Set_Pos(i,y1);
      OLED_WrDat(temp1); 
      OLED_WrDat(temp2);
    }
    else
    {
      OLED_Set_Pos(i,y1);
      OLED_WrDat(temp1); 
      OLED_WrDat(0);
      OLED_Set_Pos(i,y2);
      OLED_WrDat(0); 
      OLED_WrDat(temp2);
    }
  }
}
Ejemplo n.º 3
0
void OLED_Write_String_x(unsigned char y,unsigned char x,signed char String[],signed char Length)
{
  unsigned char Temp_Char=0,Temp_i=0,Temp_j=0,Temp_k=0;
  //unsigned char Over_Flag=0;
  unsigned char String_Length=0;      
        
  while(String[String_Length]!='\0')
    String_Length++;
  
  if(String_Length>Length)
    String_Length=Length;        
        
  if(y==1)
  {
    while(Temp_j<Length)
    {    
      String_Length++;
      if(String_Length>=Length+1)
      {
        Temp_Char=String[Temp_k]-32;
        OLED_Set_Pos(x,y);    
      	for(Temp_i=0;Temp_i<6;Temp_i++)     
      	  OLED_Write_Data(0x80|Font_6x8[Temp_Char][Temp_i]);      	
      	Temp_k++; 
      }
      else
      {
        OLED_Set_Pos(x,y);    
      	for(Temp_i=0;Temp_i<6;Temp_i++)     
      	  OLED_Write_Data(0x80);
      }
    	x+=6;
    	Temp_j++;
    }      
  }
  else
  {
    while(Temp_j<Length)
    {    
      String_Length++;
      if(String_Length>=Length+1)
      {
        Temp_Char=String[Temp_k]-32;
        OLED_Set_Pos(x,y);    
      	for(Temp_i=0;Temp_i<6;Temp_i++)     
      	  OLED_Write_Data(Font_6x8[Temp_Char][Temp_i]);      	
      	Temp_k++; 
      }
      else
      {
        OLED_Set_Pos(x,y);    
      	for(Temp_i=0;Temp_i<6;Temp_i++)     
      	  OLED_Write_Data(0);
      }
    	x+=6;
    	Temp_j++;
    }      
  }  
}
Ejemplo n.º 4
0
//输出汉字字符串
void OLED_P14x16Str(unsigned char x,unsigned char y,unsigned char ch[])
{
	unsigned char wm=0,ii = 0;
	unsigned int adder=1; 
	
	while(ch[ii] != '\0')
	{
  	wm = 0;
  	adder = 1;
  	while(F14x16_Idx[wm] > 127)
  	{
  		if(F14x16_Idx[wm] == ch[ii])
  		{
  			if(F14x16_Idx[wm + 1] == ch[ii + 1])
  			{
  				adder = wm * 14;
  				break;
  			}
  		}
  		wm += 2;			
  	}
  	if(x>118){x=0;y++;}
  	OLED_Set_Pos(x , y); 
  	if(adder != 1)// 显示汉字					
  	{
  		OLED_Set_Pos(x , y);
  		for(wm = 0;wm < 14;wm++)               
  		{
  			OLED_WrDat(F14x16[adder]);	
  			adder += 1;
  		}      
  		OLED_Set_Pos(x,y + 1); 
  		for(wm = 0;wm < 14;wm++)          
  		{
  			OLED_WrDat(F14x16[adder]);
  			adder += 1;
  		}   		
  	}
  	else			  //显示空白字符			
  	{
  		ii += 1;
      OLED_Set_Pos(x,y);
  		for(wm = 0;wm < 16;wm++)
  		{
  				OLED_WrDat(0);
  		}
  		OLED_Set_Pos(x,y + 1);
  		for(wm = 0;wm < 16;wm++)
  		{   		
  				OLED_WrDat(0);	
  		}
  	}
  	x += 14;
  	ii += 2;
	}
}
Ejemplo n.º 5
0
/*--------------------*屏幕头显示*--------------------*/
void Dis_Head(signed char String[])
{
  unsigned char Temp_Char=0,Temp_i=0,Temp_j=0,Position_x=10;
  unsigned char Over_Flag=0;
  unsigned char String_Length=0; 
  unsigned char Begin=0;    
   
  OLED_Set_Pos(118,1);    
  for(Temp_i=0;Temp_i<20;Temp_i++)
    OLED_Write_Data(0x80);   
         
  while(String[String_Length]!='\0')
    String_Length++;
    
  if(String_Length>18)
    Begin=0;
  else
    Begin=(signed char)((18-String_Length)/2);
        
  while(Temp_j<18)
  {    
    if(Temp_j<Begin)
    {
      OLED_Set_Pos(Position_x,1);      
    	for(Temp_i=0;Temp_i<6;Temp_i++)     
    	  OLED_Write_Data(0x80);
    }
    else
    {
      Temp_Char=String[Temp_j-Begin]-32;
      
      if(String[Temp_j-Begin]=='\0')
        Over_Flag=1;
      
      if(Over_Flag==0)                 
      {
        OLED_Set_Pos(Position_x,1);    
      	for(Temp_i=0;Temp_i<6;Temp_i++)     
    	    OLED_Write_Data(0x80|Font_6x8[Temp_Char][Temp_i]);      	
      }
      else
      {
        OLED_Set_Pos(Position_x,1);    
      	for(Temp_i=0;Temp_i<6;Temp_i++)     
      	  OLED_Write_Data(0x80);
      }
    }
  	Position_x+=6;
  	Temp_j++;
  }
}
Ejemplo n.º 6
0
void OLED_ShowChar(u8 x,u8 y,u8 chr)
{      	
	unsigned char c=0,i=0;	
		c=chr-' ';//得到偏移后的值			
		if(x>Max_Column-1){x=0;y=y+2;}
	
		OLED_Set_Pos(x,y);	
		for(i=0;i<8;i++)
		OLED_WR_Byte(F8X16[c*16+i],OLED_DATA);
		OLED_Set_Pos(x,y+1);
		for(i=0;i<8;i++)
		OLED_WR_Byte(F8X16[c*16+i+8],OLED_DATA);
		
}
Ejemplo n.º 7
0
void OLED_PrintPicture(void)
{
  uint8 data = 0;
  uint8 i,j,k;
  uint8 x,y;
  for (k = 0;k < 7;k++)//共计56行(后面四行单独算)
  {
    OLED_Set_Pos(5,k);//设置坐标,每次跳8行,60列
    x = k*8;//行起始位置
    y = (k+1)*8 - 1;//行计数(只要循环7行,还有一行单独算)
    for (i = 0;i< PICTURE_WIDTH;i++)
    {
      //高位显示在8行的最下面,低位显示在最上面
      //例如0x83的显示
      //* 1
      //* 1
      //  0
      //  0
      //  0 
      //  0 
      //  0
      //* 1
      //因此要从高到低扫描
      for (j = y;j > x;j--)//从第j行i列到第j+6行i列
      {
          data += PixData[j][i];//对应位置一或置零(图像已经二值化,只能是0或1)
          data<<=1;//左移一位
      }
      //j+7行i列
      data += PixData[j][i];//此处不要位移
      OLED_WrDat(data);//写入8行,1列的数据并显示
      data = 0;
    }
  }
  OLED_Set_Pos(5,7);//最后四行
  x = 56;//行起始位置
  y = 60;//行计数(只要循环4行)
  for (i = 0;i < PICTURE_WIDTH;i++)//每次写8行,图像宽度列  60列
  {
    for (j = x;j < y;j++)//从第56行i列到第59行i列
    {
        data += PixData[j][i];//对应位置一(图像已经二值化,只能是0或1)
        data<<=1;
    }
    data>>=1;
    OLED_WrDat(data);//写入8行,1列的数据并显示
    data = 0;
  }
}
Ejemplo n.º 8
0
void OLED_Write_Draw(unsigned char x,unsigned char y,signed char Asc) 
{
  unsigned char Temp_i;
  unsigned char Temp_Char;
	y=y*8;        

  Temp_Char=Asc;

  OLED_Set_Pos(y,x);    
	for(Temp_i=0;Temp_i<8;Temp_i++)     
	  OLED_Write_Data(Draw[Temp_Char*16+Temp_i]);
	OLED_Set_Pos(y,x+1);    
	for(Temp_i=0;Temp_i<8;Temp_i++)     
	  OLED_Write_Data(Draw[Temp_Char*16+Temp_i+8]);  
}
Ejemplo n.º 9
0
void OLED_Init(void)        
{
				OLED_IO_Init();
				GPIO_SetBits(OLED_Pin,OLED_SCL);
        GPIO_ResetBits(OLED_Pin,OLED_RST);//复位
				delay_ms(50);

        GPIO_SetBits(OLED_Pin,OLED_RST);//复位结束
	//从上电到下面开始初始化要有足够的时间,即等待RC复位完毕
  OLED_Write_Command(0xAE|0x00);			                // Display Off (0x00/0x01)
  OLED_Write_Command(0xD5);OLED_Write_Command(0x80);	// Set Clock as 100 Frames/Sec
  OLED_Write_Command(0xA8);OLED_Write_Command(0x3F);	// 1/64 Duty (0x0F~0x3F)
  OLED_Write_Command(0xD3);OLED_Write_Command(0x00);	// Shift Mapping RAM Counter (0x00~0x3F)
  OLED_Write_Command(0x40|0x00);			                // Set Mapping RAM Display Start Line (0x00~0x3F)
  OLED_Write_Command(0x8D);OLED_Write_Command(0x10|0x04);	    // Enable Embedded DC/DC Converter (0x00/0x04)
  OLED_Write_Command(0x20);OLED_Write_Command(0x02);		      // Set Page Addressing Mode (0x00/0x01/0x02)
  OLED_Write_Command(0xA0|0x01);                      // Set SEG/Column Mapping     0x00左右反置 0x01正常
  OLED_Write_Command(0xC0|0x08);			                // Set COM/Row Scan Direction 0x00上下反置 0x08正常
  OLED_Write_Command(0xDA);OLED_Write_Command(0x02|0x10);	    // Set Sequential Configuration (0x00/0x10)
  OLED_Write_Command(0x81);OLED_Write_Command(0xCF);	  // Set SEG Output Current
  OLED_Write_Command(0xD9);OLED_Write_Command(0xF1);	        // Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
  OLED_Write_Command(0xDB);OLED_Write_Command(0x40);			    // Set VCOM Deselect Level
  OLED_Write_Command(0xA4|0x00);		                  // Disable Entire Display On (0x00/0x01)
  OLED_Write_Command(0xA6|0x00);		                  // Disable Inverse Display On (0x00/0x01)  
  OLED_Write_Command(0xAE|0x01);		                  // Display On (0x00/0x01)
  OLED_Clear();                                       // 初始清屏
	OLED_Set_Pos(0,0); 
} 
Ejemplo n.º 10
0
/*
*@功能:显示汉字
*/
void OLED_ShowChinese(uint8_t x,uint8_t y,uint8_t no)
{      			    
		uint8_t t,adder=0;
		OLED_Set_Pos(x,y);	
    for(t=0;t<16;t++)
		{
				OLED_WR_Byte(Hzk[2*no][t],OLED_DATA);
				adder+=1;
    }	
		OLED_Set_Pos(x,y+1);	
    for(t=0;t<16;t++)
		{	
				OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);
				adder+=1;
		}					
}
Ejemplo n.º 11
0
   //写float型的数据,小数点后三位,小数点前两位
  void OLED_write_float3(unsigned char X,unsigned char Y,float s)
  {
     unsigned int num;
     
     OLED_Set_Pos(X,Y); 
     if (s < 0)//判断正负
     {
         s = 0 - s;
         OLED_write_char('-');
     }
     else 
     {
         OLED_write_char(' ');			
     }
     num = (unsigned int)(s * 1000);
	 if((num/10000)!=0)
	 OLED_write_char((num/10000)+0x30);//十位
	 num=num%10000;
	 if((num/1000)!=0)
     OLED_write_char((num/1000)+0x30);//个位
     num = num % 1000;
	 OLED_write_char('.');
     OLED_write_char((num/100)+0x30);//小数点后一位
     num = num % 100;
     OLED_write_char((num/10)+0x30);//小数点后两位
     num = num % 10;
     OLED_write_char((num)+0x30);//小数点后第三位  
  }
Ejemplo n.º 12
0
//显示汉字
void OLED_ShowCHinese(u8 x,u8 y,u8 no)
{      			    
	u8 t,adder=0;
	OLED_Set_Pos(x,y);	
    for(t=0;t<16;t++)
	{
		OLED_WR_Byte(Hzk[2*no][t],OLED_DATA);
		adder+=1;
    }	
	OLED_Set_Pos(x,y+1);	
    for(t=0;t<16;t++)
	{	
		OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);
		adder+=1;
    }					
}
Ejemplo n.º 13
0
/*********************LCD初始化************************************/
void OLED_Init(void)     
{
	OLED_DLY_ms(1);
	OLED_WrCmd(0xae);//--turn off oled panel
	OLED_WrCmd(0x00);//---set low column address
	OLED_WrCmd(0x10);//---set high column address
	OLED_WrCmd(0x40);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
	OLED_WrCmd(0x81);//--set contrast control register
	OLED_WrCmd(0xcf); // Set SEG Output Current Brightness
	OLED_WrCmd(0xa1);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
	OLED_WrCmd(0xc8);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
	OLED_WrCmd(0xa6);//--set normal display
	OLED_WrCmd(0xa8);//--set multiplex ratio(1 to 64)
	OLED_WrCmd(0x3f);//--1/64 duty
	OLED_WrCmd(0xd3);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
	OLED_WrCmd(0x00);//-not offset
	OLED_WrCmd(0xd5);//--set display clock divide ratio/oscillator frequency
	OLED_WrCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
	OLED_WrCmd(0xd9);//--set pre-charge period
	OLED_WrCmd(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
	OLED_WrCmd(0xda);//--set com pins hardware configuration
	OLED_WrCmd(0x12);
	OLED_WrCmd(0xdb);//--set vcomh
	OLED_WrCmd(0x40);//Set VCOM Deselect Level
	OLED_WrCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
	OLED_WrCmd(0x02);//
	OLED_WrCmd(0x8d);//--set Charge Pump enable/disable
	OLED_WrCmd(0x14);//--set(0x10) disable
	OLED_WrCmd(0xa4);// Disable Entire Display On (0xa4/0xa5)
	OLED_WrCmd(0xa6);// Disable Inverse Display On (0xa6/a7) 
	OLED_WrCmd(0xaf);//--turn on oled panel
	OLED_Fill(0x00);  //初始清屏
	OLED_Set_Pos(0,0); 	
} 
Ejemplo n.º 14
0
void OLED_Init(void)        
{
  //OLED Pins
  gpio_init (PORTA,12,GPO,1); 
  gpio_init (PORTA,13,GPO,1);
  gpio_init (PORTA,15,GPO,1); 
  gpio_init (PORTA,16,GPO,1);
  
  D0=1;
  //CS=1;	//预制SLK和SS为高电平   	
  
  RST=0;
  DLY_ms(50);
  RST=1;
	
	//从上电到下面开始初始化要有足够的时间,即等待RC复位完毕
  Set_Display_On_Off(0x00);		  // Display Off (0x00/0x01)
  Set_Display_Clock(0x80);		  // Set Clock as 100 Frames/Sec
  Set_Multiplex_Ratio(0x3F);		// 1/64 Duty (0x0F~0x3F)
  Set_Display_Offset(0x00);		  // Shift Mapping RAM Counter (0x00~0x3F)
  SetStartLine(0x00);			      // Set Mapping RAM Display Start Line (0x00~0x3F)
  Set_Charge_Pump(0x04);		    // Enable Embedded DC/DC Converter (0x00/0x04)
  SetAddressingMode(0x02);		  // Set Page Addressing Mode (0x00/0x01/0x02)
  Set_Segment_Remap(0x01);		  // Set SEG/Column Mapping     0x00左右反置 0x01正常
  Set_Common_Remap(0x08);			  // Set COM/Row Scan Direction 0x00上下反置 0x08正常
  Set_Common_Config(0x10);		  // Set Sequential Configuration (0x00/0x10)
  SetContrastControl(Brightness);	// Set SEG Output Current
  Set_Precharge_Period(0xF1);		// Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
  Set_VCOMH(0x40);			        // Set VCOM Deselect Level
  Set_Entire_Display(0x00);		  // Disable Entire Display On (0x00/0x01)
  Set_Inverse_Display(0x00);		// Disable Inverse Display On (0x00/0x01)  
  Set_Display_On_Off(0x01);		  // Display On (0x00/0x01)
  OLED_Fill(0x00);  //初始清屏
	OLED_Set_Pos(0,0); 
} 
Ejemplo n.º 15
0
void OLED_P8x16Str(unsigned char x,unsigned char y,unsigned char ch[])
{
	unsigned char c=0,i=0,j=0;
	while (ch[j]!='\0')
	{
		c =ch[j]-32;
		if(x>120){x=0;y++;}
		OLED_Set_Pos(x,y);
		for(i=0;i<8;i++)
		OLED_WrDat(F8X16[c*16+i]);
		OLED_Set_Pos(x,y+1);
		for(i=0;i<8;i++)
		OLED_WrDat(F8X16[c*16+i+8]);
		x+=8;
		j++;
	}
}
Ejemplo n.º 16
0
/*****************功能描述:显示16*16点阵  显示的坐标(x,y),y为页范围0~7****************************/
void OLED_P16x16Ch(unsigned char x,unsigned char y,unsigned char N)
{
	unsigned char wm = 0;
	unsigned int adder = 32 * N;  //  	
	OLED_Set_Pos(x , y);
	for ( wm = 0 ; wm < 16 ; wm ++ )  //             
	{
		OLED_WrDat(F16x16[adder]);	
		adder += 1;
	}      
	OLED_Set_Pos(x,y + 1); 
	for ( wm = 0;wm < 16 ; wm ++ ) //         
	{
		OLED_WrDat(F16x16[adder]);
		adder += 1;
	} 	  	
}
Ejemplo n.º 17
0
 //OLED_Write_String(2,1,"huang") 0246行,
void OLED_Write_String(unsigned char x,unsigned char y,signed char String[])
{
  unsigned char Temp_Char=0,Temp_i=0,Temp_j=0;
        
  while(String[Temp_j]!='\0')
  {    
    Temp_Char=String[Temp_j]-32;
    if(y>120){y=0;x++;}
    OLED_Set_Pos(y,x);    
  	for(Temp_i=0;Temp_i<8;Temp_i++)     
  	  OLED_Write_Data(Font_8x16[Temp_Char*16+Temp_i]);
  	OLED_Set_Pos(y,x+1);    
  	for(Temp_i=0;Temp_i<8;Temp_i++)     
  	  OLED_Write_Data(Font_8x16[Temp_Char*16+Temp_i+8]);  
  	y+=8;
  	Temp_j++;
  }
}
Ejemplo n.º 18
0
//==============================================================
//函数名: void LCD_PutPixel(uint8 x,uint8 y)
//功能描述:绘制一个点(x,y)
//参数:真实坐标值(x,y),x的范围0~127,y的范围0~64
//返回:无
//==============================================================
void OLED_PutPixel(uint8 x,uint8 y)
{
	uint8 data1;  //data1当前点的数据

  OLED_Set_Pos(x,y);
	data1 = 0x01<<(y%8);
	OLED_WrCmd(0xb0+(y>>3));
	OLED_WrCmd(((x&0xf0)>>4)|0x10);
	OLED_WrCmd((x&0x0f)|0x00);
	OLED_WrDat(data1);
}
Ejemplo n.º 19
0
/***********功能描述:显示显示BMP图片128×64起始点坐标(x,y),x的范围0~127,y为页的范围0~7*****************/
void Draw_BMP(unsigned char x0, unsigned char y0,unsigned char x1,unsigned char y1,const unsigned char BMP[])
{ 	
 unsigned int j = 0;
 unsigned char x,y;
	for ( y = y0 ; y < y1 ; y ++ )
	{
		OLED_Set_Pos(x0,y);				
	    for ( x = x0 ; x < x1 ; x ++ )
	    {      
	    	OLED_WrDat(BMP[j++]);	    	
	    }
	}
} 
Ejemplo n.º 20
0
void Position_Clear(unsigned char Position)
{
  unsigned char Temp_i;
  unsigned char Temp_y,Temp_x;
  switch(Position)
  {
    case 1:Temp_x=8,Temp_y=2;break;
    case 2:Temp_x=72,Temp_y=2;break;
    case 3:Temp_x=8,Temp_y=4;break;
    case 4:Temp_x=72,Temp_y=4;break;
    case 5:Temp_x=8,Temp_y=6;break;
    case 6:Temp_x=72,Temp_y=6;break;
    default:break;
  }
  
  OLED_Set_Pos(Temp_x,Temp_y);
  for(Temp_i=0;Temp_i<56;Temp_i++)
    OLED_Write_Data(0x00);
  OLED_Set_Pos(Temp_x,Temp_y+1);
  for(Temp_i=0;Temp_i<56;Temp_i++)
    OLED_Write_Data(0x00);
}
Ejemplo n.º 21
0
/*-----------------*OLED写七位字符串*-----------------*/
void OLED_Write_String_7(unsigned char y,unsigned char x,signed char String[])
{
  unsigned char Temp_Char=0,Temp_i=0,Temp_j=0,Temp_k=0;
  //unsigned char Over_Flag=0;
  unsigned char String_Length=0;      
        
  while(String[String_Length]!='\0')
    String_Length++;
  
  if(String_Length>7)
    String_Length=7;        
        
  while(Temp_j<7)
  {    
    String_Length++;
    if(String_Length>=8)
    {
      Temp_Char=String[Temp_k]-32;
      OLED_Set_Pos(x,y);    
    	for(Temp_i=0;Temp_i<8;Temp_i++)     
    	  OLED_Write_Data(Font_8x16[Temp_Char*16+Temp_i]);
    	OLED_Set_Pos(x,y+1);    
    	for(Temp_i=0;Temp_i<8;Temp_i++)     
    	  OLED_Write_Data(Font_8x16[Temp_Char*16+Temp_i+8]); 
    	Temp_k++; 
    }
    else
    {
      OLED_Set_Pos(x,y);    
    	for(Temp_i=0;Temp_i<8;Temp_i++)     
    	  OLED_Write_Data(Font_8x16[0]);
    	OLED_Set_Pos(x,y+1);    
    	for(Temp_i=0;Temp_i<8;Temp_i++)     
    	  OLED_Write_Data(Font_8x16[0]);  
    }
  	x+=8;
  	Temp_j++;
  }
}
Ejemplo n.º 22
0
void OLED_ShowChar_Mode(u8 x,u8 y,u8 chr,u8 Char_Size, u8 mode)
{
    unsigned char c=0,i=0;
    x += pos_x_offset;
    if(Char_Size == 8) {
        c=chr-'A';//得到偏移后的值
        OLED_Set_Pos(x,y);
        for(i=0; i<6; i++)
            if (mode == 1)
                OLED_WR_Byte(F6x8[c][i],OLED_DATA);
            else if (mode == 0)
                OLED_WR_Byte(~F6x8[c][i],OLED_DATA);
    } else if(Char_Size ==16) {
        c=chr-' ';//得到偏移后的值
        OLED_Set_Pos(x,y);
        for(i=0; i<8; i++)
            if (mode == 1)
                OLED_WR_Byte(F8X16[c*16+i], OLED_DATA);
            else if (mode == 0)
                OLED_WR_Byte(~F8X16[c*16+i], OLED_DATA);
        OLED_Set_Pos(x,y+1);
        for(i=0; i<8; i++)
            if (mode == 1)
                OLED_WR_Byte(F8X16[c*16+i+8], OLED_DATA);
            else if (mode == 0)
                OLED_WR_Byte(~F8X16[c*16+i+8], OLED_DATA);
    }
    /*
    else if (Char_Size == 24) {
        OLED_Set_Pos(x,y);
        for(i=0; i<6; i++)
            if (mode == 1)
                OLED_WR_Byte(F6x8[c][i],OLED_DATA);
            else if (mode == 0)
                OLED_WR_Byte(~F6x8[c][i],OLED_DATA);
    }
    */
}
Ejemplo n.º 23
0
  void OLED_write_1_num(unsigned char X,unsigned char Y,signed int s)
  {
     OLED_Set_Pos(X,Y);
	  if(s<0)
	 {
	 	s=0-s;
	 	OLED_write_char('-');
	 }
	 else
	 {
	   	OLED_write_char(' ');	
	 }
	 OLED_write_char(s+0x30);	 
  }
Ejemplo n.º 24
0
//清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!!
void OLED_Clear(void)
{
    u8 i,n;
    for(i=0; i<16; i++)
    {
        OLED_WR_Byte (0xb0+i,OLED_CMD);    //设置页地址(0~7)
        OLED_WR_Byte (0x00,OLED_CMD);      //设置显示位置—列低地址
        OLED_WR_Byte (0x10,OLED_CMD);      //设置显示位置—列高地址
        OLED_Set_Pos(pos_x_offset, i);
        for(n=0+pos_x_offset; n<Max_Column+pos_x_offset; n++)
            OLED_WR_Byte(0,OLED_DATA);
    } //更新显示

}
Ejemplo n.º 25
0
void OLED_ShowChar_Bold(u16 x,u8 y,u8 chr,u8 Char_Size)
{

    unsigned char c=0,i=0,j=0;
    x += pos_x_offset;
    c = chr-'0';//得到偏移后的值
    if(Char_Size == 32) {
        for (j=0;j<Char_Size/8;j++) {
            OLED_Set_Pos(x,y+j);
            for(i=0; i<16; i++)
                OLED_WR_Byte(BoldF16x32[c][i+j*16],OLED_DATA);
        }
    }
}
Ejemplo n.º 26
0
void Draw_Landzo(void)
{
  uint16 ii=0;
  uint8 x,y;

	for(y=2;y<8;y++)
	{
		OLED_Set_Pos(40,y);
            for(x=40;x<90;x++)
	    {
	    	OLED_WrDat(LANDZO_LOGO[ii++]);
	    }
	}
}
Ejemplo n.º 27
0
void Draw_LibLogo(void)
{
  uint16 ii=0;
  uint8 x,y;

	for(y=0;y<8;y++)
	{
		OLED_Set_Pos(34,y);
    for(x=34;x<94;x++)
	    {
	    	OLED_WrDat(LIBLOGO60x58[ii++]);
	    }
	}
}
Ejemplo n.º 28
0
//==============================================================
//函数名:LCD_P6x8Str(uint8 x,uint8 y,uint8 *p)
//功能描述:写入一组标准ASCII字符串
//参数:显示的位置(x,y),y为页范围0~7,要显示的字符串
//返回:无
//==============================================================
void OLED_P6x8Str(uint8 x,uint8 y,uint8 ch[])
{
  uint8 c=0,i=0,j=0;
  while (ch[j]!='\0')
  {
    c =ch[j]-32;
    if(x>126){x=0;y++;}
    OLED_Set_Pos(x,y);
  	for(i=0;i<6;i++)
  	  OLED_WrDat(F6x8[c][i]);
  	x+=6;
  	j++;
  }
}
Ejemplo n.º 29
0
void Dis_Head8x16(signed char String[])
{
  unsigned char Temp_Char=0,Temp_i=0,Temp_j=0,Position_x=8;
  unsigned char Over_Flag=0;
  unsigned char String_Length=0; 
  unsigned char Begin=0;     
        
  while(String[String_Length]!='\0')
    String_Length++;
    
  if(String_Length>12)
    Begin=0;
  else
    Begin=(signed char)((14.0-String_Length)/2);
        
  while(Temp_j<12)
  {    
    if(Temp_j<Begin)
    {
      OLED_Set_Pos(Position_x,0);      
    	for(Temp_i=0;Temp_i<8;Temp_i++)     
    	  OLED_Write_Data(Font_8x16[0]);
    	OLED_Set_Pos(Position_x,1);   
    	for(Temp_i=0;Temp_i<8;Temp_i++)     
    	  OLED_Write_Data(Font_8x16[0]); 
    }
    else
    {
      Temp_Char=String[Temp_j-Begin]-32;
      
      if(String[Temp_j-Begin]=='\0')
        Over_Flag=1;
      
      if(Over_Flag==0)                 
      {
        OLED_Set_Pos(Position_x,0);    
      	for(Temp_i=0;Temp_i<8;Temp_i++)     
      	  OLED_Write_Data(Font_8x16[Temp_Char*16+Temp_i]);
      	OLED_Set_Pos(Position_x,1);    
      	for(Temp_i=0;Temp_i<8;Temp_i++)     
      	  OLED_Write_Data(Font_8x16[Temp_Char*16+Temp_i+8]);   
      }
      else
      {
        OLED_Set_Pos(Position_x,0);    
      	for(Temp_i=0;Temp_i<8;Temp_i++)     
      	  OLED_Write_Data(Font_8x16[0]);
      	OLED_Set_Pos(Position_x,1);    
      	for(Temp_i=0;Temp_i<8;Temp_i++)     
      	  OLED_Write_Data(Font_8x16[0]);  
      }
    }
    
  	Position_x+=8;
  	Temp_j++;
  }
}
Ejemplo n.º 30
0
/* What we input are (0,0,Max_Column,8,BMP1) */
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1, const unsigned char BMP[])
{
    unsigned int j=0;
    unsigned char x,y;
    x0 += pos_x_offset;
    x1 += pos_x_offset;
    for(y=y0; y<y1; y++)
    {
        OLED_Set_Pos(x0,y);
        for(x=x0; x<x1; x++)
        {
            OLED_WR_Byte(BMP[j++],OLED_DATA);
        }
    }
}