Sang Vu Van
/
New
mesh phone
Diff: touch.h
- Revision:
- 0:c674504a6536
diff -r 000000000000 -r c674504a6536 touch.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/touch.h Mon Jul 02 03:41:36 2012 +0000 @@ -0,0 +1,54 @@ +char ft_read(unsigned char address) +{ + + char tem; + i2c.start(); + wait_ms(1); + i2c.write(0x70); + i2c.write(address); + i2c.stop(); + wait_ms(1); + i2c.start(); + wait_ms(1); + i2c.write(0x71); + tem = i2c.read(1); + i2c.stop(); + return tem; +} +void ft_read_data() +{ + + char tem, i; + i2c.start(); + wait_ms(1); + i2c.write(0x70); + i2c.write(0); + i2c.stop(); + wait_ms(1); + i2c.start(); + wait_ms(1); + i2c.write(0x71); + for(i = 0; i < 0x1f; i ++) + buffer[i] = i2c.read(1); + i2c.stop(); + +} +int ft_write(unsigned char address, char data) +{ + i2c.start(); + wait_ms(1); + i2c.write(0x70); + i2c.write(address); + i2c.write(data); + i2c.stop(); +} +void init_nomal_mode() +{ + ft_write(0,0); +} +void read_touch_possition() +{ + ft_read_data(); + touch_x = (buffer[3]&0x0f)*256 + buffer[4]; + touch_y = (buffer[5]&0x0f)*256 + buffer[6]; +} \ No newline at end of file