FT800 Programmers Guide의 5.47 CMD_CALIBRATE 항목을 유심히 읽어보자
5.47 CMD_CALIBRATE - execute the touch screen calibration routine
The calibration procedure collects three touches from the touch screen, then computes and loads an appropriate matrix into REG_TOUCH_TRANSFORM_A-F. To use it, create a display list and then use CMD_CALIBRATE. The co-processor engine overlays the touch targets on the current display list, gathers the calibration input and updates REG_TOUCH_TRANSFORM_A-F.
세 점을 터치해서 캘리브레이션 데이터를 REG_TOUCH_TRANSFORM에 저장한다.
cmd_dlstart();
cmd(CLEAR(1,1,1));
cmt_text(80, 30, 27, OPT_CENTER, "Please tap on the dot");
cmd_calibrate();
이렇게 실행해라.
대충 이런 뜻인듯.
터치 보정 후 REG_TOUCH_TRANSFORM_A-F 레지스터의 값을 EEPROM에 저장해 두고 부팅시 저장값을 읽어와서 초기화 해주면 될거 같다.
터치 관련 레지스터나 함 찾아보자.
REG_TOUCH_ADC_MODE
-> The host can set this bit to control the ADC sampling mode of the FT800
0 : Single Ended mode. It causes low power consumption but with less accuracy
1 : Differential Mode. It causes higher power consumption but with more accuracy.
The default mode after reset.
REG_TOUCH_SCREEN_XY
-> Bit[15:0] : Y coordinates of the touch screen. After doing calibration, it shall be within the height of the screen
size. If the touch screen is not being touched, it shall be 0x8000.
-> Bit[31:16] : X coordinates of the touch screen. After doing calibration, it shall be within the height of the screen
size. If the touch screen is not being touched, it shall be 0x8000.
Note : This register is the final computation output of the touch engine of the FT800. It has been mapped into screen size.
REG_TOUCH_RAW_XY
-> Bit[15:0] : raw Y coordinates of the touch screen before going through transformation matrix.
The valid range is from 0 to 1023. If there is no touch on screen, the value shall be 0xFFFF.
-> Bit[31:16] : raw X coordinates of the touch screen before going through transformation matrix.
The valid range is from 0 to 1023. If there is no touch on screen, the value shall be 0xFFFF.
Note : The coordinates in this register have not mapped into the screen coordinates. To get the screen coordinates, please refer to REG_TOUCH_SCREEN_XY.
REG_TOUCH_DIRECT_XY
-> Bit[9:0] : The 10 bit ADC value for Y coordinate.
-> Bit[25:16] : The 10 bit ADC value for X coordinate.
-> Bit[31] :
0 : Touch is being sensed and the two fields above contains the sensed data.
1 : No touch is being sensed and the data in the two fields above shall be ignored.
REG_TOUCH_DIRECT_Z1Z2
-> Bit[9:0] : The 10 bit ADC value for touch screen resistance Z2.
-> Bit[25:16] : The 10 bit ADC value for touch screen resistance Z1.
Note : To know it is touched or not, please check the 31st bit of REG_TOUCH_DIRECT_XT. FT800 touch engine will do the post-processing for these Z1 and Z2 values and update the result in REG_TOUCH_RZ.
REG_ANALOG
REG_TOUCH_RZ
-> Bitp[15:0] : Resistance of touching on the touch screen. The valid value is 0 to 0x7fff.
Highest value(0x7fff) means no touch, Lowest value(0) means maximum pressure.
REG_TOUCH_TRANSFORM_A-F
REG_TOUCH_TAG
-> Bit[7:0] : These bits are set as the tag value of the specific graphics object on the screen which is being touched. These bits are updated once when all the lines of the current frame is scanned out to the screen.
Note : The valid tag value range is from 1 to 255, therefore the default value of this register is zero, meaning there is no touch by default.
REG_TOUCH_TAG_XY
-> Bit[15:0] : Y coordinates of the touch screen, which was used by the touch engine to look up the tag result.
-> Bit[31:16] : X coordinates of the touch screen, which was used by the touch engine to look up the tag result.
Note : Host can read this register to check the coordinates used by the touch engine to update the tag register REG_TOUCH_TAG.
REG_TOUCH_RZTHRESH
-> Bit[15:0] : These bits control the touch screen resistance threshold. Host can adjust the touch screen touching sensitivity by setting this register. The default value after reset is 0xFFFF and it means the lightest touch will be accepted by the touch engine of the FT800. The host can set this register by doing experiments. The typical value is 1200.
REG_TOUCH_OVERSAMPLE
-> Bit[3:0] : These bits control the touch screen oversample factor. The higher value of this register causes more accuracy with more power consumption, but may not be necessary. The valid range is from 1 to 15.
REG_TOUCH_SETTLE
-> Bit[3:0] : These bits control the touch screen settle time, in the unit of 6 clocks. The default value is 3, meaning the settle time is 18(3*6) system clock cycles.
REG_TOUCH_CHARGE
-> Bit[15:0] : These bits control the touch-screen charge time, in the unit of 6 system clocks. The default value after reset is 6000, i.e. the charge time will be 6000*6 clock cycles.
REG_TOUCH_MODE
-> Bit[1:0] : The host can set these two bits to control the touch screen sampling mode of the FT800 touch engine.
00 : off mode. No sampling happens.
01 : Single mode. Cause one single sample to occur.
10 : Frame mode. Cause a sample at the start of each frame.
11 : Continuous mode. Up to 1000 time per seconds. Default mode after reset.
초기화 관련 레지스터들은 초기값으로 가도 될거같다.
터치 처리 과정은 아마도 이렇지 않을까 싶은데...
1, 터치값을 읽어와서 REG_TOUCH_RAW_XY에 저장한다.
2. 보정값을 이용해서 스크린 좌표값으로 변경한 후 REG_TOUCH_SCREEN_XY에 저장한다.
3. 2번 값으로 tag를 찾는다.
설명이 너무 느슨해서 정확한 의미를 알기가 어려운데...실제로 써보면서 확인해보자.
일단은 캘리브레이션부터
일단은 캘리브레이션부터
FT800_DLstart();
FT800_DL(CLEAR_COLOR_RGB(64,64,64));
FT800_DL(CLEAR(1,1,1));
FT800_DL(COLOR_RGB(0xff,0xff,0xff));
FT800_Text((480/2), (272/2), 27, OPT_CENTER, "Please Tap on the dot");
FT800_Calibrate(0);
FT800_Flush_Co_Buffer();
FT800_WaitCmdfifo_empty();
머 이런식이다.
FT800_Track(249, 86, 1, 1, 1);
FT800_Flush_Co_Buffer();
FT800_WaitCmdfifo_empty();
FT800_DLstart();
FT800_DL(CLEAR_COLOR_RGB(0,0,0));
FT800_DL(CLEAR(1,1,1));
FT800_DL(TAG(1));
FT800_Dial(249, 86, 55, 0, 0x8000);
FT800_DL(DISPLAY());
FT800_Swap();
FT800_Flush_Co_Buffer();
FT800_WaitCmdfifo_empty();
while(1){
TR_Val = ft800memRead32(REG_TRACKER);
if((TR_Val & 0xff) == 1)
color = TR_Val >> 16;
do{
cmdBufferRd = ft800memRead16(REG_CMD_READ);
cmdBufferWr = ft800memRead16(REG_CMD_WRITE);
printf("%x, %x\r\n", cmdBufferRd, cmdBufferWr);
}while(cmdBufferWr != cmdBufferRd);
FT800_DLstart();
FT800_DL(CLEAR_COLOR_RGB(0,0,0));
FT800_DL(CLEAR(1,1,1));
FT800_DL(TAG(1));
FT800_Dial(249, 86, 55, 0, color);
FT800_DL(DISPLAY());
FT800_Swap();
FT800_Flush_Co_Buffer();
FT800_WaitCmdfifo_empty();
되긴 되네.
댓글 없음:
댓글 쓰기