看一个这个图片,手机拍的不是很清楚;不过基本上看的清,具体问题是这样的。芯片采用新华龙的C8051F347这个芯片,
OLED屏是12864 主控是SH1101A 。图片整体向右移了半个阿拉数字的宽度。请教大家有知道的帮看看。。。。谢谢!!!!
这个是源程序,,,,,希望有知道高手指点一下。。先感激一下!!!!!
void disc(unsigned char X,unsigned char Y,unsigned char * c)//显示英文//
{
unsigned char n;
Woled_Command (0xb7-(Y<<1));
if(X%2)
Woled_Command (0x08);
else
Woled_Command (0x00);
Woled_Command (0x10+(X>>1));
for(n=0;n<=15;n+=2)
Woled_Data(*(c+n));
Woled_Command (0xb7-(Y<<1)-1);
if(X%2)
Woled_Command (0x08);
else
Woled_Command (0x00);
Woled_Command (0x10+(X>>1));
for(n=1;n<=15;n+=2)
Woled_Data(*(c+n));
}
// X is 0 to 7
void dish(unsigned char X,unsigned char Y,unsigned char * h)//显示汉字//
{
unsigned char n;
Woled_Command (0xb7-(Y<<1));
if(X%2)
Woled_Command (0x08);
else
Woled_Command (0x00);
Woled_Command (0x10+(X>>1));
for(n=0;n<=31;n+=2)
Woled_Data(*(h+n));
Woled_Command (0xb7-(Y<<1)-1);
if(X%2)
Woled_Command (0x08);
else
Woled_Command (0x00);
Woled_Command (0x10+(X>>1));
for(n=1;n<=31;n+=2)
Woled_Data(*(h+n));
}
void disn(unsigned char X,unsigned char Y,unsigned char n)//显示数字//
{
unsigned char m;
Woled_Command (0xb7-(Y<<1));
if(X%2)
Woled_Command (0x08);
else
Woled_Command (0x00);
Woled_Command (0x10+(X>>1));
//for(n=0;n<=15;n+=2)
//Woled_Data(*(c+n));
for(m=0;m<=15;m+=2)
Woled_Data(*(num[n]+m));
Woled_Command (0xb7-(Y<<1)-1);
if(X%2)
Woled_Command (0x08);
else
Woled_Command (0x00);
Woled_Command (0x10+(X>>1));
for(m=1;m<=15;m+=2)
Woled_Data(*(num[n]+m));
}
void Woled_init(void)
{
Woled_RES=0;
Delay_us(30);
Woled_RES=1;
Delay_us(20);
Woled_Command(0xAE); //DOT MARTIX DISPLAY OFF
Woled_Command(0x40); //SET DISPLAY START LINE(40H-7FH)
Woled_Command(0xA1); //SET SEGMENT RE-MAP(0A0H-0A1H) //显示左右方向调整 镜像。
Woled_Command(0xA4); //ENTIRE DISPLAY OFF(0A4H-0A5H) //显示方式。
Woled_Command(0xA6); //SET NORMAL DISPLAY(0A6H-0A7H) //反白和标准显示方式。
Woled_Command(0xC0); //COM SCAN COM1-COM64(0C8H,0C0H) //显示上理向调整,镜像。
Woled_Command(0xA8); //SET MULTIPLEX RATIO 64
Woled_Command(0x3F);
Woled_Command(0xD3); //SET DISPLAY OFFSET(OOH-3FH) //
Woled_Command(0x00);
Woled_Command(0xD5); //SET FRAME FREQUENCY
Woled_Command(0x50); //100Hz
Woled_Command(0xD9); //SET DIS-/PRE-_CHARGE PERIOD
Woled_Command(0x23);
Woled_Command(0xDA); //COM PIN CONFIGURATION(02H,12H)
Woled_Command(0x12);
Woled_Command(0xDB); //SET VCOM DESELECT LEVEL(035H)//
Woled_Command(0x35);
Woled_Command(0x81); //CONTARST CONTROL(00H-0FFH)
Woled_Command(0x4F);
//Woled_Command(0xAD); //SET DC/DC BOOSTER(8AH=OFF,8BH=ON)
//Woled_Command(0x8A);
Woled_Command(0xAF); //DSPLAY ON
}
void main()
{
System_Init();
Woled_init();
Delay_us(500);
/****-------------------数字测试---------***/
//第一列显示数字测试//
disn(1,0,0);
disn(2,0,1);
disn(3,0,2);
disn(4,0,3);
disn(5,0,4);
disn(6,0,5);
disn(7,0,6);
disn(8,0,7);
disn(9,0,8);
disn(10,0,9);
disn(11,0,0);
disn(12,0,1);
disn(13,0,2);
disn(14,0,3);
disn(15,0,4);
disn(16,0,5);
//第二列汉字测试//
dish(1,1,yi);
dish(3,1,er);
dish(5,1,san);
dish(7,1,si);
dish(9,1,wu);
dish(11,1,liu);
dish(13,1,ri);
dish(15,1,qi);
//第三列显示汉字测试//
dish(1,2,year);
dish(3,2,month);
dish(5,2,day);
dish(7,2,xing);
dish(9,2,qi);
dish(11,2,wu);
dish(13,2,si);
dish(15,2,qi);
//第四列显示英文测试//
disc(1,3,h);
disc(2,3,d);
disc(3,3,w);
disc(4,3,z);
disc(5,3,dot);
disc(6,3,c);
disc(7,3,m);
disc(8,3,o);
disc(9,3,w);
disc(10,3,mao);
disc(10,3,mao);
disc(11,3,mp);
disc(12,3,c);
disc(13,3,o);
disc(14,3,m);
disc(15,3,d);
disc(16,3,w);
//-----------------数字测试-------//
while(1);
}
这个是OLED的主控芯片资料。。。。。。。。。。
SH1101A.pdf
(832.31 KB)
|