| Marc Singer | 51cb21a | 2006-05-16 11:41:43 +0100 | [diff] [blame] | 1 | README on the ADC/Touchscreen Controller | 
|  | 2 | ======================================== | 
|  | 3 |  | 
|  | 4 | The LH79524 and LH7A404 include a built-in Analog to Digital | 
|  | 5 | controller (ADC) that is used to process input from a touchscreen. | 
|  | 6 | The driver only implements a four-wire touch panel protocol. | 
|  | 7 |  | 
|  | 8 | The touchscreen driver is maintenance free except for the pen-down or | 
|  | 9 | touch threshold.  Some resistive displays and board combinations may | 
|  | 10 | require tuning of this threshold.  The driver exposes some of it's | 
|  | 11 | internal state in the sys filesystem.  If the kernel is configured | 
|  | 12 | with it, CONFIG_SYSFS, and sysfs is mounted at /sys, there will be a | 
|  | 13 | directory | 
|  | 14 |  | 
|  | 15 | /sys/devices/platform/adc-lh7.0 | 
|  | 16 |  | 
|  | 17 | containing these files. | 
|  | 18 |  | 
|  | 19 | -r--r--r--    1 root     root         4096 Jan  1 00:00 samples | 
|  | 20 | -rw-r--r--    1 root     root         4096 Jan  1 00:00 threshold | 
|  | 21 | -r--r--r--    1 root     root         4096 Jan  1 00:00 threshold_range | 
|  | 22 |  | 
|  | 23 | The threshold is the current touch threshold.  It defaults to 750 on | 
|  | 24 | most targets. | 
|  | 25 |  | 
|  | 26 | # cat threshold | 
|  | 27 | 750 | 
|  | 28 |  | 
|  | 29 | The threshold_range contains the range of valid values for the | 
|  | 30 | threshold.  Values outside of this range will be silently ignored. | 
|  | 31 |  | 
|  | 32 | # cat threshold_range | 
|  | 33 | 0 1023 | 
|  | 34 |  | 
|  | 35 | To change the threshold, write a value to the threshold file. | 
|  | 36 |  | 
|  | 37 | # echo 500 > threshold | 
|  | 38 | # cat threshold | 
|  | 39 | 500 | 
|  | 40 |  | 
|  | 41 | The samples file contains the most recently sampled values from the | 
|  | 42 | ADC.  There are 12.  Below are typical of the last sampled values when | 
|  | 43 | the pen has been released.  The first two and last two samples are for | 
|  | 44 | detecting whether or not the pen is down.  The third through sixth are | 
|  | 45 | X coordinate samples.  The seventh through tenth are Y coordinate | 
|  | 46 | samples. | 
|  | 47 |  | 
|  | 48 | # cat samples | 
|  | 49 | 1023 1023 0 0 0 0 530 529 530 529 1023 1023 | 
|  | 50 |  | 
|  | 51 | To determine a reasonable threshold, press on the touch panel with an | 
|  | 52 | appropriate stylus and read the values from samples. | 
|  | 53 |  | 
|  | 54 | # cat samples | 
|  | 55 | 1023 676 92 103 101 102 855 919 922 922 1023 679 | 
|  | 56 |  | 
|  | 57 | The first and eleventh samples are discarded.  Thus, the important | 
|  | 58 | values are the second and twelfth which are used to determine if the | 
|  | 59 | pen is down.  When both are below the threshold, the driver registers | 
|  | 60 | that the pen is down.  When either is above the threshold, it | 
|  | 61 | registers then pen is up. |