3.5寸240128OLED显示模块例程 HGS2401281例程

发布时间:2019/9/12 9:56:52

   3.5寸240128OLED显示模块分辨率为240*128.内置SSD1322及其兼容控制器,显示效果为黑底绿字或黑底黄字,电压5/3v可选,接口并口串口可选,中文字库可选
   例程如下:

#include<reg51.h>

#include <string.h>

#include <intrins.h>

#include <math.h>

#define uchar unsigned char

#define uint unsigned int

#define DATA  P1

sbit CD  = P3^0;

sbit WR1 = P3^1;

sbit RD1 = P3^2;

sbit CS  = P3^3;

sbit RES = P3^4;

uchar RAM_data[4];

uchar INV=0;

//逐行式  顺向(高位在前)

uchar code table_88[]={

0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"0",0*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,/*"1",1*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x04,0x04,0x08,0x10,0x20,0x42,0x7E,0x00,0x00,/*"2",2*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x3C,0x42,0x42,0x04,0x18,0x04,0x02,0x02,0x42,0x44,0x38,0x00,0x00,/*"3",3*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x24,0x44,0x44,0x7E,0x04,0x04,0x1E,0x00,0x00,/*"4",4*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x58,0x64,0x02,0x02,0x42,0x44,0x38,0x00,0x00,/*"5",5*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x1C,0x24,0x40,0x40,0x58,0x64,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"6",6*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x7E,0x44,0x44,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,/*"7",7*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,/*"8",8*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x26,0x1A,0x02,0x02,0x24,0x38,0x00,0x00,/*"9",9*/

/* (8 X 16 , 宋体 )*/  

};

uchar code table_816[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00,/*"w",0*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00,/*"w",1*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xD7,0x92,0x92,0xAA,0xAA,0x44,0x44,0x00,0x00,/*"w",2*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,/*".",3*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00,/*"c",4*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0xC0,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,/*"h",5*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,/*"i",6*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDC,0x62,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,/*"n",7*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x1E,0x22,0x42,0x42,0x3F,0x00,0x00,/*"a",8*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",9*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,/*"l",10*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00,/*"c",11*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x06,0x02,0x02,0x02,0x1E,0x22,0x42,0x42,0x42,0x26,0x1B,0x00,0x00,/*"d",12*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x49,0x49,0x49,0x49,0x49,0xED,0x00,0x00,/*"m",13*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,/*"o",14*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x06,0x02,0x02,0x02,0x1E,0x22,0x42,0x42,0x42,0x26,0x1B,0x00,0x00,/*"d",15*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC6,0x42,0x42,0x42,0x42,0x46,0x3B,0x00,0x00,/*"u",16*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00,/*"l",17*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x40,0x40,0x42,0x3C,0x00,0x00,/*"e",18*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x40,0x3C,0x02,0x42,0x7C,0x00,0x00,/*"s",19*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,/*".",20*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00,/*"c",21*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,/*"o",22*/

/* (8 X 16 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x49,0x49,0x49,0x49,0x49,0xED,0x00,0x00,/*"m",23*/

/* (8 X 16 , 宋体 )*/

};

uchar code table_1616[]={

//逐行式  顺向(高位在前)

0x40,0x40,0x23,0xFC,0x20,0x40,0x0B,0xFC,0x88,0x40,0x57,0xFC,0x50,0x00,0x13,0xF8,

0x22,0x08,0x23,0xF8,0xE2,0x08,0x23,0xF8,0x22,0x08,0x22,0x08,0x22,0x28,0x22,0x10,/*"清",0*/

/* (16 X 16 , 宋体 )*/

0x00,0x00,0x40,0x80,0x30,0x80,0x10,0x80,0x0F,0xFC,0x00,0x80,0x00,0x80,0xE0,0x80,

0x21,0x40,0x21,0x20,0x22,0x18,0x24,0x0C,0x28,0x08,0x50,0x02,0x8F,0xFC,0x00,0x00,/*"达",1*/

/* (16 X 16 , 宋体 )*/

0x01,0x00,0x21,0x10,0x19,0x18,0x0D,0x10,0x09,0x20,0x01,0x04,0x7F,0xFE,0x04,0x40,

0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x42,0x08,0x42,0x10,0x42,0x20,0x3E,0x40,0x00,/*"光",2*/

/* (16 X 16 , 宋体 )*/

0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,

0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x02,0x01,0x02,0x00,0xFE,0x00,0x00,/*"电",3*/

/* (16 X 16 , 宋体 )*/

0x10,0x20,0x10,0x20,0x10,0x20,0xFD,0xFE,0x10,0x20,0x14,0x20,0x19,0xFC,0x31,0x08,

0xD0,0x88,0x10,0x90,0x10,0x60,0x10,0x60,0x10,0x90,0x11,0x0E,0x56,0x04,0x20,0x00,/*"技",4*/

/* (16 X 16 , 宋体 )*/

0x01,0x00,0x01,0x20,0x01,0x10,0x01,0x00,0xFF,0xFE,0x01,0x00,0x03,0x80,0x05,0x40,

0x05,0x20,0x09,0x10,0x11,0x18,0x21,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,0x00,0x00,/*"术",5*/

/* (16 X 16 , 宋体 )*/

0x01,0x00,0x01,0x00,0x7F,0xFE,0x02,0x00,0x04,0x00,0x0F,0xF0,0x18,0x10,0x28,0x10,

0x4F,0xF0,0x88,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x90,0x08,0x70,0x08,0x20,/*"有",6*/

/* (16 X 16 , 宋体 )*/

0x00,0x00,0xFB,0xF8,0x92,0x08,0x93,0xF8,0xA2,0x08,0xA2,0x08,0x93,0xF8,0x8A,0x80,

0x8A,0x48,0xAA,0x50,0x92,0x20,0x82,0x20,0x82,0x10,0x82,0x8E,0x83,0x04,0x82,0x00,/*"限",7*/

/* (16 X 16 , 宋体 )*/

0x00,0x00,0x04,0x40,0x06,0x40,0x04,0x40,0x08,0x20,0x08,0x10,0x10,0x18,0x22,0x0E,

0x43,0x04,0x02,0x00,0x04,0x20,0x08,0x10,0x11,0xF8,0x3F,0x18,0x10,0x10,0x00,0x00,/*"公",8*/

/* (16 X 16 , 宋体 )*/

0x00,0x00,0x3F,0xFC,0x00,0x04,0x00,0x04,0x7F,0xE4,0x00,0x04,0x00,0x04,0x3F,0xC4,

0x20,0x44,0x20,0x44,0x3F,0xC4,0x20,0x44,0x20,0x04,0x00,0x14,0x00,0x08,0x00,0x00,/*"司",9*/

/* (16 X 16 , 宋体 )*/

0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x04,0x40,0x04,0x40,

0x44,0x48,0x24,0x48,0x14,0x50,0x14,0x60,0x04,0x40,0xFF,0xFE,0x00,0x00,0x00,0x00,/*"显",10*/

/* (16 X 16 , 宋体 )*/

0x00,0x00,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x01,0x00,0x01,0x00,

0x11,0x20,0x11,0x10,0x21,0x08,0x41,0x0C,0x81,0x04,0x01,0x00,0x05,0x00,0x02,0x00,/*"示",11*/

/* (16 X 16 , 宋体 )*/

0x20,0x90,0x20,0x90,0x27,0xFC,0x20,0x90,0xFB,0xF8,0x22,0x08,0x73,0xF8,0x6A,0x08,

0xA3,0xF8,0xA0,0x40,0x27,0xFE,0x20,0x40,0x20,0xA0,0x20,0x98,0x21,0x0E,0x26,0x04,/*"模",12*/

/* (16 X 16 , 宋体 )*/

0x10,0x00,0x19,0xF8,0x11,0x08,0x25,0x08,0x25,0x08,0x79,0xF8,0x09,0x08,0x11,0x08,

0x21,0x08,0x7D,0xF8,0x01,0x08,0x01,0x08,0x0D,0x08,0x73,0xFE,0x00,0x00,0x00,0x00,/*"组",13*/

/* (16 X 16 , 宋体 )*/

};

uchar code table_3232[][128]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x00,0x00,0xF8,0x0F,0x00,

