快捷搜索:

鲜有人知2.8寸液晶屏工控设备大绝招,这些你一定要知道

鲜有人知2.8寸液晶屏工控设备大绝招,这些你一定要知道

介绍2.8寸液晶屏工控设备,根据同学的提问这是小单采集到关于如何在LCD上显示日历表的一个小程序在这里和大家分享下希望能帮助到有需要的同学。LCD可以简单的显示一些字母数字但是对于汉字来说显示起来还是不太好不怎么好显示毕竟像素比较低所以这次我们的程序里面用的是英文字母来代替汉字。效果图程序代码lcdh#ifndef_LCD_H_#define_LCD_H_#include#includesbitRS=P^;sbitRW=P^;sbitEN=P^;#defineRS_CLRRS=#defineRS_SETRS=#defineRW_CLRRW=#defineRW_SETRW=#defineEN_CLREN=#defineEN_SETEN=#definedataportP#defineucharunsignedcharexternvoidDelayUsxuchart;externvoidDelayMsuchart;externvoidLCD_Write_COMucharcom;写指令externvoidLCD_Write_DataucharData;externvoidLCD_Clear;externvoidLCD_Write_Stringucharx,uchary,uchars;externvoidLCD_Write_Charucharx,uchary,ucharc;externvoidLCD_Init;#endiflcdc#include"lcdh"voidDelayUsxuchart{whilet;}voidDelayMsuchart{whilet{DelayUsx;DelayUsx;}}bitLCD_Check_busyvoid{dataport=xff;RS_CLR;RW_SET;EN_CLR;_nop_;EN_SET;returnbitdataport&x;}写指令voidLCD_Write_COMucharcom{DelayMs;RS_CLR;RW_CLR;EN_SET;dataport=com;_nop_;EN_CLR;}写数据voidLCD_Write_DataucharData{DelayMs;RS_SET;RW_CLR;EN_SET;dataport=Data;_nop_;EN_CLR;}清屏voidLCD_Clear{LCD_Write_COMx;DelayMs;}输入字符x为横坐标y为纵坐标voidLCD_Write_Stringucharx,uchary,uchars{ify=={LCD_Write_COMxx;}else{LCD_Write_COMxCx;}whiles{LCD_Write_Datas;s;}}输入字符x为横坐标y为纵坐标voidLCD_Write_Charucharx,uchary,ucharc{ify=={LCD_Write_COMxx;}else{LCD_Write_COMxCx;}LCD_Write_Datac;}voidLCD_InitLCD初始化子程序{EN_CLR;LCD_Write_COMx;设置显示模式DelayMs;LCD_Write_COMx;设置显示模式DelayMs;LCD_Write_COMx;设置显示模式DelayMs;LCD_Write_COMx;设置显示模式DelayMs;LCD_Write_COMxc;开显示不显示光标光标闪烁LCD_Write_COMx;写一个指针加一LCD_Write_COMx;清屏LCD_Write_COMx;设置数据指针起点}mainc#include"lcdh"ucharhour=,min=,sec=,count,date=,monse=;unsignedintyear=;voidinit_T{EA=;ET=;TMOD=X;TH=XC;TL=XB;TR=;}voidmain{init_T;LCD_Init;LCD_Clear;while{LCD_Write_String,,"Date";LCD_Write_Char,,year;LCD_Write_Char,,year;LCD_Write_Char,,year;LCD_Write_Char,,year;LCD_Write_Char,,'';LCD_Write_Char,,monse;LCD_Write_Char,,monse;LCD_Write_Char,,'';LCD_Write_Char,,date;LCD_Write_Char,,date;LCD_Write_String,,"Time";LCD_Write_Char,,hour;LCD_Write_Char,,hour;LCD_Write_Char,,'';LCD_Write_Char,,min;LCD_Write_Char,,min;LCD_Write_Charxa,,'';LCD_Write_Charxb,,sec;LCD_Write_Charxc,,sec;}}voidinterinterrupt{TH=XC;TL=XB;count;ifcount>={count=;sec;}ifsec>={sec=;min;}ifmin>={min=;hour;}ifhour>={hour=;date;}ifdate>{date=;monse;}ifmonse>{monse=;year;}}本文来自CSDN

您可能还会对下面的文章感兴趣: