- //型号T12864C048B
- #include <reg51.h>
- #include <intrins.h>
- #include <absacc.h>
- #define uchar unsigned char
- #define uint unsigned int
- sfr CLK_DIV =0x97;
- sfr P1M1 =0x91;
- sfr P1M0 =0x92;
- sfr P3M1 =0xB1;
- sfr P3M0 =0xB2;
-
- sbit R_S= P3^5;//指令/数据选择信号
- sbit RES= P3^4;//复位信号
- sbit SCK= P1^6;
- sbit SDA= P1^7;
- sbit CS1= P3^7;//片选
- bit Flage1=0;
- void LcdInit();
- void Clear();
- void Delayms(uint ms);
- void Comwrite(uchar cmd);
- void Datwrite(uchar dat);
- void Setadd(uchar xl,uchar yl);
- void disp_str(unsigned char *p,unsigned char uCol,uPage);
- unsigned char CurOffset;
- /*
- #define LEFT 0
- #define RIGHT 1
- #define CMD 0
- #define DATA 1
- */
- #define ASC_CHR_WIDTH 8
- #define ASC_CHR_HEIGHT 12
- typedef struct typFNT_ASC16
- {
- char Index[1];
- char Msk[16];
- };
- code struct typFNT_ASC16 ASC_16[] =
- {
- "1",0x00,0x00,0x08,0x08,0xFC,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x04,0x04,0x00,
- "2",0x00,0x00,0x08,0x04,0x84,0x44,0x38,0x00,0x00,0x00,0x06,0x05,0x04,0x04,0x04,0x00,
- "3",0x00,0x00,0x08,0x04,0x44,0x44,0xB8,0x00,0x00,0x00,0x02,0x04,0x04,0x04,0x03,0x00,
- "4",0x00,0x00,0x80,0x60,0x18,0xFC,0x00,0x00,0x00,0x00,0x01,0x01,0x05,0x07,0x05,0x00,
- "5",0x00,0x00,0x7C,0x44,0x44,0x44,0x84,0x00,0x00,0x00,0x02,0x04,0x04,0x04,0x03,0x00,
- "6",0x00,0x00,0xF0,0x48,0x44,0x44,0x80,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x03,0x00,
- "7",0x00,0x00,0x0C,0x04,0x84,0x64,0x1C,0x00,0x00,0x00,0x00,0x06,0x01,0x00,0x00,0x00,
- "8",0x00,0x00,0xB8,0x44,0x44,0x44,0xB8,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x03,0x00,
- "9",0x00,0x00,0x38,0x44,0x44,0x44,0xF8,0x00,0x00,0x00,0x00,0x04,0x04,0x02,0x01,0x00,
- "0",0x00,0x00,0xF8,0x04,0x04,0x04,0xF8,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x03,0x00,
- };
- #define ASC_HZ_WIDTH 16
- //#define ASC_HZ_HEIGHT 12
- typedef struct typFNT_GB16
- {
- char Index[2];
- char Msk[32];
- };
- /*code struct typFNT_GB16 GB_16[] = {
- "欢", 0x04,0x34,0xC4,0x04,0xC4,0x3C,0x20,0x10,0x0F,0xE8,0x08,0x08,0x28,0x18,0x00,0x00,
- 0x10,0x08,0x06,0x01,0x82,0x8C,0x40,0x30,0x0C,0x03,0x0C,0x10,0x60,0xC0,0x40,0x00,
- "迎", 0x40,0x42,0x44,0xC8,0x00,0xFC,0x04,0x02,0x82,0xFC,0x04,0x04,0x04,0xFE,0x04,0x00,
- 0x00,0x40,0x20,0x1F,0x20,0x47,0x42,0x41,0x40,0x7F,0x40,0x42,0x44,0x63,0x20,0x00,
- "使", 0x40,0x20,0xF8,0x07,0x04,0xF4,0x14,0x14,0x14,0xFF,0x14,0x14,0x14,0xF6,0x04,0x00,
- 0x00,0x00,0xFF,0x00,0x80,0x43,0x45,0x29,0x19,0x17,0x21,0x21,0x41,0xC3,0x40,0x00,
- "用", 0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0xFF,0x02,0x00,0x00,
- 0x80,0x60,0x1F,0x02,0x02,0x02,0x02,0x7F,0x02,0x02,0x42,0x82,0x7F,0x00,0x00,0x00,
- "黑", 0x00,0x00,0xFE,0x8A,0x92,0xB2,0x82,0xFE,0x82,0xA2,0x9A,0x92,0xFF,0x02,0x00,0x00,
- 0x08,0x8A,0x6A,0x0A,0x2A,0xCA,0x0A,0x0F,0x2A,0xCA,0x0A,0x2A,0x4A,0xCA,0x08,0x00,
- "白", 0x00,0x00,0xF8,0x08,0x0C,0x0A,0x09,0x08,0x08,0x08,0x08,0x08,0xFC,0x08,0x00,0x00,
- 0x00,0x00,0x7F,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x7F,0x00,0x00,0x00,
- "点", 0x00,0x00,0xC0,0x40,0x40,0x40,0x7F,0x48,0x48,0x48,0x48,0xE8,0x4C,0x08,0x00,0x00,
- 0x80,0x40,0x37,0x04,0x14,0x64,0x04,0x14,0x24,0x64,0x04,0x17,0x20,0xC0,0x00,0x00,
- "阵", 0x00,0xFE,0x22,0x5A,0x86,0x04,0x84,0xE4,0x9F,0x84,0xF4,0x84,0xC4,0x86,0x04,0x00,
- 0x00,0xFF,0x04,0x08,0x07,0x08,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x0C,0x08,0x00,
- "液", 0x10,0x22,0x64,0x0C,0x80,0x04,0xC4,0x34,0x05,0xC6,0xBC,0x24,0x24,0xE6,0x04,0x00,
- 0x04,0x04,0xFE,0x01,0x02,0x01,0xFF,0x42,0x21,0x16,0x08,0x15,0x23,0x60,0x20,0x00,
- "晶", 0x00,0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x80,0x00,0x00,
- 0x00,0xFF,0x49,0x49,0x49,0x49,0xFF,0x00,0xFF,0x49,0x49,0x49,0x49,0xFF,0x01,0x00,
- "屏", 0x00,0x00,0xFE,0x12,0x92,0x92,0xB2,0xD2,0x92,0xD2,0xB2,0x92,0xDF,0x82,0x00,0x00,
- 0x40,0x20,0x1F,0x04,0x84,0x44,0x3F,0x04,0x04,0x04,0xFF,0x04,0x04,0x06,0x04,0x00,
- "显", 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0xFF,0x02,0x00,0x00,0x00,
- 0x40,0x42,0x44,0x4D,0x40,0x7F,0x40,0x40,0x40,0x7F,0x40,0x49,0x44,0x66,0x40,0x00,
- "示", 0x40,0x40,0x42,0x42,0x42,0x42,0x42,0xC2,0x42,0x42,0x42,0x43,0x42,0x60,0x40,0x00,
- 0x00,0x10,0x08,0x04,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x0C,0x18,0x00,0x00,
- "汉", 0x10,0x22,0x64,0x0C,0x80,0x04,0x74,0x84,0x04,0x04,0x04,0xC4,0x3E,0x04,0x00,0x00,
- 0x04,0x04,0x7E,0x01,0x80,0x40,0x20,0x11,0x0A,0x04,0x0B,0x10,0x60,0xC0,0x40,0x00,
- "字", 0x00,0x10,0x0C,0x24,0x24,0x24,0x25,0x26,0xA4,0x64,0x24,0x04,0x14,0x0C,0x00,0x00,
- 0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x03,0x02,0x00,
- "测", 0x10,0x22,0x6C,0x00,0x80,0xFC,0x04,0xF4,0x04,0xFE,0x04,0xF8,0x00,0xFE,0x00,0x00,
- 0x04,0x04,0xFE,0x01,0x40,0x27,0x10,0x0F,0x10,0x67,0x00,0x47,0x80,0x7F,0x00,0x00,
- "试", 0x40,0x42,0xCC,0x00,0x10,0x90,0x90,0x90,0x90,0x90,0xFF,0x10,0x12,0x14,0x10,0x00,
- 0x00,0x00,0x7F,0x20,0x10,0x20,0x60,0x3F,0x10,0x10,0x01,0x3E,0x40,0x80,0x70,0x00
- };
- */
- uchar code Hanzi[]={
- /*-- 调入了一幅图像:F:\技术支持\测试程序\黑白图片\马2.bmp --*/
- /*-- 宽度x高度=128x64 --*/
- 0x04,0xF4,0x54,0x5F,0x54,0xF4,0x44,0x30,0x4C,0x4B,0xC8,0x48,0x0C,0x08,0x00,0x00,
- 0x00,0x00,0xFE,0x92,0x92,0x92,0xFE,0x92,0x92,0x92,0xFF,0x02,0x00,0x00,0x20,0x21,
- 0xE6,0x00,0x00,0xF8,0x48,0x48,0xFF,0x48,0x48,0x48,0xFC,0x08,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,0x00,0x00,0x00,
- 0x80,0x80,0x50,0xD0,0xA4,0xE4,0xC8,0xD8,0xF8,0xF8,0xF4,0xF8,0xF8,0xF8,0xF0,0xF0,
- 0xF0,0xF0,0xF0,0xE0,0x60,0x40,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0x20,0xE0,0xE0,
- 0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x04,0x05,0x05,0x3F,0x05,0x05,0x04,0x00,0x1C,0x23,0x20,0x20,0x20,0x3C,0x00,0x00,
- 0x10,0x0C,0x01,0x1E,0x20,0x21,0x22,0x24,0x20,0x20,0x3A,0x04,0x08,0x00,0x10,0x08,
- 0x07,0x08,0x10,0x27,0x24,0x24,0x27,0x24,0x24,0x24,0x27,0x20,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,0x00,0x44,0x44,
- 0xC2,0x6B,0x6F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xF0,0xF1,0xC1,0x61,
- 0x71,0x71,0xF0,0xF4,0xAC,0xEC,0xEC,0x6E,0x7A,0x3F,0x1F,0x0F,0x1F,0x1F,0x1D,0x1D,
- 0x1D,0x05,0x01,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,
- 0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xC5,
- 0xE5,0xF7,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0x2F,0x47,
- 0xD7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBC,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,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x08,0x18,0xD0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE5,0xEC,0xEC,0xFA,
- 0xDE,0xFE,0xFC,0xFF,0xFD,0xFF,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,
- 0xFF,0xFF,0xFF,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
- 0x0F,0x0E,0x0E,0x1C,0x1C,0x1C,0x1C,0x18,0x18,0x38,0x38,0x1C,0x1D,0x1D,0x1D,0x2F,
- 0x3F,0x9F,0x9F,0x8F,0x8F,0x07,0x03,0x03,0x05,0x16,0x0F,0x07,0xA7,0xE2,0xF0,0xFD,
- 0x3F,0x5F,0xDF,0xFF,0xFF,0xFF,0x0F,0x03,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- 0x01,0x01,0x07,0x07,0x07,0x07,0x07,0x07,0x87,0xC3,0xEB,0xCF,0xC3,0xC3,0xE0,0xF4,
- 0x7F,0x3F,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xFC,0xFC,0xF8,0xC0,0xE8,0xFC,
- 0xFC,0xC0,0xC0,0x80,0x20,0xC0,0xD4,0xD4,0xFE,0xFF,0xF7,0xF6,0xF0,0xFC,0xFC,0xFE,
- 0xF3,0xFF,0xF7,0xC3,0x81,0x00,0x38,0x3C,0xFC,0xFC,0xFC,0xEC,0xE5,0xED,0xFF,0xD5,
- 0xC5,0xF9,0xF9,0xBF,0xBF,0xFF,0xDF,0xF8,0xFC,0x7E,0x26,0x36,0x36,0x1E,0x1E,0x1C,
- 0x3C,0x78,0xF0,0xF0,0xE0,0xE0,0xC0,0xC0,0xC0,0x80,0x80,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,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x90,0xFF,0xFF,0xFF,0xF9,0xFD,0x8F,0x0F,0x0D,
- 0x0C,0x0C,0x1C,0x1C,0x18,0x18,0x18,0x1C,0x1E,0x0F,0x07,0x03,0x03,0x0F,0x0F,0x1F,
- 0x1F,0x3F,0x7F,0xFF,0xFE,0xDE,0xDE,0x9F,0x3F,0x3F,0x7E,0xFF,0xDF,0xBF,0x3F,0x3F,
- 0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,0x1F,0x3E,0x3C,0x6F,0x7D,0xFD,0xF9,0xF3,0xD7,0xCF,
- 0xDF,0xBB,0x57,0xC3,0x83,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x0F,0x1F,0x03,0x22,0x26,0x2C,0x10,
- 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,0x02,
- 0x06,0x1F,0x33,0x3B,0x3F,0x13,0x1F,0x0F,0x07,0x07,0x03,0x01,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,0x01,0x03,0x07,0x07,0x06,0x05,0x0D,0x1B,0x3E,0x36,
- 0x7C,0x78,0x78,0xF0,0xE0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
- 0x03,0x07,0x0E,0x0E,0x1F,0x1F,0x3F,0x3E,0x7E,0xFC,0xF0,0xE0,0xC0,0x80,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x02,0x02,0xFE,0x02,0x02,0x00,0xFE,0x12,0x12,0x32,0xCC,0x00,0x00,0x7E,0x80,0x80,
- 0x80,0x7E,0x00,0x00,0x4C,0x92,0x92,0x64,0x00,0x02,0x02,0xFE,0x02,0x02,0x00,0x02,
- 0x0C,0xF0,0x0C,0x02,0x00,0x00,0xFE,0x80,0x80,0x80,0x00,0x7C,0x82,0x82,0x82,0x44,
- 0x00,0x00,0xFE,0x82,0x82,0x82,0x7C,0x00,0x00,0x80,0x00,0x00,0x7C,0x82,0x82,0x82,
- 0x44,0x00,0x00,0x7C,0x82,0x82,0x82,0x7C,0x00,0xFE,0x0C,0x70,0x80,0x70,0x0C,0xFE,
- 0x00,0x00,0x00,0x00,0x01,0x03,0x0F,0x0F,0x1F,0x7F,0x7E,0x36,0x46,0x4E,0x6C,0x68,
- 0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x07,0x0F,0x6F,
- 0xEF,0xDF,0xDE,0xDA,0xD8,0xF8,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- void Display(unsigned char sda,unsigned char sda1)
- {
- unsigned char i,j,k=0;
- for(i=0;i<8;i++)
- {
- Comwrite(0xb0+k);
- Comwrite(0x10);
- Comwrite(0x00);
- for(j=0;j<64;j++)
- { Datwrite(sda);
- Datwrite(sda1);
- }
- k++;
- }
- }
- void Hanzi_Disp(void)
- {
- unsigned char i,j,k=0;
- for(i=0;i<8;i++)
- {
- Comwrite(0xb0+k);
- Comwrite(0x10);
- Comwrite(0x00); //0x04>0x00
- for(j=0;j<128;j++)
- {Datwrite(Hanzi[i*128+j]);
- }
- k++;
- }
- }
- void main()
- {
- P1M1=0x00;
- P1M0=0xff;
- P3M1=0x00;
- P3M0=0xff;
- CLK_DIV=0x02;
- LcdInit();
- while(1)
- {
- Clear();
- Display(0xff,0xff);
- Delayms(5000);
- Display(0x55,0xaa);
- Delayms(5000);
- Display(0x00,0xff);
- Delayms(5000);
- Display(0xaa,0xaa);
- Delayms(5000);
- Display(0x55,0x55);
- Delayms(5000);
- Hanzi_Disp();
- Delayms(5000);
- Delayms(5000);
- /* Clear();
- disp_str("测试",0,0);Delayms(1000);
- disp_str("测试",96,0);Delayms(1000);
- disp_str("测试",48,3);Delayms(1000);
- disp_str("测试",96,0);Delayms(1000);
- disp_str("测试",0,6);Delayms(1000);
- disp_str("测试",96,6);Delayms(1000);
- Delayms(4000);Delayms(4000);
- Clear();
- Flage1=0;
- disp_str("黑白液晶屏测试点",0,0);
- disp_str("黑白液晶屏测试点",0,2);
- disp_str("黑白液晶屏测试点",0,4);
- disp_str("189024550071234",0,6);
- Delayms(5000);Delayms(5000);
- */
- }
-
- }
- void Delayms(uint ms)
- {
- uchar j;
- while(ms--)
- for(j=0;j<=20;j++);
-
- }
-
- void Comwrite(uchar cmd)
- {
- uchar data i,j;
- CS1=0;
- R_S=0;
- SCK=1;
- for(i=0;i<8;i++)
- {
- j=cmd;
- SCK=0;
- SDA=cmd&0x80;
- SCK=1;
- cmd=j<<1;
- }
- CS1=1;
- R_S=1;
- }
- void Datwrite(uchar dat)
- {
- uchar data i,j;
- CS1=0;
- R_S=1;
- SCK=1;
- for(i=0;i<8;i++)
- {
- j=dat;
- SCK=0;
- SDA=dat&0x80;
- SCK=1;
- dat=j<<1;
- }
- CS1=1;
- R_S=0;
- }
- void Clear()
- {
- unsigned char i,j,m=0;
- for(i=0;i<8;i++)
- {
- Setadd(0,i);
- for(j=0;j<128;j++)
- Datwrite(0x00);
- }
- }
- void Setadd(uchar xl,uchar yl)
- { uchar i;
- i=(xl+0)&0x0f; //i=(xl+0)&0x0f;(SEG0~SEG127) // i=(xl+4)&0x0f;(SEG4~SEG131)
- xl=(xl>>4)+0x10;
- Comwrite(0xb0+yl);
- Comwrite(xl);
- Comwrite(i);
- }
- void LcdInit()
- {
- RES=1;
- Delayms(50);
- RES=0;
- Delayms(50);
- RES=1;
- Delayms(50);
- Comwrite(0xE2); //Software Reset
- Delayms(50);
- Comwrite(0xA2); //Set Bias 0xA3 1/7bias, 0xA2 1/9 bias
- Comwrite(0xA0); //Segment Direction Select bit0=0,normal ,=1,reverse
- Comwrite(0xC8); //Common Direction Select bit3=0,normal ,=1,revese
- Comwrite(0xA8);
- Comwrite(0xA6);
- Comwrite(0xA4);
- Comwrite(0x23); //调电压 对比度 Set internal rb/ra 0x24
- Comwrite(0x81); //Set Contrast
- Comwrite(0x30); //调电压 对比度 1a>1f
- Comwrite(0x2F); //Power Control Set
- Delayms(5000); //delay 40mS
- Comwrite(0x40); //Set Display Start Line
- Comwrite(0xAF); //Display ON
- }
-
- void disp_ch(unsigned char c,uCol,uPage)
- {
- unsigned char k,j,ch_w;
- unsigned char width;
- unsigned char len;
- len=sizeof(ASC_16)/sizeof(ASC_16[0]);
- for(k=0;k<len;k++)
- {
- if(c == ASC_16[k].Index[0] ) break;
- }
- if(k<len)
- {
-
- if(c=='-'||c==':')
- width=ASC_CHR_WIDTH-2;
- else if(c=='|')
- width=ASC_HZ_WIDTH-ASC_CHR_WIDTH;
- else
- width=ASC_CHR_WIDTH;
-
- Setadd(uCol,uPage);
- for(j=0;j<width;j++)
- {
- ch_w=ASC_16[k].Msk[j];
- Datwrite(ch_w);
- }
- Setadd(uCol,uPage+1);
- for(j=0;j<width;j++)
- {
- ch_w=ASC_16[k].Msk[ASC_CHR_WIDTH+j];
- Datwrite(ch_w);
- }
- }
- }
- /*
- void disp_hz(unsigned char *hz,uCol,uPage)
- {
- unsigned char k,j,ch_w;
- //sizeof 用来求一个变量或者一种类型所占用的字节数
- for(k=0;k<sizeof(GB_16)/sizeof(GB_16[0]);k++)
- {
- if(hz[0] == GB_16[k].Index[0] && hz[1] == GB_16[k].Index[1])
- break;
- }
- Setadd(uCol,uPage);
- for(j=0;j<ASC_HZ_WIDTH;j++)
- {
- ch_w=GB_16[k].Msk[j];
- Datwrite(ch_w);
- }
- Setadd(uCol,uPage+1);
- for(j=0;j<ASC_HZ_WIDTH;j++)
- {
- ch_w=GB_16[k].Msk[ASC_HZ_WIDTH+j];
- Datwrite(ch_w);
- }
- }
- */
- void disp_str(unsigned char *p,unsigned char uCol,uPage)
- {
- unsigned char i=0;
- while(p[i]>0)
- {
- if(p[i] < 128)
- {
- disp_ch(p[i],uCol,uPage);
- uCol+=8;
- }
- /* else
- {
- disp_hz(&p[i],uCol,uPage);
- uCol+=16;
- i++;
- }
- */ if(Flage1==1) Delayms(200);
- i++;
- }
- }
复制代码 |