基于STC89C52的oled红外遥控闹钟
Posted blogs-192-168-9-222
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于STC89C52的oled红外遥控闹钟相关的知识,希望对你有一定的参考价值。
这个红外遥控主要是程序通过对按下的键的键码进行解析,并运行相应的功能代码
一次按键动作的遥控编码信息为 32 位串行二进制码。对于二进制信号“0”,一个脉冲占 1.2ms;对于二进制信号“1”,一个脉冲占 2.4ms,而每一脉冲内低电平均为 0.6ms。从起始标志到 32 位编码脉冲发完大约需80ms,此后遥控信号维持高电平。若按键未释放,则从起始标志起每隔 108ms 发出 3 个脉冲的重复标志。在 32 位的编码脉冲中,前 16 位码不随按键的不同而变化,我们称之为用户码。它是为了表示特定用户而设置的一个辨识标志,以区别不同机种和不同用户发射的遥控信号,防止误操作。后 16 位码随着按键的不同而改变,我们就是要读取这 16 位按键编码,经解码得到按键键号,转而执行相应控制动作。
主要运用DS1302时钟芯片,红外遥控,oled显示屏,蜂鸣器,定时器,中断实现
研究过程:
1.工程的建立和文件存放分配
2.根据原理图进行全局参数,引脚申明,类型说明头文件的编写
3.功能模块调试
1>oled液晶显示屏功能调试
2>蜂鸣器功能调试 //定时器2
3>DS1302读写调试
4>红外遥控按键功能的调试 //定时器1和外部中断0
4.所有显示程序的调试
5.程序总体功能的调试
7引脚的oled接线:
GND接GND,VCC接VCC,D0,D1,RST,DC接自定义引脚,CS接地。
引脚申明类型说明
1 #ifndef _CONFIG_H_ 2 #define _CONFIG_H_ 3 4 #include"reg52.h" 5 #include"intrins.h" 6 7 typedef signed char int8; 8 typedef signed int int16; 9 typedef unsigned int u16; 10 typedef unsigned char u8; 11 typedef signed long int32; 12 13 #define LED P2 14 #define SYS_MCLK 1000000 15 16 sbit GPIO_KEY=P1; 17 18 sbit OLED_SCLK=P1^0; //D0时钟管脚 19 sbit OLED_SDA=P1^1; //D1数据管脚 20 sbit OLED_RST=P1^2; //电源复位,低电平有效 21 sbit OLED_DC=P1^3; //数据或命令控制管脚 22 23 sbit DS_IO=P3^4 ; 24 sbit DS_SCLK=P3^6; 25 sbit DS_RST=P3^5; 26 27 28 sbit BUZZER=P1^5; 29 30 sbit DSPORT=P3^7; 31 32 sbit IRIN=P3^2; 33 34 #endif
oled显示屏代码
1 #define _OLED_C 2 #include"config.h" 3 #include"OLED.h" 4 #define _OLED_C 5 void OLED_SetPos(u8 x,u8 y); 6 //命令函数 7 const u8 code F6x8[][6] = 8 { 9 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //sp0 10 { 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !1 11 { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // "2 12 { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #3 13 { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // $4 14 { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // %5 15 { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // &6 16 { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // ‘7 17 { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // (8 18 { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // )9 19 { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *10 20 { 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +11 21 { 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // ,12 22 { 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // -13 23 { 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // .14 24 { 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // /15 25 { 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 016 26 { 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 117 27 { 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 218 28 { 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 319 29 { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 420 30 { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 521 31 { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 622 32 { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 723 33 { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 824 34 { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 925 35 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // :26 36 { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ;27 37 { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // <28 38 { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // =29 39 { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // >30 40 { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ?31 41 { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @32 42 { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A33 43 { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B34 44 { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C35 45 { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D36 46 { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E37 47 { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F38 48 { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G39 49 { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H40 50 { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I41 51 { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J42 52 { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K43 53 { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L44 54 { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M45 55 { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N46 56 { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O47 57 { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P48 58 { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q49 59 { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R50 60 { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S51 61 { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T52 62 { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U53 63 { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V54 64 { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W55 65 { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X56 66 { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y57 67 { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z58 68 { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [59 69 { 0x00, 0x02, 0x04, 0x08, 0x10, 0x20 }, // 60 70 { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ]61 71 { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^62 72 { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _63 73 { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // ‘64 74 { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 }, // a65 75 { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b66 76 { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c67 77 { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d68 78 { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, // e69 79 { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f70 80 { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g71 81 { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h72 82 { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i73 83 { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j74 84 { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k75 85 { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l76 86 { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m77 87 { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n78 88 { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o79 89 { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p80 90 { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q81 91 { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r82 92 { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s83 93 { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t84 94 { 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u85 95 { 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v86 96 { 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w87 97 { 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x88 98 { 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y89 99 { 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z90 100 { 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // horiz lines91 101 }; 102 103 const u8 code F8X16[]= 104 { 105 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0 106 0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,//!1 107 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"2 108 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//#3 109 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$4 110 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//%5 111 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//&6 112 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//‘7 113 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//(8 114 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//)9 115 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//*10 116 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+11 117 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//,12 118 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//-13 119 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//.14 120 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,///15 121 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//016 122 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//117 123 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//218 124 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//319 125 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//420 126 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//521 127 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//622 128 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//723 129 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//824 130 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//925 131 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//:26 132 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//;27 133 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//<28 134 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//=29 135 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//>30 136 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//?31 137 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@32 138 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A33 139 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B34 140 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C35 141 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D36 142 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E37 143 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F38 144 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G39 145 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H40 146 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I41 147 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J42 148 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K43 149 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L44 150 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M45 151 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N46 152 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O47 153 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P48 154 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q49 155 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R50 156 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S51 157 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T52 158 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U53 159 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V54 160 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W55 161 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X56 162 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y57 163 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z58 164 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[59 165 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//60 166 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//]61 167 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^62 168 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_63 169 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`64 170 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a65 171 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b66 172 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c67 173 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d68 174 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e69 175 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f70 176 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g71 177 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h72 178 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i73 179 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j74 180 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k75 181 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l76 182 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m77 183 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n78 184 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o79 185 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p80 186 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q81 187 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r82 188 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s83 189 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t84 190 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u85 191 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v86 192 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w87 193 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x88 194 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y89 195 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z90 196 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{91 197 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//|92 198 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//}93 199 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~94 200 }; 201 202 203 204 const u8 code F14x16_Idx[] = 205 { 206 "星期一二日六五四三" 207 }; 208 209 //中文字符串编码 210 const u8 code F14x16[] = 211 212 { 213 214 0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x3E,0x00,0x00, 215 0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x41,0x40,//星 216 0x00,0x04,0xFF,0x24,0x24,0x24,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE, 217 0x88,0x48,0x2F,0x09,0x09,0x19,0xAF,0x48,0x30,0x0F,0x02,0x42,0x82,0x7F,//期 218 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 219 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//一 220 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00, 221 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,//二 222 0x00,0x00,0x00,0xFE,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xFE,0x00,0x00, 223 0x00,0x00,0x00,0xFF,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x00,0x00,//日 224 0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2C,0x20,0x20,0x20,0x20,0x20, 225 0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x60,//六 226 0x00,0x02,0x42,0x42,0x42,0xC2,0x7E,0x42,0x42,0x42,0x42,0xC2,0x02,0x02, 227 0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7F,0x40,0x40,//五 228 0x00,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0xFC, 229 0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7F,//四 230 0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04, 231 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20//三 232 233 }; 234 235 236 void OLED_WriteCmd(u8 Cmd) 237 { 238 u8 i=8 ; 239 OLED_DC=0; 240 OLED_SCLK=0; 241 while(i--) 242 { 243 if(Cmd&0x80) 244 { 245 OLED_SDA=1; 246 } 247 else 248 { 249 OLED_SDA=0; 250 } 251 OLED_SCLK= 1; 252 _nop_(); 253 OLED_SCLK=0; 254 Cmd<<=1; 255 } 256 return; 257 } 258 259 void OLED_WriteDat(u8 Dat) 260 { 261 u8 i=8 ; 262 OLED_DC=1; 263 OLED_SCLK=0; 264 while(i--) 265 { 266 if(Dat&0x80) 267 { 268 OLED_SDA=1; 269 } 270 else 271 { 272 OLED_SDA=0; 273 } 274 OLED_SCLK= 1; 275 _nop_(); 276 OLED_SCLK=0; 277 Dat<<=1; 278 } 279 280 return; 281 } 282 283 void OLED_FILL(u8 date) 284 { 285 u8 Page,Column; 286 for( Page=0;Page<8;Page++) 287 { 288 OLED_WriteCmd(0xb0+Page); 289 OLED_WriteCmd(0x00); 290 OLED_WriteCmd(0x10); 291 for(Column=0;Column<128;Column++) 292 { 293 OLED_WriteDat( date ); 294 } 295 } 296 } 297 298 //初始化 299 300 void OledInit() 301 { 302 303 u8 i; 304 305 OLED_SCLK = 1; 306 OLED_RST = 0; 307 308 for(i = 0; i < 100; i++) 309 { 310 _nop_(); //从上电到下面开始初始化要有足够的时间,即等待RC复位完毕 311 } 312 313 OLED_RST = 1; 314 OLED_WriteCmd(0xae); 315 OLED_WriteCmd(0x00); 316 OLED_WriteCmd(0x10); 317 OLED_WriteCmd(0x40); 318 OLED_WriteCmd(0x81); 319 OLED_WriteCmd(0xcf); 320 OLED_WriteCmd(0xa1); 321 OLED_WriteCmd(0xc8); 322 OLED_WriteCmd(0xa6); 323 OLED_WriteCmd(0xa8); 324 OLED_WriteCmd(0x3f); 325 OLED_WriteCmd(0xd3); 326 OLED_WriteCmd(0x00); 327 OLED_WriteCmd(0xd5); 328 OLED_WriteCmd(0x80); 329 OLED_WriteCmd(0xd9); 330 OLED_WriteCmd(0xf1); 331 OLED_WriteCmd(0xda); 332 OLED_WriteCmd(0x12); 333 OLED_WriteCmd(0xdb); 334 OLED_WriteCmd(0x40); 335 OLED_WriteCmd(0x20); 336 OLED_WriteCmd(0x02); 337 OLED_WriteCmd(0x8d); 338 OLED_WriteCmd(0x14); 339 OLED_WriteCmd(0xa4); 340 OLED_WriteCmd(0xa6); 341 OLED_WriteCmd(0xaf); 342 OLED_FILL(0x00); 343 OLED_SetPos(0,0); 344 } 345 346 void OLED_SetPos(u8 x,u8 y) 347 { 348 OLED_WriteCmd(0xb0 + y); 349 OLED_WriteCmd(((x & 0xf0)>> 4) | 0x10); 350 OLED_WriteCmd((x & 0x0f) | 0x01); 351 } 352 353 void OLED6x8Showstr(u8 x,u8 y,u8 str[]) 354 { 355 356 u8 c=0,i=0,j=0; 357 while(str[j]!=‘