0x03,0xC0,0x03,0xC0,0x07,0x80,0x01,0xE0,0x0F,0x00,0x00,0xF0,0x1F,0x00,0x00,0xF8,

0x1F,0x00,0x00,0xF8,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,

0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,

0x1F,0x00,0x00,0x78,0x1F,0x00,0x00,0xF8,0x0F,0x80,0x00,0xF0,0x07,0x80,0x01,0xE0,

0x01,0xE0,0x03,0xC0,0x00,0x78,0x0F,0x00,0x00,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"O",0*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x00,0x00,0x03,0xC0,0x00,0x00,

0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,

0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,

0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,

0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x0C,0x03,0xC0,0x00,0x08,

0x03,0xC0,0x00,0x38,0x03,0xC0,0x00,0xF0,0x3F,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"L",1*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xE0,0x03,0xC0,0x01,0xF0,

0x03,0xC0,0x00,0x78,0x03,0xC0,0x00,0x18,0x03,0xC0,0x00,0x0C,0x03,0xC0,0x00,0x00,

0x03,0xC0,0x03,0x00,0x03,0xC0,0x03,0x00,0x03,0xC0,0x07,0x00,0x03,0xFF,0xFF,0x00,

0x03,0xC0,0x07,0x00,0x03,0xC0,0x03,0x00,0x03,0xC0,0x03,0x00,0x03,0xC0,0x00,0x00,

0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x06,0x03,0xC0,0x00,0x0C,

0x03,0xC0,0x00,0x1C,0x03,0xC0,0x00,0xF8,0x3F,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"E",2*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,0x00,0x07,0x80,0x3E,0x00,

0x07,0x80,0x07,0x80,0x07,0x80,0x03,0xE0,0x07,0x80,0x01,0xF0,0x07,0x80,0x00,0xF8,

0x07,0x80,0x00,0xF8,0x07,0x80,0x00,0x7C,0x07,0x80,0x00,0x7C,0x07,0x80,0x00,0x7C,

0x07,0x80,0x00,0x7C,0x07,0x80,0x00,0x7C,0x07,0x80,0x00,0x7C,0x07,0x80,0x00,0x78,

0x07,0x80,0x00,0xF8,0x07,0x80,0x00,0xF8,0x07,0x80,0x01,0xF0,0x07,0x80,0x03,0xE0,

0x07,0x80,0x0F,0x80,0x07,0x80,0x7E,0x00,0x7F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"D",3*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x00,0x01,0xE0,0x1F,0x00,

0x07,0x80,0x07,0xC0,0x0F,0x00,0x03,0xE0,0x0F,0x80,0x03,0xE0,0x0F,0xC0,0x03,0xE0,

0x07,0xC0,0x03,0xE0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0x80,0x00,0x00,0x1F,0x00,

0x00,0x00,0x3C,0x00,0x00,0x00,0x70,0x00,0x00,0x01,0xC0,0x00,0x00,0x07,0x00,0x00,

0x00,0x1C,0x00,0x00,0x00,0x70,0x00,0x30,0x01,0xC0,0x00,0x30,0x07,0x00,0x00,0x60,

0x0E,0x00,0x00,0xE0,0x1F,0xFF,0xFF,0xE0,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"2",0*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x3E,0x00,

0x00,0x00,0x7E,0x00,0x00,0x00,0xDE,0x00,0x00,0x01,0x9E,0x00,0x00,0x07,0x1E,0x00,

0x00,0x0C,0x1E,0x00,0x00,0x18,0x1E,0x00,0x00,0x30,0x1E,0x00,0x00,0xE0,0x1E,0x00,

0x01,0x80,0x1E,0x00,0x03,0x00,0x1E,0x00,0x06,0x00,0x1E,0x00,0x18,0x00,0x1E,0x00,

0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x1E,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x1E,0x00,

0x00,0x00,0x1E,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x3F,0x00,0x00,0x0F,0xFF,0xF8,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"4",1*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF8,0x00,0x00,0x78,0x1E,0x00,

0x01,0xE0,0x07,0x80,0x03,0xC0,0x03,0xC0,0x07,0xC0,0x01,0xE0,0x0F,0x80,0x01,0xF0,

