加入eeprom驱动,用于保存屏幕触控的校准数据
This commit is contained in:
+14
-1
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "touch.h"
|
||||
#include "LCD.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
//默认为touchtype=0的数据.
|
||||
#define CMD_RDX 0X90
|
||||
#define CMD_RDY 0XD0
|
||||
@@ -149,6 +151,13 @@ void TP_DrwaTrage(int x,int y,int r)
|
||||
|
||||
void TP_adjustment()
|
||||
{
|
||||
//判断是否需要校准,从eeprom获取数据
|
||||
EEPROM_READ_BATY(16,(char *)&tconfig,sizeof(touch_config));
|
||||
if(tconfig.begin==0xab&&tconfig.end==0xcd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char str[64];
|
||||
uint16_t y_adc,x_adc,step=0,r=10;
|
||||
uint16_t y1,y2,y3,y4,x1,x2,x3,x4;
|
||||
@@ -286,13 +295,17 @@ void TP_adjustment()
|
||||
tconfig.y_acc=acc_y;
|
||||
tconfig.y_offset=offset_y;
|
||||
|
||||
tconfig.begin=0xab;
|
||||
tconfig.end=0xcd;
|
||||
|
||||
|
||||
sprintf(str,"x_acc=%f y_acc=%f",acc_x,acc_y);
|
||||
LCD_ShowString(0,66+16+16+16+16,str,16,RED,RED);
|
||||
sprintf(str,"x_offset=%d y_offset=%d",offset_x,offset_y);
|
||||
LCD_ShowString(0,66+16+16+16+16+16,str,16,RED,RED);
|
||||
|
||||
}
|
||||
|
||||
EEPROM_WRITE_BATY(16,(char *)&tconfig,sizeof(touch_config));
|
||||
HAL_Delay(1000);
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user