📄 seg7.c
字号:
#include "seg7.h"
void seg7(int n)
{
int i;
int seg7_val[16] = {
DISP_0,
DISP_1,
DISP_2,
DISP_3,
DISP_4,
DISP_5,
DISP_6,
DISP_7,
DISP_8,
DISP_9,
DISP_A,
DISP_B,
DISP_C,
DISP_D,
DISP_E,
DISP_F,
};
if (n > 16)
return;
i = n & 0xf;
SEG7 = seg7_val[i];
if (n == 16)
SEG7 = DISP_INVALID;
}
int ctoi(char ch)
{
int res;
switch(ch)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
res = (int)(ch - '0'); break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
res = (int)(ch -'A' + 10); break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
res = (int)(ch -'a' + 10); break;
default:
res = 16;
}
return res;
}
static void delay(int count)
{
int i;
while (count--)
for (i = 0; i < 65535; i++)
;
}
void seg7demo(void)
{
int i;
for (i = 0; i < 16; i++)
{
seg7(i);
delay(20);
}
seg7(0);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -