之前论坛送的ST7585,坛友发的驱动是STM的,根据那个驱动做了个51的驱动。在此感谢下发布驱动的朋友。
main.c:
- #include "STC90.H"
- #include "font.h"
- #define SDA P20
- #define A0 P21
- #define CS P22
- #define SCL P23
- #define RES P24
- #define LED1 P20
- #define LED2 P21
- #define NOP 0x00
- #define Function_Set 0x20
- #define Display_Control 0x08
- #define Set_Y_Address 0x40
- #define Set_X_Address 0x80
- #define Set_V0 0x80
- #define Set_Test_Mode 0x30
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- const unsigned char code BMP[768]={
- 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,
- 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,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x0E,0x1F,0x3F,
- 0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,
- 0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7E,0x7F,0x7F,0x7F,0x7F,0x7F,
- 0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x07,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
- 0x07,0x07,0x07,0x03,0x80,0xC0,0xE0,0xFC,0xFF,0xFF,0x3F,0x0F,0x03,0x00,0x00,0xE0,
- 0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xDF,0xF7,0xFE,0xFF,0xFF,0xFF,
- 0x7F,0x1F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x80,0xE0,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,0xFC,0xF8,0xF0,
- 0xE0,0xC0,0x80,0x01,0x01,0x03,0x07,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x07,
- 0x00,0x00,0xC0,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0xFD,
- 0xFF,0xFF,0xFF,0xFF,0x3F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xC0,0xF0,0xFE,0xFF,0xFF,0xE0,0x80,0x00,0x00,0x00,0x1E,0x1F,
- 0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0x3F,0x0E,0x00,0x00,0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x7F,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xFC,0x7F,0x3F,0x1F,0x0F,0x0F,0x0F,
- 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
- 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
- 0x0F,0x0F,0x8F,0xEF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0x7F,0x1F,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 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,0xC0,0xC0,0xD0,0xD0,0xD0,
- 0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,
- 0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,
- 0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xF0,0xF0,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 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,
- 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,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- };
- const char code write_chinese[][24]={
- /*-- 文字: 两 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x01,0xF9,0x89,0x7F,0x49,0x89,0x7F,0x49,0x89,0xF9,0x01,0x00,0x00,0x07,0x00,0x00,
- 0x01,0x00,0x00,0x04,0x04,0x07,0x00,0x00,
- /*-- 文字: 个 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x10,0x10,0x08,0x04,0x02,0xF9,0x02,0x04,0x08,0x10,0x10,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 黄 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x08,0x0A,0xEA,0xAF,0xAA,0xFA,0xAA,0xAF,0xEA,0x0A,0x08,0x00,0x04,0x04,0x07,0x02,
- 0x02,0x03,0x02,0x02,0x07,0x04,0x04,0x00,
- /*-- 文字: 鹂 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0xFA,0x4A,0xFA,0x2A,0x4A,0xFA,0x00,0x7E,0x4B,0x52,0xDE,0x00,0x07,0x00,0x07,0x00,
- 0x04,0x07,0x01,0x01,0x05,0x05,0x03,0x00,
- /*-- 文字: 鸣 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0xFE,0x42,0x42,0xFE,0x00,0x7E,0x43,0x5A,0x52,0x5E,0xC0,0x00,0x00,0x00,0x00,0x01,
- 0x01,0x01,0x01,0x05,0x05,0x04,0x03,0x00,
- /*-- 文字: 翠 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x01,0x91,0x5B,0x35,0x5F,0x90,0x51,0x3B,0x55,0x9F,0x00,0x00,0x01,0x01,0x01,0x01,
- 0x01,0x07,0x01,0x01,0x01,0x01,0x01,0x00,
- /*-- 文字: 柳 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0xC4,0x34,0xFF,0x24,0xFE,0x82,0xFD,0x00,0xFE,0x02,0xFE,0x00,0x00,0x00,0x07,0x00,
- 0x04,0x02,0x01,0x00,0x07,0x01,0x01,0x00,
- /*-- 文字: 一 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 行 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x48,0x24,0xF3,0x08,0x09,0x09,0x09,0x09,0xF9,0x09,0x08,0x00,0x00,0x00,0x07,0x00,
- 0x00,0x04,0x04,0x04,0x07,0x00,0x00,0x00,
- /*-- 文字: 白 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x00,0xFC,0x44,0x44,0x46,0x45,0x44,0x44,0x44,0xFC,0x00,0x00,0x00,0x07,0x04,0x04,
- 0x04,0x04,0x04,0x04,0x04,0x07,0x00,0x00,
- /*-- 文字: 鹭 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x10,0x1F,0xD5,0x5D,0x57,0xEA,0x5B,0x55,0xD5,0x1B,0x08,0x00,0x04,0x04,0x05,0x05,
- 0x05,0x05,0x05,0x01,0x05,0x05,0x03,0x00,
- /*-- 文字: 上 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x00,0x00,0x00,0x00,0x00,0xFF,0x10,0x10,0x10,0x10,0x00,0x00,0x04,0x04,0x04,0x04,
- 0x04,0x07,0x04,0x04,0x04,0x04,0x04,0x00,
- /*-- 文字: 青 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x22,0x2A,0xEA,0xAA,0xAA,0xBF,0xAA,0xAA,0xEA,0x2A,0x22,0x00,0x00,0x00,0x07,0x02,
- 0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x00,
- /*-- 文字: 天 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x10,0x11,0x11,0x11,0xD1,0x3F,0xD1,0x11,0x11,0x11,0x10,0x00,0x04,0x04,0x02,0x01,
- 0x00,0x00,0x00,0x01,0x02,0x04,0x04,0x00,
- /*-- 文字: 窗 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x04,0x16,0xFA,0x96,0xD2,0x7B,0x52,0xD2,0x16,0xFA,0x16,0x00,0x00,0x00,0x07,0x04,
- 0x06,0x05,0x05,0x06,0x04,0x07,0x00,0x00,
- /*-- 文字: 含 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x10,0x10,0x88,0x94,0x92,0x99,0xD2,0xB4,0x88,0x10,0x10,0x00,0x00,0x00,0x07,0x04,
- 0x04,0x04,0x04,0x04,0x07,0x00,0x00,0x00,
- /*-- 文字: 西 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x01,0xF9,0x09,0x89,0x7F,0x09,0xFF,0x89,0x89,0xF9,0x01,0x00,0x00,0x07,0x05,0x04,
- 0x04,0x04,0x04,0x04,0x04,0x07,0x00,0x00,
- /*-- 文字: 岭 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0xFC,0x00,0xFF,0x80,0xFC,0x50,0x4C,0x53,0x64,0xC8,0x10,0x00,0x01,0x01,0x00,0x00,
- 0x01,0x00,0x01,0x02,0x05,0x00,0x00,0x00,
- /*-- 文字: 千 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x10,0x12,0x12,0x12,0x12,0xFE,0x11,0x11,0x11,0x10,0x10,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
- /*-- 文字: 秋 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x8A,0x6A,0xFE,0x29,0x49,0x3C,0x80,0x7F,0x90,0x08,0x04,0x00,0x01,0x00,0x07,0x04,
- 0x04,0x02,0x01,0x00,0x01,0x02,0x04,0x00,
- /*-- 文字: 雪 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x0C,0x45,0x55,0x55,0x45,0x7F,0x45,0x55,0x55,0xC5,0x0C,0x00,0x00,0x04,0x05,0x05,
- 0x05,0x05,0x05,0x05,0x05,0x07,0x00,0x00,
- /*-- 文字: 门 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x00,0xFC,0x01,0x06,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,0x07,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x00,
- /*-- 文字: 泊 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x08,0x91,0x7A,0x00,0xFC,0x44,0x46,0x45,0x44,0x44,0xFC,0x00,0x01,0x07,0x00,0x00,
- 0x07,0x02,0x02,0x02,0x02,0x02,0x07,0x00,
- /*-- 文字: 东 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x02,0x22,0x32,0xAA,0x26,0xFB,0x22,0x62,0xA2,0x22,0x02,0x00,0x02,0x02,0x01,0x00,
- 0x04,0x07,0x00,0x00,0x00,0x01,0x02,0x00,
- /*-- 文字: 吴 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x80,0xA0,0xAF,0xA9,0xA9,0xE9,0xA9,0xA9,0xAF,0xA0,0x80,0x00,0x04,0x04,0x04,0x02,
- 0x01,0x00,0x01,0x02,0x02,0x04,0x04,0x00,
- /*-- 文字: 万 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x02,0x02,0x02,0xC2,0x3E,0x12,0x12,0x12,0xF2,0x03,0x02,0x00,0x04,0x02,0x01,0x00,
- 0x00,0x02,0x04,0x04,0x03,0x00,0x00,0x00,
- /*-- 文字: 里 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x00,0x00,0x7F,0x29,0x29,0xFF,0x29,0x29,0x29,0x7F,0x00,0x00,0x04,0x05,0x05,0x05,
- 0x05,0x07,0x05,0x05,0x05,0x05,0x04,0x00,
- /*-- 文字: 船 --*/
- /*-- Trebuchet MS9; 此字体下对应的点阵为:宽x高=12x12 --*/
- /*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/
- 0x20,0xFE,0xAB,0x22,0xFE,0x20,0xDF,0x41,0x41,0x5F,0xD0,0x00,0x06,0x01,0x00,0x04,
- 0x07,0x00,0x07,0x04,0x04,0x04,0x07,0x00
- };/**/
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- void delay(unsigned int x)
- {
- unsigned int i,j;
- for(i=0;i<x;i++)
- for(j=0;j<100;j++);
- }
- void LCDShiftWrite(unsigned char dat)
- {
- unsigned char i;
- unsigned char Series,Temp;
- SCL = 0;
- Series = dat;
- for(i=0; i<8; i++)
- {
- SCL = 0;
- Temp=Series & 0x80;
- if(Temp)
- {
- SDA = 1;
- }
- else
- {
- SDA = 0;
- }
- SCL = 1;
- Series = Series << 1;
- }
- }
- void send_cmd(unsigned char cmd, unsigned char dat)
- {
- A0=0;
- CS=0;
- LCDShiftWrite(cmd|dat);
- CS=1;
- A0=1;
- }
- void send_dat(unsigned char dat)
- {
- CS=0;
- LCDShiftWrite(dat);
- CS=1;
- }
- void LCDInit()
- {
- RES=0;
- delay(10);
- RES=1;
- delay(10);
- send_cmd(Function_Set,0x01);
- send_cmd(Set_V0,0x30);
- send_cmd(Set_Test_Mode,0x02);
- send_cmd(Function_Set,0x00);
- send_cmd(Display_Control,0x04);
- }
- void LCD_set_XY(unsigned char x,unsigned char y)
- {
- send_cmd(Set_X_Address,x);
- send_cmd(Set_Y_Address,y);
- }
- void cls(void)
- {
- int i;
- send_cmd(Set_X_Address, 0);
- send_cmd(Set_Y_Address, 0);
- for(i=0;i<960;i++)
- send_dat(0x00);
- send_cmd(Set_X_Address, 0);
- send_cmd(Set_Y_Address, 0);
- }
- void putch(unsigned char x, unsigned char y, unsigned int ch)
- {
- unsigned char i;
- send_cmd(Set_X_Address,x);
- send_cmd(Set_Y_Address,y);
- for(i=0;i<5;i++)
- send_dat(FONT[(ch-0x20)*5+i]);
- }
- void putstr(unsigned char x, unsigned char y, char *str)
- {
- while(*str!=0)
- {
- putch(x,y,*str++);
- x=x+6;
- }
- }
- void SHOW_BMP()
- {
- unsigned int i,j,n=0;
- for(i=0;i<8;i++)
- for(j=0;j<96;j++)
- {
- send_cmd(Set_Y_Address,i);
- send_cmd(Set_X_Address,j);
- send_dat(BMP[n++]);
- }
- }
- /*-----------------------------------------------------------------------
- LCD_write_chinese_string: 在LCD上显示汉字
- 输入参数:X、Y :显示汉字的起始X、Y坐标;
- ch_with :汉字点阵的宽度
- num :显示汉字的个数;
- line :汉字点阵数组中的起始行数
- row :汉字显示的行间距
- -----------------------------------------------------------------------*/
- void LCD_write_chinese_string(unsigned char X, unsigned char Y,
- unsigned char ch_with,unsigned char num,
- unsigned char line,unsigned char row)
- {
- unsigned char i,n;
- LCD_set_XY(X,Y); //设置初始位置
- for (i=0;i<num;)
- {
- for (n=0; n<ch_with*2; n++) //写一个汉字
- {
- if (n==ch_with) //写汉字的下半部分
- {
- if (i==0) LCD_set_XY(X,Y-1);
- else
- LCD_set_XY((X+(ch_with+row)*i),Y-1);
- }
- send_dat(write_chinese[line+i][n]);
- }
- i++;
- LCD_set_XY((X+(ch_with+row)*i),Y);
- }
- }
- void main(void)
- {
- CS = 0;
- LCDInit();
- cls();
- LED1=0;
- LED2=1;
- while(1)
- {
- putstr(30,5,"amobbs");
- putstr(30,3,"CY");
- putstr(10,1,"STC90");
- delay(5000);
- cls();
- SHOW_BMP();
- delay(5000);
- cls();
- LCD_write_chinese_string(0,7,12,7,0,0);
- LCD_write_chinese_string(0,5,12,7,7,0);
- LCD_write_chinese_string(0,3,12,7,14,0);
- LCD_write_chinese_string(0,1,12,7,21,0);
- delay(5000);
- cls();
- LED1=~LED1;
- LED2=~LED2;
- }
- }
复制代码
font.c:
- const unsigned char code FONT[] = // ASCII
- {
- 0x00,0x00,0x00,0x00,0x00, // - -
- 0x00,0x00,0x5F,0x00,0x00, // -!-
- 0x00,0x07,0x00,0x07,0x00, // -"-
- 0x14,0x7F,0x14,0x7F,0x14, // -#-
- 0x24,0x2E,0x7B,0x2A,0x12, // -$-
- 0x23,0x13,0x08,0x64,0x62, // -%-
- 0x36,0x49,0x56,0x20,0x50, // -&-
- 0x00,0x04,0x03,0x01,0x00, // -'-
- 0x00,0x1C,0x22,0x41,0x00, // -(-
- 0x00,0x41,0x22,0x1C,0x00, // -)-
- 0x22,0x14,0x7F,0x14,0x22, // -*-
- 0x08,0x08,0x7F,0x08,0x08, // -+-
- 0x40,0x30,0x10,0x00,0x00, // -,-
- 0x08,0x08,0x08,0x08,0x08, // ---
- 0x00,0x60,0x60,0x00,0x00, // -.-
- 0x20,0x10,0x08,0x04,0x02, // -/-
- 0x3E,0x51,0x49,0x45,0x3E, // -0-
- 0x00,0x42,0x7F,0x40,0x00, // -1-
- 0x62,0x51,0x49,0x49,0x46, // -2-
- 0x21,0x41,0x49,0x4D,0x33, // -3-
- 0x18,0x14,0x12,0x7F,0x10, // -4-
- 0x27,0x45,0x45,0x45,0x39, // -5-
- 0x3C,0x4A,0x49,0x49,0x31, // -6-
- 0x01,0x71,0x09,0x05,0x03, // -7-
- 0x36,0x49,0x49,0x49,0x36, // -8-
- 0x46,0x49,0x49,0x29,0x1E, // -9-
- 0x00,0x36,0x36,0x00,0x00, // -:-
- 0x40,0x36,0x36,0x00,0x00, // -;-
- 0x08,0x14,0x22,0x41,0x00, // -<-
- 0x14,0x14,0x14,0x14,0x14, // -=-
- 0x00,0x41,0x22,0x14,0x08, // ->-
- 0x02,0x01,0x59,0x05,0x02, // -?-
- 0x3E,0x41,0x5D,0x55,0x5E, // -@-
- 0x7C,0x12,0x11,0x12,0x7C, // -A-
- 0x7F,0x49,0x49,0x49,0x36, // -B-
- 0x3E,0x41,0x41,0x41,0x22, // -C-
- 0x7F,0x41,0x41,0x41,0x3E, // -D-
- 0x7F,0x49,0x49,0x49,0x41, // -E-
- 0x7F,0x09,0x09,0x09,0x01, // -F-
- 0x3E,0x41,0x51,0x51,0x72, // -G-
- 0x7F,0x08,0x08,0x08,0x7F, // -H-
- 0x00,0x41,0x7F,0x41,0x00, // -I-
- 0x20,0x40,0x41,0x3F,0x01, // -J-
- 0x7F,0x08,0x14,0x22,0x41, // -K-
- 0x7F,0x40,0x40,0x40,0x40, // -L-
- 0x7F,0x02,0x0C,0x02,0x7F, // -M-
- 0x7F,0x04,0x08,0x10,0x7F, // -N-
- 0x3E,0x41,0x41,0x41,0x3E, // -O-
-
- 0x7F,0x09,0x09,0x09,0x06, // -P-
-
- 0x3E,0x41,0x51,0x21,0x5E, // -Q-
-
- 0x7F,0x09,0x19,0x29,0x46, // -R-
-
- 0x26,0x49,0x49,0x49,0x32, // -S-
-
- 0x01,0x01,0x7F,0x01,0x01, // -T-
-
- 0x3F,0x40,0x40,0x40,0x3F, // -U-
-
- 0x1F,0x20,0x40,0x20,0x1F, // -V-
-
- 0x7F,0x20,0x18,0x20,0x7F, // -W-
-
- 0x63,0x14,0x08,0x14,0x63, // -X-
-
- 0x03,0x04,0x78,0x04,0x03, // -Y-
-
- 0x61,0x51,0x49,0x45,0x43, // -Z-
-
- 0x7F,0x7F,0x41,0x41,0x00, // -[-
-
- 0x02,0x04,0x08,0x10,0x20, // -\-
-
- 0x00,0x41,0x41,0x7F,0x7F, // -]-
-
- 0x04,0x02,0x7F,0x02,0x04, // -^-
-
- 0x08,0x1C,0x2A,0x08,0x08, // -_-
-
- 0x00,0x00,0x01,0x02,0x04, // -`-
-
- 0x24,0x54,0x54,0x38,0x40, // -a-
-
- 0x7F,0x28,0x44,0x44,0x38, // -b-
-
- 0x38,0x44,0x44,0x44,0x08, // -c-
-
- 0x38,0x44,0x44,0x28,0x7F, // -d-
-
- 0x38,0x54,0x54,0x54,0x08, // -e-
-
- 0x08,0x7E,0x09,0x09,0x02, // -f-
-
- 0x98,0xA4,0xA4,0xA4,0x78, // -g-
-
- 0x7F,0x08,0x04,0x04,0x78, // -h-
-
- 0x00,0x00,0x79,0x00,0x00, // -i-
-
- 0x00,0x80,0x88,0x79,0x00, // -j-
-
- 0x7F,0x10,0x28,0x44,0x40, // -k-
-
- 0x00,0x41,0x7F,0x40,0x00, // -l-
-
- 0x78,0x04,0x78,0x04,0x78, // -m-
-
- 0x04,0x78,0x04,0x04,0x78, // -n-
-
- 0x38,0x44,0x44,0x44,0x38, // -o-
-
- 0xFC,0x24,0x24,0x24,0x18, // -p-
-
- 0x18,0x24,0x24,0x24,0xFC, // -q-
-
- 0x04,0x78,0x04,0x04,0x08, // -r-
-
- 0x48,0x54,0x54,0x54,0x24, // -s-
-
- 0x04,0x3F,0x44,0x44,0x24, // -t-
-
- 0x3C,0x40,0x40,0x3C,0x40, // -u-
-
- 0x1C,0x20,0x40,0x20,0x1C, // -v-
-
- 0x3C,0x40,0x3C,0x40,0x3C, // -w-
-
- 0x44,0x28,0x10,0x28,0x44, // -x-
-
- 0x9C,0xA0,0xA0,0x90,0x7C, // -y-
-
- 0x44,0x64,0x54,0x4C,0x44, // -z-
-
- 0x08,0x36,0x41,0x00,0x00, // -{-
-
- 0x00,0x00,0x77,0x00,0x00, // -|-
-
- 0x00,0x00,0x41,0x36,0x08, // -}-
-
- 0x08,0x04,0x08,0x10,0x08, // -~-
-
- 0x55,0x2A,0x55,0x2A,0x55, // --
- };
复制代码 |