📄 shumaguan.h
字号:
/*
this file is the head file
*/
#include<iom16v.h>
#include<macros.h>
#include"delay.h"
//macros.h 中有BIT(x) (1 << (x))定义, 比如 BIT(5)相当于将第5位置1
const unsigned char discode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
0x82,0xf8,0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e,0xbf}; //共阳数码管
/*------------------------------------------------------------------
fuction: display in hex formart
para : hi--the high two bits to be displayed
low--the low two bits to be displayed
-------------------------------------------------------------------*/
void display(unsigned char num)
{
PORTB &=~BIT(PORTB0); //light the first bit of the shumaguan
//PORTB0 was defined in iom16v.h
PORTA=discode[num>>4]; //display the thousand bit
delay_nms(5);
PORTB |=BIT(PORTB0); //turn off the first bit of the shumaguan
PORTB &=~BIT(PORTB1);
PORTA=discode[num%16];
delay_nms(5);
PORTB |=BIT(PORTB1);
}
/*---------------------------------------------------------------------
fuction: display error,this will display "- - - -" on the four bits leds
----------------------------------------------------------------------*/
void displayerror(void)
{
PORTB &=~1; //light the first bit of the shumaguan
//PORTB0 was defined in iom16v.h
PORTA=discode[16]; //display the thousand bit
delay_nms(5);
PORTB |=1; //turn off the first bit of the shumaguan
PORTB &=~2;
PORTA=discode[16];
delay_nms(5);
PORTB |=2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -