⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 门禁系统 interated with LCD
💻 C
字号:
#include "Display.h"

void Display2(int number)	
{	
	//Digits |4|3|2|1|
	int temp1,temp2,temp3,temp4;
	int TEMPTRISB = TRISB, TEMPTRISD = TRISD; //Save curent TRIS bits
 	TRISB = TRISB & 0xF0;	//Set PortB lower 4 bits to output
 	TRISD = 0x00;
 	
  	temp1 = number/1000; 											//Thousands
	temp2 = ((number - (temp1*1000))/100); 							//Hundreds
	temp3 = ((number - (temp1*1000) -  (temp2 *100))/10); 				//Tens
	temp4 = ((number - (temp1*1000) - (temp2 *100) - (temp3 * 10))); 	//Ones
	
	if (temp4 > 9) { temp4 -= 10; temp3++;}
	if (temp3 > 9) { temp3 -= 10; temp2++;}	
	if (temp2 > 9) { temp2 -= 10; temp1++;}
	if (temp1 > 9)  temp1 -= 10; 
	PORTB =((PORTB & 0xF0) | (temp4));
	PORTD = 0x00;	//select Digit 1 Disable Write
	PORTD = 0x40;	//select Digit 1 Disable Write

	PORTB = ((PORTB & 0xF0) | (temp3));	//select Digit 2 Enable Write
	PORTD = 0x10;	//select Digit 1 Disable Write
	PORTD = 0x50;	//select Digit 2 Disable Write

	PORTB = ((PORTB & 0xF0)| (temp2));	//select Digit 3 Enable Write
	PORTD = 0x20;	//select Digit 1 Disable Write
	PORTD = 0x60;	//select Digit 3 Disable Write
	
	PORTB = ((PORTB &  0xF0 )|(temp1));	//select Digit 4 Enable Write
	PORTD = 0x30;	//select Digit 1 Disable Write
	PORTD = 0x70;	//select Digit 4 Disable Write
	TRISB = TEMPTRISB;
	TRISD = TEMPTRISD;
}
void Display(int number)	
{	
	//Digits |4|3|2|1|
	int temp1,temp2,temp3,temp4;
	int TEMPTRISB = TRISB,TEMPPORTB = PORTB;
	TRISB = TRISB & 0x00; //Set PortB lower 4 bits to output
 	
  	temp1 = number/1000; 											//Thousands
	temp2 = ((number - (temp1*1000))/100); 							//Hundreds
	temp3 = ((number - (temp1*1000) -  (temp2 *100))/10); 				//Tens
	temp4 = ((number - (temp1*1000) - (temp2 *100) - (temp3 * 10))); 	//Ones
	if (temp4 > 9) { temp4 -= 10; temp3++;}
	if (temp3 > 9) { temp3 -= 10; temp2++;}	
	if (temp2 > 9) { temp2 -= 10; temp1++;}
	if (temp1 > 9)  temp1 -= 10;
	
	PORTB = 0x00 + temp4;	//select Digit 1 Disable Write
	PORTB = 0x40 + temp4;	//select Digit 1 Disable Write

	
	PORTB = 0x10 + temp3;	//select Digit 1 Disable Write
	PORTB = 0x50 + temp3;	//select Digit 2 Disable Write

	PORTB = 0x20 + temp2;	//select Digit 1 Disable Write
	PORTB = 0x60 + temp2;	//select Digit 2 Disable Write
	
	PORTB = 0x30 + temp1;	//select Digit 1 Disable Write
	PORTB = 0x70 + temp1;	//select Digit 2 Disable Write
	
	TRISB = TEMPTRISB;
	PORTB = TEMPPORTB;
}

void Display_Time(int upper,int lower)
{
	int temp;
	temp = lower + (upper*100);
	Display(temp);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -