屏幕已驱动起
This commit is contained in:
+79
-25
@@ -67,6 +67,7 @@ uint8_t Read_Ds()
|
||||
//return READ_HC595_DCK;
|
||||
}
|
||||
|
||||
//send data to 959
|
||||
void Sand_Byte_to_595_2(uint8_t h)
|
||||
{
|
||||
ds_in_or_out(1);
|
||||
@@ -88,8 +89,6 @@ void Sand_Byte_to_595_2(uint8_t h)
|
||||
HC595_RCK(1);
|
||||
HC595_RCK(0);
|
||||
}
|
||||
|
||||
|
||||
void hc2_sever()
|
||||
{
|
||||
char h=0;
|
||||
@@ -116,6 +115,7 @@ void hc2_sever()
|
||||
Sand_Byte_to_595_2(h);
|
||||
}
|
||||
|
||||
//motor cool start
|
||||
void moto_server()
|
||||
{
|
||||
if(HAL_GetTick()>moto.moto_run)
|
||||
@@ -206,6 +206,64 @@ void moto_server()
|
||||
dis_buff.moto2b=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const unsigned char LED_Tab[]=
|
||||
{
|
||||
0x7d,0x05,0x5b,0x1f,0x27,0x3e,0x7e,0x15,0x7f,0x3f, //0-9
|
||||
0x77,0x6e,0x71,0x5e,0x7a,0x73, //a-f
|
||||
0x00,0x02
|
||||
};
|
||||
#define A 0x80
|
||||
#define B 0x40
|
||||
#define C 0x20
|
||||
#define D 0x10
|
||||
#define E 0x08
|
||||
#define F 0x04
|
||||
#define G 0x02
|
||||
#define H 0x01
|
||||
void HT1621_Display_GetButton(void)
|
||||
{
|
||||
unsigned char send_buff[8]={0,0,0,0,0,0,0,0,0};
|
||||
unsigned char lcd_buff[4]={0,0,0,0};
|
||||
|
||||
//WritenDataHT1621(0,send_buff,8);
|
||||
|
||||
lcd_buff[0]=LED_Tab[dis_buff.d_num[0]];
|
||||
if(dis_buff.dot1==1)
|
||||
{
|
||||
lcd_buff[0]|=0x80;
|
||||
}
|
||||
lcd_buff[1]=LED_Tab[dis_buff.d_num[1]];
|
||||
if(dis_buff.dot2==1)
|
||||
{
|
||||
lcd_buff[1]|=0x80;
|
||||
}
|
||||
lcd_buff[2]=LED_Tab[dis_buff.d_num[2]];
|
||||
if(dis_buff.dot3==1)
|
||||
{
|
||||
lcd_buff[2]|=0x80;
|
||||
}
|
||||
lcd_buff[3]=LED_Tab[dis_buff.d_num[3]];
|
||||
if(dis_buff.dot4==1)
|
||||
{
|
||||
lcd_buff[3]|=0x80;
|
||||
}
|
||||
send_buff[0]=lcd_buff[0]>>4;
|
||||
send_buff[1]=lcd_buff[0]&0x0f;
|
||||
send_buff[2]=lcd_buff[1]>>4;
|
||||
send_buff[3]=lcd_buff[1]&0x0f;
|
||||
send_buff[4]=lcd_buff[2]>>4;
|
||||
send_buff[5]=lcd_buff[2]&0x0f;
|
||||
send_buff[6]=lcd_buff[3]>>4;
|
||||
send_buff[7]=lcd_buff[3]&0x0f;
|
||||
|
||||
|
||||
WritenDataHT1621(0,send_buff,8);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void my_code()
|
||||
@@ -214,12 +272,9 @@ void my_code()
|
||||
uint8_t mode=0,overload_mode=0;
|
||||
|
||||
uint16_t overload_times=0;
|
||||
long countdown=0;
|
||||
long countdown=1000;
|
||||
long countdown_set=15000;
|
||||
dis_buff.d_num[0]=8;
|
||||
dis_buff.d_num[1]=8;
|
||||
dis_buff.d_num[2]=8;
|
||||
dis_buff.d_num[3]=8;
|
||||
|
||||
|
||||
dis_buff.moto1a=0;
|
||||
dis_buff.moto1b=0;
|
||||
@@ -241,21 +296,19 @@ void my_code()
|
||||
HT1621_Init();
|
||||
while(1)
|
||||
{
|
||||
//*adc读取 并计滤波 并计算温度*/
|
||||
///*获取两个通道*/
|
||||
//get ADC
|
||||
for(char a=0;a<2;a++)
|
||||
{
|
||||
HAL_ADC_Start(&hadc);
|
||||
while(HAL_ADC_PollForConversion(&hadc,0xffff)!=HAL_OK);
|
||||
ADCC.adc_filtering[a]+=HAL_ADC_GetValue(&hadc); //把读到的值加到滤波缓存
|
||||
ADCC.adc_filtering[a]+=HAL_ADC_GetValue(&hadc);
|
||||
}
|
||||
HAL_ADC_Stop(&hadc);
|
||||
///*开始滤波*/
|
||||
ADCC.filtering_times+=1; //每采样加一次记一次
|
||||
if(ADCC.filtering_times==set_filtering_times) //当达到设定的滤波采样次数
|
||||
ADCC.filtering_times+=1;
|
||||
if(ADCC.filtering_times==set_filtering_times)
|
||||
{
|
||||
ADCC.filtering_times=0;
|
||||
ADCC.adc_value[0]=ADCC.adc_filtering[0]/set_filtering_times; //就除于采样次数
|
||||
ADCC.adc_value[0]=ADCC.adc_filtering[0]/set_filtering_times;
|
||||
ADCC.adc_filtering[0]=0;
|
||||
ADCC.adc_value[1]=ADCC.adc_filtering[1]/set_filtering_times;
|
||||
ADCC.adc_filtering[1]=0;
|
||||
@@ -304,20 +357,22 @@ void my_code()
|
||||
if(dis_buff.led_run==1)
|
||||
{
|
||||
dis_buff.led_run=0;
|
||||
dis_buff.dot4=1;
|
||||
}else
|
||||
{
|
||||
dis_buff.led_run=1;
|
||||
dis_buff.dot4=0;
|
||||
}
|
||||
}
|
||||
dis_buff.d_num[0]=0xff;
|
||||
dis_buff.d_num[1]=0xff;
|
||||
dis_buff.d_num[2]=0xff;
|
||||
dis_buff.d_num[3]=0xff;
|
||||
dis_buff.d_num[0]=16;
|
||||
dis_buff.d_num[1]=16;
|
||||
dis_buff.d_num[2]=16;
|
||||
dis_buff.d_num[3]=16;
|
||||
|
||||
dis_buff.dot1=0;
|
||||
dis_buff.dot2=0;
|
||||
dis_buff.dot3=0;
|
||||
dis_buff.dot4=0;
|
||||
|
||||
overload_times=0;
|
||||
if(key2.code!=0)
|
||||
{
|
||||
@@ -359,7 +414,7 @@ void my_code()
|
||||
dis_buff.d_num[3]=(countdown/100)%10;
|
||||
dis_buff.d_num[2]=(countdown/1000)%10;
|
||||
dis_buff.d_num[1]=((countdown/10000)%10);
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?255:dis_buff.d_num[1];
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?16:dis_buff.d_num[1];
|
||||
dis_buff.dot3=1;
|
||||
|
||||
if(key3.code!=0)
|
||||
@@ -405,7 +460,7 @@ void my_code()
|
||||
dis_buff.d_num[3]=(countdown/100)%10;
|
||||
dis_buff.d_num[2]=(countdown/1000)%10;
|
||||
dis_buff.d_num[1]=((countdown/10000)%10);
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?255:dis_buff.d_num[1];
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?16:dis_buff.d_num[1];
|
||||
dis_buff.dot3=1;
|
||||
if(key2.code!=0)
|
||||
{
|
||||
@@ -459,7 +514,7 @@ void my_code()
|
||||
dis_buff.d_num[3]=(countdown_set/100)%10;
|
||||
dis_buff.d_num[2]=(countdown_set/1000)%10;
|
||||
dis_buff.d_num[1]=((countdown_set/10000)%10);
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?255:dis_buff.d_num[1];
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?16:dis_buff.d_num[1];
|
||||
dis_buff.dot3=1;
|
||||
|
||||
break;
|
||||
@@ -474,7 +529,7 @@ void my_code()
|
||||
dis_buff.d_num[3]=(countdown/100)%10;
|
||||
dis_buff.d_num[2]=(countdown/1000)%10;
|
||||
dis_buff.d_num[1]=((countdown/10000)%10);
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?255:dis_buff.d_num[1];
|
||||
dis_buff.d_num[1]=dis_buff.d_num[1]==0?16:dis_buff.d_num[1];
|
||||
dis_buff.dot3=1;
|
||||
if(key4.code!=0){mode=1;}
|
||||
|
||||
@@ -518,8 +573,7 @@ void my_code()
|
||||
GEI_BUTTON_CODE(&key2,dis_buff.button_flag[1]);
|
||||
GEI_BUTTON_CODE(&key3,dis_buff.button_flag[2]);
|
||||
GEI_BUTTON_CODE(&key4,dis_buff.button_flag[3]);
|
||||
//display_and_button_loop();
|
||||
HT1621_Display();
|
||||
HT1621_Display_GetButton();
|
||||
hc2_sever();
|
||||
moto_server();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user