- #include "REG51.h"
- //本程序在标准8052单片机(STC89C52)以12MHz运行。底层已优化到最快。
- //如果使用STC15,STC8系列单片机,请将单片机主频降低10倍先试。也就是用1.3824MHz先试试。
- //因为是追求速度,所以如果你的单片机IO速度太快,需要自己在Write_IIC_Byte加点延时进去。
- sbit SCL = P1^0;
- sbit SDA = P1^1;
- code unsigned char Hzk[]={
- /*-- 文字: 柳 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- 0x08,0x88,0x68,0xFF,0x28,0x48,0xFC,0x04,0x02,0xF2,0x00,0xFC,0x04,0x04,0xFC,0x00,
- 0x02,0x01,0x00,0xFF,0x00,0x40,0x47,0x22,0x19,0x07,0x00,0xFF,0x02,0x04,0x03,0x00,
- ///*-- 文字: 州 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0xE0,0x00,0x00,0xFF,0x20,0xC0,0x00,0xFE,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,
- //0x01,0x80,0x60,0x18,0x07,0x00,0x00,0x00,0x7F,0x00,0x00,0x01,0x00,0xFF,0x00,0x00,
- ///*-- 文字: 双 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x12,0x22,0x42,0x82,0x62,0x1E,0x00,0x1E,0xE2,0x02,0x02,0xE2,0x1E,0x00,0x00,
- //0x20,0x10,0x08,0x06,0x01,0x03,0x4E,0x24,0x10,0x09,0x06,0x09,0x10,0x60,0x20,0x00,
- ///*-- 文字: 虹 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0xF8,0x08,0x08,0xFF,0x08,0x08,0xF8,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x00,
- //0x43,0x41,0x41,0x3F,0x21,0x29,0x73,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x00,
- ///*-- 文字: 农 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x20,0x18,0x08,0x88,0xE8,0x1F,0x6A,0x88,0x08,0x88,0xC8,0xA8,0x1C,0x08,0x00,
- //0x08,0x04,0x02,0x41,0xFF,0x40,0x20,0x10,0x01,0x02,0x0D,0x18,0x70,0x20,0x20,0x00,
- ///*-- 文字: 业 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38,0x10,0x00,
- //0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30,0x20,0x00,
- ///*-- 文字: 科 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x10,0x12,0x92,0x72,0xFE,0x51,0x91,0x00,0x22,0xCC,0x00,0x00,0xFF,0x00,0x00,0x00,
- //0x04,0x02,0x01,0x00,0xFF,0x00,0x04,0x04,0x04,0x02,0x02,0x02,0xFF,0x01,0x01,0x00,
- ///*-- 文字: 技 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00,
- //0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00,
- ///*-- 文字: 企 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x80,0x80,0x40,0x40,0x20,0x10,0x08,0xC7,0x8A,0x10,0x20,0x60,0x40,0xC0,0x40,0x00,
- //0x40,0x40,0x40,0x7F,0x42,0x40,0x40,0x7F,0x42,0x42,0x42,0x43,0x42,0x60,0x40,0x00,
- ///*-- 文字: 鹅 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x24,0x24,0xFC,0x22,0xFF,0x24,0x28,0x00,0xFC,0x0C,0x36,0x05,0x44,0x7C,0x00,0x00,
- //0x24,0x42,0x3F,0x09,0x05,0x0E,0x31,0x78,0x09,0x09,0x09,0x09,0x49,0x81,0x7F,0x00,
- ///*-- 文字: 电 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
- //0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00,
- ///*-- 文字: 路 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x7E,0x22,0xE2,0x3E,0x20,0x10,0x08,0x0F,0xB4,0x44,0xA4,0x9C,0x04,0x00,0x00,
- //0x20,0x3F,0x20,0x1F,0x11,0x11,0x02,0x7F,0x23,0x22,0x22,0x22,0x7E,0x03,0x01,0x00,
- ///*-- 文字: 个 --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
- //0x00,0x80,0x80,0x40,0x20,0x10,0x0C,0xE3,0x04,0x08,0x10,0x20,0x60,0xC0,0x40,0x00,
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- code unsigned char hz_suoyin[]="柳州双虹农业科技企鹅电路个";
- code unsigned char num[]={
- /*-- 文字: ? --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,
- /*-- 文字: 0 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,
- /*-- 文字: 1 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
- /*-- 文字: 2 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
- /*-- 文字: 3 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,
- /*-- 文字: 4 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
- /*-- 文字: 5 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,
- /*-- 文字: 6 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,
- /*-- 文字: 7 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,
- /*-- 文字: 8 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,
- /*-- 文字: 9 --*/
- /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,
- ///*-- 文字: a --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,
- ///*-- 文字: b --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,
- ///*-- 文字: c --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,
- ///*-- 文字: d --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,
- ///*-- 文字: e --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,
- ///*-- 文字: f --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
- ///*-- 文字: g --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,
- ///*-- 文字: h --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,
- ///*-- 文字: i --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
- ///*-- 文字: j --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,
- ///*-- 文字: k --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,
- ///*-- 文字: l --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
- ///*-- 文字: m --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,
- ///*-- 文字: n --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,
- ///*-- 文字: o --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,
- ///*-- 文字: p --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,
- ///*-- 文字: q --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,
- ///*-- 文字: r --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,
- ///*-- 文字: s --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,
- ///*-- 文字: t --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,
- ///*-- 文字: u --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,
- ///*-- 文字: v --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,
- ///*-- 文字: w --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,
- ///*-- 文字: x --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,
- ///*-- 文字: y --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,
- ///*-- 文字: z --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,
- ///*-- 文字: A --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,
- ///*-- 文字: B --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,
- ///*-- 文字: C --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,
- ///*-- 文字: D --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,
- ///*-- 文字: E --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,
- ///*-- 文字: F --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,
- ///*-- 文字: G --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,
- ///*-- 文字: H --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,
- ///*-- 文字: I --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
- ///*-- 文字: J --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,
- ///*-- 文字: K --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,
- ///*-- 文字: L --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,
- ///*-- 文字: M --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,
- ///*-- 文字: N --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,
- ///*-- 文字: O --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,
- ///*-- 文字: P --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,
- ///*-- 文字: Q --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,
- ///*-- 文字: R --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,
- ///*-- 文字: S --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,
- ///*-- 文字: T --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,
- ///*-- 文字: U --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,
- ///*-- 文字: V --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,
- ///*-- 文字: W --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,
- ///*-- 文字: X --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,
- ///*-- 文字: Y --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,
- ///*-- 文字: Z --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,
- ///*-- 文字: ` --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- ///*-- 文字: ! --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,
- ///*-- 文字: @ --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,
- ///*-- 文字: # --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,
- ///*-- 文字: $ --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,
- ///*-- 文字: % --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,
- ///*-- 文字: ^ --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- ///*-- 文字: & --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,
- ///*-- 文字: * --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,
- ///*-- 文字: ( --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,
- ///*-- 文字: ) --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,
- ///*-- 文字: - --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
- ///*-- 文字: = --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,
- ///*-- 文字: _ --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
- ///*-- 文字: + --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,
- ///*-- 文字: [ --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,
- ///*-- 文字: ] --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,
- ///*-- 文字: ; --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,
- ///*-- 文字: ' --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- ///*-- 文字: , --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,
- ///*-- 文字: . --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,
- ///*-- 文字: / --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,
- ///*-- 文字: { --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,
- ///*-- 文字: } --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,
- ///*-- 文字: : --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,
- ///*-- 文字: < --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,
- ///*-- 文字: > --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,
- ///*-- 文字: \ --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,
- ///*-- 文字: " --*/
- ///*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
- //0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,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,
- };
- code unsigned char zm_suoyin[]="?0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`!@#$%^&*()-=_+[];',./{}:<>\x5c\34 ";
- void Write_IIC_Byte(unsigned char IIC_Byte)
- {
- SCL=0;
- SDA=IIC_Byte&0x80;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x40;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x20;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x10;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x08;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x04;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x02;
- SCL=1;
- SCL=0;
- SDA=IIC_Byte&0x01;
- SCL=1;
- SCL=0;
- SCL=1;
- SCL=0;
- }
- void Write_IIC_Command(unsigned char IIC_Command)
- {
- SCL=1;
- SDA=1;
- SDA=0;
- Write_IIC_Byte(0x78); //Slave address,SA0=0
- Write_IIC_Byte(0x00); //write command
- Write_IIC_Byte(IIC_Command);
- SDA=0;
- SCL=1;
- SDA=1;
- }
- void Write_IIC_Data(unsigned char IIC_Data)
- {
- SCL=1;
- SDA=1;
- SDA=0;
- Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
- Write_IIC_Byte(0x40); //write data
- Write_IIC_Byte(IIC_Data);
- SDA=0;
- SCL=1;
- SDA=1;
- }
- void OLED_Clear(void)
- {
- unsigned char i,n;
- for(i=0;i<4;i++)
- {
- Write_IIC_Command (0xb0+i); //设置页地址(0~7)
- Write_IIC_Command (0x00); //设置显示位置—列低地址
- Write_IIC_Command (0x10); //设置显示位置—列高地址
- SCL=1;
- SDA=1;
- SDA=0;
- Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
- Write_IIC_Byte(0x40); //write data
- for(n=0;n<128;n++)Write_IIC_Byte(0X00);
- SDA=0;
- SCL=1;
- SDA=1;
-
- } //更新显示
- }
- void Delay100ms() //@11.0592MHz
- {
- unsigned char i, j, k;
- i = 5;
- j = 52;
- k = 195;
- do
- {
- do
- {
- while (--k);
- } while (--j);
- } while (--i);
- }
- void OLED_Init(void)
- {
- Delay100ms();
- Write_IIC_Command(0xAE);//关闭显示
-
- Write_IIC_Command(0x40);//---set low column address
- Write_IIC_Command(0xB0);//---set high column address
- Write_IIC_Command(0xC8);//-not offset
- Write_IIC_Command(0x81);//设置对比度
- Write_IIC_Command(0xff);
- Write_IIC_Command(0xa1);//段重定向设置
- Write_IIC_Command(0xa6);//
-
- Write_IIC_Command(0xa8);//设置驱动路数
- Write_IIC_Command(0x1f);
-
- Write_IIC_Command(0xd3);
- Write_IIC_Command(0x00);
-
- Write_IIC_Command(0xd5);
- Write_IIC_Command(0xf0);
-
- Write_IIC_Command(0xd9);
- Write_IIC_Command(0x22);
-
- Write_IIC_Command(0xda);
- Write_IIC_Command(0x02);
-
- Write_IIC_Command(0xdb);
- Write_IIC_Command(0x49);
-
- Write_IIC_Command(0x8d);
- Write_IIC_Command(0x14);
-
- Write_IIC_Command(0xaf);
- OLED_Clear();
- }
- void OLED_Set_Pos(unsigned char x, unsigned char y)
- {
- SCL=1;
- SDA=1;
- SDA=0;
- Write_IIC_Byte(0x78); //Slave address,SA0=0
- Write_IIC_Byte(0x00); //write command
- Write_IIC_Byte(0xb0+y);
- Write_IIC_Byte(((x&0xf0)>>4)|0x10);
- Write_IIC_Byte((x&0x0f));
- SDA=0;
- SCL=1;
- SDA=1;
- }
- void OLED_ShowHz(unsigned char x,y,no)
- {
- unsigned char i;
- OLED_Set_Pos(x,y);
- no=no*32;
- for(i=0;i<16;i++)
- {
- Write_IIC_Data(Hzk[no++]);
- }
- OLED_Set_Pos(x,y+1);
- for(i=16;i<32;i++)
- {
- Write_IIC_Data(Hzk[no++]);
- }
- }
- void OLED_ShowNum(unsigned char x,y,val)
- {
- unsigned char i;
- OLED_Set_Pos(x,y);
- val=val*16;
- SCL=1;
- SDA=1;
- SDA=0;
- Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
- Write_IIC_Byte(0x40); //write data
- for(i=0;i<8;i++)
- {
- Write_IIC_Byte(num[val++]);
- }
- SDA=0;
- SCL=1;
- SDA=1;
- OLED_Set_Pos(x,y+1);
- SCL=1;
- SDA=1;
- SDA=0;
- Write_IIC_Byte(0x78); //D/C#=0; R/W#=0
- Write_IIC_Byte(0x40); //write data
- for(i=8;i<16;i++)
- {
- Write_IIC_Byte(num[val++]);
- }
- SDA=0;
- SCL=1;
- SDA=1;
- }
- void OLED_Show_Zfc(unsigned char x,y,unsigned char code * Zfc)
- {
- unsigned char i;
- while(*Zfc!=0)
- {
- if(*Zfc>127)
- {
- for(i=0;i<=sizeof(hz_suoyin);i++)
- {
- if(Zfc[0]==hz_suoyin[i] && Zfc[1]==hz_suoyin[i+1])
- {
- if(x>112){y+=2;x=0;}
- OLED_ShowHz(x,y,i/2);
- x=x+16;
- Zfc+=2;
- }
- }
- }
- else
- {
- for(i=0;i<=sizeof(zm_suoyin);i++)
- {
- if(Zfc[0]==zm_suoyin[i])
- {
- if(x>120){y+=2;x=0;}
- OLED_ShowNum(x,y,i);
- x=x+8;
- }
- }
- Zfc++;
- }
- }
- }
- int main(void)
- {
- unsigned char i;
- OLED_Init(); //初始化OLED
- OLED_Clear();
- OLED_Show_Zfc(0,0,"柳 18077219186");
- while(1)
- {
- // OLED_ShowNum(0,2,i/100);
- // OLED_ShowNum(8,2,i%100/10);
- // OLED_ShowNum(16,2,i%10);
- i++;
- }
- }
复制代码 |