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_3 _TIM_Interrupt/led_num.c

144 lines
1.9 KiB
C

#include <reg52.h>
#include "led_num.h"
#include <intrins.h>
#include "delay.h"
#define DUTY 10
static unsigned int i = 0;
const unsigned char hello_var[] = {0x89, 0x86, 0xc7, 0xc7, 0xc0,0xff};
static unsigned char get_var(int k)
{
return hello_var[(65535-i+k)%6];
}
static unsigned char var2 = 0xfd;
static unsigned int count = 0;
static unsigned char e = 0xfe;
void hello_display()
{
if(count < DUTY)
{
P0 = 0xfe;
P2 = get_var(5);
delay(1);
P2 = 0XFF;
P0 = 0xfd;
P2 = get_var(4);
delay(1);
P2 = 0XFF;
P0 = 0xfb;
P2 = get_var(3);
delay(1);
P2 = 0XFF;
P0 = 0xf7;
P2 = get_var(2);
delay(1);
P2 = 0XFF;
P0 = 0xef;
P2 = get_var(1);
delay(1);
P2 = 0XFF;
P0 = 0xdf;
P2 = get_var(0);
delay(1);
P2 = 0XFF;
// var2 = var2 >> 1;
// if(var2 == 0)
// var2 = 0x10;
}
if(count >= DUTY)
{
P2 = 0XFF;
}
count++;
if(count >= 100)
count = 0;
return;
}
void hello_push()
{
// var2 = _crol_(var2, 1);
i++;
// if(var2 < 0xdf)
// {
// i = 0;
// var2 = 0xfd;
// }
}
void num_display()
{
if(count < DUTY)
{
P0 = 0xfe;
P2 = e;
delay(1);
P2 = 0XFF;
// var2 = var2 >> 1;
// if(var2 == 0)
// var2 = 0x10;
}
if(count >= DUTY)
{
P2 = 0XFF;
}
count++;
if(count >= 100)
count = 0;
return;
}
void num_push()
{
e = _crol_(e, 1);
}
void ledfull()
{
P2 = 0xff;
P0 = 0X00;
}
void hello_full_display()
{
if(count < DUTY)
{
unsigned char var3=0xfd;
int j;
for(j=0;j<5;j++)
{
var3 = _crol_(var3,1);
P1=var3;
P2 = hello_var[i];
delay(1);
P2 = 0XFF;
}
// var2 = var2 >> 1;
// if(var2 == 0)
// var2 = 0x10;
}
if(count >= DUTY)
{
P2 = 0XFF;
}
count++;
if(count >= 100)
count = 0;
return;
}