📄 clockofoled.lst
字号:
C51 COMPILER V7.50 CLOCKOFOLED 08/28/2007 15:41:04 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE CLOCKOFOLED
OBJECT MODULE PLACED IN clockofoled.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE clockofoled.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <REG932.H>
2 #include "zimo.h"
3
4 sbit UP=P3^1;
5 sbit DOWN=P3^0;
6 unsigned char temp,s,min,hour;
7
8 void disc(unsigned char,unsigned char,unsigned char *);
9 void dish(unsigned char,unsigned char,unsigned char *);
10 void disn(unsigned char,unsigned char,unsigned char);
11 void ini_oled(void);
12 void WriteCommand(unsigned);
13 void ini_io(void);
14
15 void welcome()
16 {
17 1 /* disc(0,0,w);
18 1 disc(1,0,w);
19 1 disc(2,0,w);
20 1 disc(3,0,dot);
21 1 disc(4,0,h);
22 1 disc(5,0,h);
23 1 disc(6,0,d);
24 1 disc(7,0,z);
25 1 disc(8,0,w);
26 1 disc(9,0,dot);
27 1 disc(10,0,c);
28 1 disc(11,0,o);
29 1 disc(12,0,m);
30 1
31 1 /* WriteCommand(0x26);
32 1 WriteCommand(0x02);
33 1 WriteCommand(0xb6);
34 1 WriteCommand(0x00);
35 1 WriteCommand(0xb7);
36 1
37 1 WriteCommand(0x2f);*/
38 1 disc(2,0,o);
39 1 disc(3,0,l);
40 1 disc(4,0,e);
41 1 disc(5,0,d);
42 1 dish(6,0,dian);
43 1 dish(8,0,zi);
44 1 dish(10,0,shi);
45 1 dish(12,0,zhong);
46 1
47 1 //dish(0,1,gong);dish(2,1,li);
48 1 disn(1,1,2);disn(2,1,0);disn(3,1,0);disn(4,1,6);dish(5,1,year);
49 1 disn(7,1,1);disn(8,1,1);dish(9,1,month);disn(11,1,0);disn(12,1,9);dish(13,1,day);
50 1 //dish(0,3,nong);dish(2,3,li);
51 1 dish(5,3,xing);dish(7,3,qi);dish(9,3,si);
52 1
53 1 disn(4,2,0);disn(5,2,0);disc(6,2,mao);disn(7,2,0);
54 1 disn(8,2,0);disc(9,2,mao);disn(10,2,0);disn(11,2,0);
55 1 }
C51 COMPILER V7.50 CLOCKOFOLED 08/28/2007 15:41:04 PAGE 2
56 void ini()
57 {
58 1 TMOD=0x01;
59 1 ET0=1;
60 1 EA=1;
61 1 TR0=1;
62 1 }
63
64 void ini_io()
65 {
66 1 P1M1 = 0x00;
67 1 P1M2 = 0x00;
68 1 P0M1 = 0x00;
69 1 P0M2 = 0x00;
70 1 P2M1 = 0x00;
71 1 P2M2 = 0x00;
72 1 DIVM=12;
73 1 }
74
75 void main()
76 {
77 1 unsigned long cc;
78 1 unsigned char state=1;
79 1 ini();
80 1 ini_io();
81 1 ini_oled();
82 1 WriteCommand(0xAD); // Set DC-DC
83 1 WriteCommand(0x8B); // 8B=ON, 8A=Off
84 1 welcome();
85 1 WriteCommand(0xaf);
86 1 EA=0;
87 1 while(1){}
88 1 {
89 2 if(!DOWN)
90 2 {
91 3 WriteCommand(0xAf); // AF=ON , AE=OFF
92 3 while(!DOWN);
93 3 state++;
94 3 if(state>=10)
95 3 min++;
96 3 if(min>59)
97 3 min=0;
98 3 WriteCommand(0x2e);
99 3 disn(7,2,min/10);
100 3 disn(8,2,min%10);
101 3 WriteCommand(0x2f);
102 3 cc=0;
103 3 }
104 2 if(!UP)
105 2 {
106 3 WriteCommand(0xAF); // AF=ON , AE=OFF
107 3 while(!UP);
108 3 if(state!=0)
109 3 hour++;
110 3 if(hour>23)
111 3 hour=0;
112 3 WriteCommand(0x2e);
113 3 disn(4,2,hour/10);
114 3 disn(5,2,hour%10);
115 3 WriteCommand(0x2f);
116 3 cc=0;
117 3 } // key panduan
C51 COMPILER V7.50 CLOCKOFOLED 08/28/2007 15:41:04 PAGE 3
118 2 if(cc>=400000)
119 2 {
120 3 // WriteCommand(0xae);
121 3 cc=500000;
122 3 state=0;
123 3 }
124 2 else
125 2 {
126 3 cc++;
127 3 state=10;
128 3 }
129 2 }
130 1 }
131
132 void timer0() interrupt 1 using 0
133 {
134 1 TH0=0X4C;
135 1 TL0=0X00;
136 1 temp++;
137 1 WriteCommand(0x2e); //水平滚动关闭
138 1 if(temp>=20)
139 1 {
140 2 temp=0;
141 2 s++;
142 2 if(s>59)
143 2 {
144 3 s=0;
145 3 min++;
146 3 if(min>59)
147 3 {
148 4 min=0;
149 4 hour++;
150 4 if(hour>23)
151 4 hour=0;
152 4 disn(4,2,hour/10);
153 4 disn(5,2,hour%10);
154 4
155 4 }
156 3 disn(7,2,min/10);
157 3 disn(8,2,min%10);
158 3 }
159 2 disn(10,2,s/10);
160 2 disn(11,2,s%10);
161 2 }
162 1 WriteCommand(0x2f); //水平滚动使能
163 1 }
164
165 //以下为接口定义,根据用户的实验板接口不同而自行定义
166
167 //#define PAR 1
168 #ifdef PAR
#define DAT P0
sbit WRO=P2^7;
sbit RDO=P2^6;
sbit RES=P2^5;
sbit DC=P2^4;
sbit CS=P2^3;
#else
176 //以上为数据端口定义
177 sbit CLK=P0^2; //*原为P0^0
178 sbit DATA=P2^2;
179 sbit RES1=P2^5;
C51 COMPILER V7.50 CLOCKOFOLED 08/28/2007 15:41:04 PAGE 4
180 sbit DC=P2^4;
181 sbit CS=P2^3;
182 #endif
183 unsigned char code num[10][16]={
184 {0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0"*/
185 {0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1"*/
186 {0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2"*/
187 {0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3"*/
188 {0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4"*/
189 {0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5"*/
190 {0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6"*/
191 {0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7"*/
192 {0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8"*/
193 {0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44,0x10,0x44,0x08,0x88,0x07,0xF0,0x00,0x00} /*"9"*/
194 };
195 //****************************主要操作函数************************************
196 void WriteCommand(unsigned com); //写命令程序
197 void WriteData(unsigned dat); //写数据程序
198 void esbusini(void); //初始化总线程序
199 void ini_oled(void); //OLED初始化
200 void ini_dis(void); //显示初始化(清除缓冲区)
201 /**************************实现函数********************************************
202 *函数原型: unsigned char ReadCommand(void);
203 *功 能: 从oled上读当前命令到控制器。
204 *******************************************************************************/
205 void WriteCommand(unsigned com)
206 {
207 1 #ifdef PAR
CS=1;
DC=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -