📄 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,0xff}; //共阳数码管
/*--------------------------------------------------------*/
//para number: the number to be displayed
/*--------------------------------------------------------*/
void display(unsigned int number)
{
PORTB &=~BIT(PORTB0); //light the first bit of the shumaguan
//PORTB0 was defined in iom16v.h
PORTA=discode[number/1000]; //display the thousand bit
delay_nms(5);
PORTB |=BIT(PORTB0); //turn off the first bit of the shumaguan
PORTB &=~BIT(PORTB1);
PORTA=discode[number/100%10];
delay_nms(5);
PORTB |=BIT(PORTB1);
PORTB &=~BIT(PORTB2);
PORTA=discode[number%100/10];
delay_nms(5);
PORTB |=BIT(PORTB2);
PORTB &=~BIT(PORTB3);
PORTA=discode[number%10];
delay_nms(5);
PORTB |=BIT(PORTB3);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -