显示部分已驱动

This commit is contained in:
2021-09-18 10:34:38 +08:00
parent d9c604f623
commit adc745e2a7
5 changed files with 7319 additions and 3473 deletions
+80 -8
View File
@@ -15,12 +15,8 @@
const char d_num_data[2][10]=
{
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
},
{
0xed,0x48,0xe6,0x6e,0x4b,0x2f,0xaf,0x68,0xef,0x6f
}
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f},
{0xed,0x48,0xe6,0x6e,0x4b,0x2f,0xaf,0x68,0xef,0x6f}
};
struct
@@ -69,20 +65,96 @@ void Send_to_595(char h,char l)
HC595_RCK(0);
}
void display()
{
char h_buff=0,l_buff=0;
Send_to_595(h_buff,l_buff);
h_buff=0,l_buff=0;
h_buff=~0x01;
l_buff=d_num_data[0][dis_buff.d_num[0]];
if(dis_buff.dot1==1)
{
l_buff|=0x80;
}
Send_to_595(h_buff,l_buff);
h_buff=0,l_buff=0;
h_buff=~0x80;
l_buff=d_num_data[1][dis_buff.d_num[1]];
if(dis_buff.dot2==1)
{
l_buff|=0x10;
}
Send_to_595(h_buff,l_buff);
h_buff=0,l_buff=0;
h_buff=~0x40;
l_buff=d_num_data[0][dis_buff.d_num[2]];
if(dis_buff.dot3==1)
{
l_buff|=0x80;
}
Send_to_595(h_buff,l_buff);
h_buff=0,l_buff=0;
h_buff=0xC1;
l_buff=d_num_data[1][dis_buff.d_num[3]];
if(dis_buff.dot4==1)
{
l_buff|=0x10;
}
if(dis_buff.led_run==1)
{
h_buff|=0x10;
}
if(dis_buff.led_err==1)
{
h_buff|=0x08;
}
if(dis_buff.led_n==1)
{
h_buff|=0x04;
}
if(dis_buff.led_p==1)
{
h_buff|=0x02;
}
Send_to_595(h_buff,l_buff);
}
void mymain()
{
uint32_t runtime=0;
MOTA(0);
MOTB(0);
HC595_DCK(0);
HC595_RCK(0);
HC595_SCK(0);
Send_to_595(0x00,0x6f);
dis_buff.d_num[0]=1;
while(1)
{
if(HAL_GetTick()>runtime)
{
runtime+=1000;
dis_buff.d_num[0]=rand()%10;
dis_buff.d_num[1]=rand()%10;
dis_buff.d_num[2]=rand()%10;
dis_buff.d_num[3]=rand()%10;
dis_buff.dot1=rand()%2;
dis_buff.dot2=rand()%2;
dis_buff.dot3=rand()%2;
dis_buff.dot4=rand()%2;
dis_buff.led_err=rand()%2;
dis_buff.led_n=rand()%2;
dis_buff.led_p=rand()%2;
dis_buff.led_run=rand()%2;
}
display();
}
}