This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/MCU/MCU_6 _UART/display.c

50 lines
781 B
C
Raw Normal View History

2022-04-28 02:00:04 +00:00
#include <reg52.h>
#include "display.h"
#include "delay.h"
const unsigned char num_var[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};
static unsigned char ge, ui, bd, qm, wj, uw;
void fresh_display()
{
P0 = 0xfe;
P2 = num_var[ge];
delay(1);
P2 = 0XFF;
P0 = 0xfd;
P2 = num_var[ui];
delay(1);
P2 = 0XFF;
P0 = 0xfb;
P2 = num_var[bd];
delay(1);
P2 = 0XFF;
P0 = 0xf7;
P2 = num_var[qm];
delay(1);
P2 = 0XFF;
P0 = 0xef;
P2 = num_var[wj];
delay(1);
P2 = 0XFF;
P0 = 0xdf;
P2 = num_var[uw];
delay(1);
P2 = 0XFF;
}
void set_display(unsigned char num)
{
uw = (num % 1000000) / 100000;
wj = (num % 100000) / 10000;
qm = (num % 10000) / 1000;
bd = (num % 1000) / 100;
ui = (num % 100) / 10;
ge = num % 10;
}