51_LanQiaoBei/题目/真题/12 第十二届国赛_左岚/第十二届国赛/Driver/Seg.c
2025-04-13 01:02:19 +08:00

22 lines
654 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <Seg.h>
// 段选 0 1 2 3 4 5 6 7 8 9 灭 L F C H 上- 中- 下- P
unsigned char seg_dula[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0xff,
0xc7, 0x8e, 0xc6, 0x89, 0xfe, 0xbf, 0xf7, 0x8c};
// 位选 2^0,2^1,2^2,2^3,2^4,2^52^6,2^7一共八个按键
unsigned char seg_wela[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
void Seg_Disp(unsigned char wela, dula, point)
{
// 手动消抖
P0 = 0xff;
P2 = P2 & 0x1f | 0xe0;
P0 = seg_wela[wela];
P2 = P2 & 0x1f | 0xc0;
P2 &= 0x1f;
P0 = seg_dula[dula];
if (point)
P0 &= 0x7f;
P2 = P2 & 0x1f | 0xe0;
P2 &= 0x1f;
}