0x0F,0x80,0x01,0xF0,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,

0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,

0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x07,0xC0,0x01,0xE0,0x03,0xC0,0x03,0xC0,

0x01,0xE0,0x07,0x80,0x00,0x78,0x1E,0x00,0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"0",2*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x01,0xC0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x01,0xC0,0x00,

0x1F,0x81,0xC0,0xFC,0x1F,0xE1,0xC3,0xFC,0x03,0xF8,0x8F,0xE0,0x00,0x1E,0xBC,0x00,

0x00,0x01,0xC0,0x00,0x00,0x1E,0xBC,0x00,0x03,0xF8,0x8F,0xE0,0x1F,0xE1,0xC3,0xFC,

0x1F,0x81,0xC0,0xFC,0x00,0x01,0xC0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,

0x00,0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"*",3*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x03,0xC0,0x00,

0x01,0xFF,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,

0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,

0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,

0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,

0x00,0x03,0xC0,0x00,0x00,0x07,0xE0,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",4*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x00,0x01,0xE0,0x1F,0x00,

0x07,0x80,0x07,0xC0,0x0F,0x00,0x03,0xE0,0x0F,0x80,0x03,0xE0,0x0F,0xC0,0x03,0xE0,

0x07,0xC0,0x03,0xE0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0x80,0x00,0x00,0x1F,0x00,

0x00,0x00,0x3C,0x00,0x00,0x00,0x70,0x00,0x00,0x01,0xC0,0x00,0x00,0x07,0x00,0x00,

0x00,0x1C,0x00,0x00,0x00,0x70,0x00,0x30,0x01,0xC0,0x00,0x30,0x07,0x00,0x00,0x60,

0x0E,0x00,0x00,0xE0,0x1F,0xFF,0xFF,0xE0,0x1F,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"2",5*/

/* (32 X 32 , 宋体 )*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x00,0x01,0xF0,0x0F,0x80,

0x07,0x80,0x01,0xE0,0x0F,0x00,0x01,0xF0,0x0F,0x00,0x00,0xF0,0x0F,0x00,0x00,0xF0,

0x07,0xC0,0x00,0xE0,0x03,0xF0,0x01,0xC0,0x01,0xFE,0x07,0x80,0x00,0x3F,0xFC,0x00,

0x00,0x73,0xFE,0x00,0x01,0xC0,0x3F,0x80,0x07,0x80,0x07,0xE0,0x0F,0x00,0x01,0xF0,

0x1E,0x00,0x00,0xF8,0x1E,0x00,0x00,0x78,0x1E,0x00,0x00,0x78,0x0F,0x00,0x00,0xF0,

0x07,0x80,0x01,0xE0,0x01,0xF0,0x07,0x80,0x00,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"8",6*/

/* (32 X 32 , 宋体 )*/

};

/******************************************************************

     延时子程序

*****************************************************************/

void uDelay(uchar n)

{

while(n--);

}

void delay(uint z)

{

uint x,y;

for(x=z;x>0;x--)

  for(y=124;y>0;y--);

}

void delay_100us(uchar z)

{

z=z*16;

while(z--);

}

/*********************************************************************

  写入指令和数据

************************************************************************/

void wr_data(uchar b) //写数据  ;

{

RD1=1;

CS=0;

CD=1;

WR1=0;

DATA=b;

//uDelay(1);

WR1=1;

//_nop_();

CS=1;

}

void wr_com(uchar com)  //写命令;

{

RD1=1;

CS=0;

CD=0;

WR1=0;

DATA=com;

WR1=1;

CS=1;

}

/*********************************************************************

 转换程序 :16阶灰度,一个RAM数据8位,4位一个像素,想控制8个点,就须写4个的RAM数据;

 因为一个地址16位,因此也等与写两个地址;

************************************************************************/

void change(uchar b)

{

uchar i;

for(i=0;i<4;i++)  

   {    

    switch(b&0xc0)

         {

     case 0x00: RAM_data[i]=0x00;break;

         case 0x40:   RAM_data[i]=0x0f;break;

     case 0x80: RAM_data[i]=0xf0;break;

         case 0xc0: RAM_data[i]=0xff;break;

       default:   break;

     }

    b=b<<2;                              

    wr_data(RAM_data[i]);              

   }

}

/*********************************************************************

工作窗口设置;

************************************************************************/

void SET_AW(uchar a,uchar b,uchar c,uchar d)

{

wr_com(0x15);

wr_data(0x18+a);

wr_data(0x18+b);

wr_com(0x75);  

wr_data(c);    

wr_data(d);  

}

/*********************************************************************

全屏程序;

************************************************************************/

void all_screen(uchar b)  //480*128整个RAM区;

{

uchar i,j;

wr_com(0x15);

wr_data(0x00);

wr_data(0x77); //120*4=480;

wr_com(0x75);  

wr_data(0x00);    

wr_data(0x7f);//128;  

wr_com(0x5c);

for(j=0;j<128;j++)

   for(i=0;i<120;i++) {wr_data(b) ; wr_data(b) ; }

}

void fill(uchar b) //256*64区域;

{

uchar i,j;

SET_AW(0,59,0,127);

wr_com(0x5c);

for(j=0;j<128;j++)

   for(i=0;i<60;i++)

{wr_data(b) ; wr_data(b) ; }

}

/*********************************************************************

写入8*8字符;

x y-->行列地址;n首字符序号,end_n尾字符序号;

************************************************************************/

void word_88(uchar x,uchar y,uchar n) //8*8字符单个写;

{

uchar i;

SET_AW(x,x+1,y,y+7);

wr_com(0x5c);

if(INV) {for(i=0;i<8;i++)  change(~table_88[8*n+i]);}

else    {for(i=0;i<8;i++)  change(table_88[8*n+i]);}

}

void show_88(uchar x,uchar y,uchar n,uchar end_n)//写入y一串8*8字符,可自动换行;

{

uchar i;

for(i=n;i<=end_n;i++)

   {

if(x>0x3e) {y=y+8;x=0;}

   word_88(x,y,i);

x=x+2;

}

}

/*********************************************************************

写入8*16 16*16字符;

x y-->行列地址;n首字符序号,end_n尾字符序号;

************************************************************************/

void word_816(uchar x,uchar y,uchar n) //8*16字符单个写;

{

uchar i;

SET_AW(x,x+1,y,y+15);

wr_com(0x5c);

if(INV)  {for(i=0;i<16;i++)  change(~table_816[16*n+i]); }  

else      {for(i=0;i<16;i++)  change(table_816[16*n+i]); }    

}  

void word_1616(uchar x,uchar y,uchar n) //16*16字符单个写;

{

uchar i;

SET_AW(x,x+3,y,y+15);

wr_com(0x5c);

if(INV)   {for(i=0;i<32;i++)  change(~table_1616[32*n+i]);}

else   {for(i=0;i<32;i++)  change(table_1616[32*n+i]); }    

}

void show_816(uchar x,uchar y,uchar n,uchar end_n)//写入一串8*16,可自动换行;

{

uchar i;

for(i=n;i<=end_n;i++)

   {

if(x>0x3e) {y=y+16;x=0;}

   word_816(x,y,i);

x=x+2;

}

}

void show_1616(uchar x,uchar y,uchar n,uchar end_n)//写入一串16*16,可自动换行;

{

uchar i;

for(i=n;i<=end_n;i++)

   {

if(x>0x3c) {y=y+16;x=0;}

   word_1616(x,y,i);

x=x+4;

}

}

/*********************************************************************

写入32*32字符;

x y-->行列地址;n首字符序号,end_n尾字符序号;

************************************************************************/

void word_3232(uchar x,uchar y,uchar n) //32*32字符单个写;

{

uchar i;

SET_AW(x,x+7,y,y+32);

wr_com(0x5c);

if(INV)   {for(i=0;i<128;i++)  change(~table_3232[n][i]);}

else   {for(i=0;i<128;i++)  change(table_3232[n][i]); }    

}

void show_3232(uchar x,uchar y,uchar n,uchar end_n)//写入一串32*32;可自动换行;

{

uchar i;

for(i=n;i<=end_n;i++)

   {

if(x>0x38) {y=y+32;x=0;}

   word_3232(x,y,i);

x=x+8;

}

}

