📄 memory clockί
字号:
#include <reg52.h>//包含52单片机头文件
#include "Lcd.h"
#include "main.h"
#include "Assistance.h"
uchar number;
void delay(uint z) //延时函数
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void LcdInit()
{
lcden=0;
write_com(0x38);//设置16X2显示,5X7点阵,8位数据接口
write_com(0x0c);//设置开显示,不显示光标
write_com(0x06);//写一个字符后地址指针加1
write_com(0x01);//显示清零,数据指针清零
write_com(0x80);//设置显示初始坐标
}
void write_com(uchar com)//液晶写命令函数
{
rs=0;
lcden=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date)//液晶写数据函数
{
rs=1;
lcden=0;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_sfm(uchar add,uchar date)//写时分秒函数
{
uchar shi,ge;
shi=date/10;//分解一个2位数的十位和个位
ge=date%10;
write_com(0x80+0x40+add);//设置显示位置
write_date(0x30+shi);//送去液晶显示十位
write_date(0x30+ge); //送去液晶显示个位
}
void write_sfm1(uchar add,uchar date)//写时分秒函数
{
uchar ge;
ge=date%10;
write_com(0x80+0x40+add);//设置显示位置
write_date(0x30+ge); //送去液晶显示个位
}
void write_sfm2(uchar add,uchar date)//写时分秒函数
{
uchar shi;
shi=date%10;//分解一个2位数的十位和个位
write_com(0x80+0x40+add);//设置显示位置
write_date(0x30+shi);//送去液晶显示十位
}
void write_year(uchar add,uchar date)//写时分秒函数
{
uchar shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+add);//设置显示位置
write_date(0x30+shi);//送去液晶显示十位
write_date(0x30+ge); //送去液晶显示个位
}
void write_month(uchar add,uchar date)//写月函数
{
uchar shi,ge;
shi=date/10;//分解一个2位数的十位和个位
ge=date%10;
write_com(0x80+add);//设置显示位置
write_date(0x30+shi);//送去液晶显示十位
write_date(0x30+ge); //送去液晶显示个位
}
void write_day(uchar add,uchar date)//写日函数
{
uchar shi,ge;
shi=date/10;//分解一个2位数的十位和个位
ge=date%10;
write_com(0x80+add);//设置显示位置
write_date(0x30+shi);//送去液晶显示十位
write_date(0x30+ge); //送去液晶显示个位
}
void write_weekDay(uchar add,uchar date)//写时分秒函数
{
write_com(0x80+add);//设置显示位置
for(number=0;number<3;number++)
{
write_date(weekTable[date][number]);//送去液晶显示十位
delay(2);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -