屏幕已驱动起
This commit is contained in:
+1
-66
@@ -139,53 +139,9 @@ void WritenDataHT1621(unsigned char Addr,unsigned char *Databuf,unsigned char Cn
|
||||
HC595_RCK(1); //CS 片选关
|
||||
HC595_DCK(1);
|
||||
}
|
||||
/**
|
||||
* @brief 数据交换,自动生成液晶需要的数组,此程序,需要根据液晶图纸修改
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
const unsigned char LED_Tab[]=
|
||||
{
|
||||
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71, //0-15 = 0--f
|
||||
0x58, //16=c
|
||||
0x37, //17=N
|
||||
0x40, //18=-
|
||||
0x0E, //19=J
|
||||
0x3E, //20=U
|
||||
0x76, //21=H
|
||||
0x30, //22=I
|
||||
};
|
||||
unsigned char LCD_RAM_Tab[sizeof(LED_Tab)];
|
||||
|
||||
#define LCD_A 0x01
|
||||
#define LCD_B 0x02
|
||||
#define LCD_C 0x04
|
||||
#define LCD_D 0x08
|
||||
#define LCD_E 0x10
|
||||
#define LCD_F 0x20
|
||||
#define LCD_G 0x40
|
||||
#define LCD_P 0x80
|
||||
|
||||
void HT1621_num_init(void)
|
||||
{
|
||||
unsigned char num,LCD_data;
|
||||
|
||||
for(num=0; num<sizeof(LED_Tab); num++)
|
||||
{
|
||||
LCD_data = 0;
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_P)) << 7);
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_E)) << 6);
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_F)) << 5);
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_A)) << 4);
|
||||
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_D)) << 3);
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_C)) << 2);
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_G)) << 1);
|
||||
LCD_data = LCD_data | ((unsigned char)((char)(LED_Tab[num] & LCD_B)) << 0);
|
||||
|
||||
LCD_RAM_Tab[num] = LCD_data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief HT1621 Init
|
||||
* @param None
|
||||
@@ -209,28 +165,7 @@ void HT1621_Init(void) //退出掉电低功耗状态重新初始化HT1621
|
||||
WriteCommandHT1621(BUZZ_OFF);
|
||||
WriteCommandHT1621(IRQ_DIS);
|
||||
|
||||
HT1621_num_init(); //自动生成液晶屏需要的数组
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 用户显示程序,需要自己完善
|
||||
* @param None
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
void HT1621_Display(void)
|
||||
{
|
||||
|
||||
Write1DataHT1621(0,0x00);
|
||||
Write1DataHT1621(1,0x00);
|
||||
Write1DataHT1621(2,0x00);
|
||||
Write1DataHT1621(3,0x00);
|
||||
Write1DataHT1621(4,0x00);
|
||||
Write1DataHT1621(5,0x00);
|
||||
Write1DataHT1621(6,0x00);
|
||||
Write1DataHT1621(7,0x00);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,10 +42,7 @@ void Write1DataHT1621(unsigned char Addr,unsigned char Dat);
|
||||
void WritenDataHT1621(unsigned char Addr,unsigned char *Databuf,unsigned char Cnt);
|
||||
|
||||
|
||||
void HT1621_num_init(void);
|
||||
void HT1621_Init(void);
|
||||
|
||||
void HT1621_Display(void);
|
||||
|
||||
|
||||
#endif /* HT1621_H_ */
|
||||
|
||||
+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();
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ void my_code();
|
||||
|
||||
struct display_penal
|
||||
{
|
||||
char d_num[4];
|
||||
char button_flag[4];
|
||||
unsigned char d_num[4];
|
||||
unsigned char button_flag[4];
|
||||
char dot1:1;
|
||||
char dot2:1;
|
||||
char dot3:1;
|
||||
|
||||
Reference in New Issue
Block a user