/*********************************************************************

  初始化函数;

************************************************************************/

void init(void)

{

     delay(50);

     RES=1;delay(1);

     RES=0;delay(1);

     RES=1;delay(1);

// 准备接受命令;

     wr_com(0xFD);

 wr_data(0x12);       /* 12H接受,16H拒绝 */

//休眠开关;

 wr_com(0xAE);   /* AEH开休眠,AF关休眠 */

// 设置列窗口;

 wr_com(0x15);

 wr_data(0x24);      

 wr_data(0x5f);            /*256列 */

//设置行窗口;

 wr_com(0x75);

 wr_data(0x00);      

 wr_data(0x7f);            /*64行 */

// 设置可逆地图;

 wr_com(0xA0);

 wr_data(0x36);        /* 选高字节在前,COM扫描反向 ,水平地址模式 */

 wr_data(0x01);      /*选双屏模式 */

// 设置起始行;

 wr_com(0xA1);

 wr_data(0x00);        /* 0 */

// 设置显示分支;

 wr_com(0xA2);    

 wr_data(0x00);            /* 无分支 */

// 设置显示模式;

 wr_com(0xA6);        /* A4H全关,A5H全开,A6H正常,A7H反显 */

 wr_com(0xA6);

// 设置反显;

     wr_com(0xA8);

  wr_data(0x00);      

  wr_data(0x7f);

// 设置部分显示;

 wr_com(0xA9);        /* A8H进入部分显示,A9H退出 */

// Vdd来源;

 wr_com(0xAB);

 wr_data(0x01);       /* 00H为外部,01H为内部 */

// 设置P1 P2 ;

 wr_com(0xB1);       /*P1=29,P2=7 */

 wr_data(0xd2);

// 设置D和Fosc;

 wr_com(0xB3);  

 //wr_data(0xe1);           /*F=9,D=1 */

 wr_data(0xf1);

// 设置显示质量和Vsl来源;

 wr_com(0xB4);  

 wr_data(0xA0);       /* A0H为外部Vsl,A2H为内部Vsl */

 wr_data(0xfd);       /*FDH为提高质量,B5H为正常 */

//设置Tp3

     wr_com(0xB6);

 wr_data(0x08);

//设置Vp2;

    wr_com(0xBB);

wr_data(0x1F);

// 设置Vcomh;

    wr_com(0xBE);

wr_data(0x06); /* Vcomh=0.86Vcc  */  

//设置GPIO;

     wr_com(0xB5);

 wr_data(0x0a);  

//设置灰度值;

 wr_com(0xB8);

 wr_data(0x0c);

 wr_data(0x18);

 wr_data(0x24);

 wr_data(0x30);

 wr_data(0x3c);

 wr_data(0x48);

 wr_data(0x54);

 wr_data(0x60);

 wr_data(0x6c);

 wr_data(0x78);

 wr_data(0x84);

 wr_data(0x90);

 wr_data(0x9c);

 wr_data(0xa8);

 wr_data(0x93);//b4  

//使能灰阶;

    wr_com(0x00);

//设置对比度;

    wr_com(0xC1);

wr_data(0x80); /* 共256级选第128级  */  

//设置SEG电流范围;

    wr_com(0xC7);

wr_data(0x0F); /* 满范围  */

//设置显示行;

    wr_com(0xCA);

wr_data(0x7F);  /* 64 */  

//设置显示质量;

    wr_com(0xD1);

wr_data(0xA2);

wr_data(0x20);

all_screen(0X00); //清屏

    wr_com(0xAF); /* 开显示  */  

}

main()

{

uchar i,j=0;

init();

for(i=0;i<8;i++)

{ j=i*16;

 show_1616(2,j,0,13); //清达光电技术有限公司显示模组

}

delay(1000);

fill(0x00); //清屏

show_3232(14,5,0,3);  //OLED

show_3232(2,37,4,10); //240*128

show_1616(10,80,0,9);//清达光电技术有限公司

show_816(6,100,0,23);//www.china-lcdmodules.com

while(1);

}


显示效果图如下:

上一篇:液晶模块的常见不良现象及原因分析
下一篇:HGSC2561283串口DEMO程序