Sang Vu Van
/
New
mesh phone
touch.h@0:c674504a6536, 2012-07-02 (annotated)
- Committer:
- SangSTBK
- Date:
- Mon Jul 02 03:41:36 2012 +0000
- Revision:
- 0:c674504a6536
mesh
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SangSTBK | 0:c674504a6536 | 1 | char ft_read(unsigned char address) |
SangSTBK | 0:c674504a6536 | 2 | { |
SangSTBK | 0:c674504a6536 | 3 | |
SangSTBK | 0:c674504a6536 | 4 | char tem; |
SangSTBK | 0:c674504a6536 | 5 | i2c.start(); |
SangSTBK | 0:c674504a6536 | 6 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 7 | i2c.write(0x70); |
SangSTBK | 0:c674504a6536 | 8 | i2c.write(address); |
SangSTBK | 0:c674504a6536 | 9 | i2c.stop(); |
SangSTBK | 0:c674504a6536 | 10 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 11 | i2c.start(); |
SangSTBK | 0:c674504a6536 | 12 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 13 | i2c.write(0x71); |
SangSTBK | 0:c674504a6536 | 14 | tem = i2c.read(1); |
SangSTBK | 0:c674504a6536 | 15 | i2c.stop(); |
SangSTBK | 0:c674504a6536 | 16 | return tem; |
SangSTBK | 0:c674504a6536 | 17 | } |
SangSTBK | 0:c674504a6536 | 18 | void ft_read_data() |
SangSTBK | 0:c674504a6536 | 19 | { |
SangSTBK | 0:c674504a6536 | 20 | |
SangSTBK | 0:c674504a6536 | 21 | char tem, i; |
SangSTBK | 0:c674504a6536 | 22 | i2c.start(); |
SangSTBK | 0:c674504a6536 | 23 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 24 | i2c.write(0x70); |
SangSTBK | 0:c674504a6536 | 25 | i2c.write(0); |
SangSTBK | 0:c674504a6536 | 26 | i2c.stop(); |
SangSTBK | 0:c674504a6536 | 27 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 28 | i2c.start(); |
SangSTBK | 0:c674504a6536 | 29 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 30 | i2c.write(0x71); |
SangSTBK | 0:c674504a6536 | 31 | for(i = 0; i < 0x1f; i ++) |
SangSTBK | 0:c674504a6536 | 32 | buffer[i] = i2c.read(1); |
SangSTBK | 0:c674504a6536 | 33 | i2c.stop(); |
SangSTBK | 0:c674504a6536 | 34 | |
SangSTBK | 0:c674504a6536 | 35 | } |
SangSTBK | 0:c674504a6536 | 36 | int ft_write(unsigned char address, char data) |
SangSTBK | 0:c674504a6536 | 37 | { |
SangSTBK | 0:c674504a6536 | 38 | i2c.start(); |
SangSTBK | 0:c674504a6536 | 39 | wait_ms(1); |
SangSTBK | 0:c674504a6536 | 40 | i2c.write(0x70); |
SangSTBK | 0:c674504a6536 | 41 | i2c.write(address); |
SangSTBK | 0:c674504a6536 | 42 | i2c.write(data); |
SangSTBK | 0:c674504a6536 | 43 | i2c.stop(); |
SangSTBK | 0:c674504a6536 | 44 | } |
SangSTBK | 0:c674504a6536 | 45 | void init_nomal_mode() |
SangSTBK | 0:c674504a6536 | 46 | { |
SangSTBK | 0:c674504a6536 | 47 | ft_write(0,0); |
SangSTBK | 0:c674504a6536 | 48 | } |
SangSTBK | 0:c674504a6536 | 49 | void read_touch_possition() |
SangSTBK | 0:c674504a6536 | 50 | { |
SangSTBK | 0:c674504a6536 | 51 | ft_read_data(); |
SangSTBK | 0:c674504a6536 | 52 | touch_x = (buffer[3]&0x0f)*256 + buffer[4]; |
SangSTBK | 0:c674504a6536 | 53 | touch_y = (buffer[5]&0x0f)*256 + buffer[6]; |
SangSTBK | 0:c674504a6536 | 54 | } |