Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions 7inch.patch

This file was deleted.

65 changes: 15 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,38 @@
Update about new device
Updated
=======================
I heared that waveshare developed a new version of the touchscreen which uses standard HID protocol. By using this new version, we don't need driver any more. The HID protocol can be used in linux, windows 10 IoT and even desktop (I didn't try)

If you want to upgrade your device, please send it back and let them upgrade for you.

I will stop develop this driver and keep the functionality the same.

Support this driver
===================
Support me by [registering a DigitalOcean account](https://m.do.co/c/4bc532e3ef94), you will get a $10 credict for free.
Original driver and README at: https://github.com/derekhe/waveshare-7inch-touchscreen-driver.git

WaveShare 7-inch user space driver
===================================
I brought a [WaveShare 7-inch HDMI LCD](http://www.waveshare.net/shop/7inch-HDMI-LCD-B.htm) and it provides a USB touchscreen.
OP brought a [WaveShare 7-inch HDMI LCD](http://www.waveshare.net/shop/7inch-HDMI-LCD-B.htm) and it provides a USB touchscreen.
But the company only provide binary driver and images, which is quite bad. Installing binary driver will break self compiled kernel, and you can't get updated kernels.
I asked the company to provide the source code but they refused. They said they won't provide any source code because other companies can copy very fast so that their products can't sell out at good price.

OK. If they company won't want to provide anything, that's fine. I finally find out we can still drive the touchscreen by writing a user space driver.
OP asked the company to provide the source code but they refused. They said they won't provide any source code because other companies can copy very fast so that their products can't sell out at good price.

Tested using official image: 2015-05-05-raspbian-wheezy.img
OK. If they company won't want to provide anything, that's fine. OP finally find out we can still drive the touchscreen by writing a user space driver.

**NOTE: I do not guarantee this driver will work on other system/other displays. If you have trouble, or make it work on other system/displays, please make a pull request, I'll help to merge it into master branch.**

**If any help needed, do not send an email to me directly, please raise an issue so that your question can be solved quicker.**

This is what my hack does.
This is what OP's hack does.
- Make 7-inch display working.
- Make touch panel working.

# Install (Thanks Kaz Fukuoka to fix this guide)
# Install
ssh into your raspiberry

```
git clone https://github.com/derekhe/waveshare-7inch-touchscreen-driver
git clone https://github.com/akhepcat/waveshare-7inch-touchscreen-driver
cd waveshare-7inch-touchscreen-driver
chmod +x install.sh
sudo apt-get update
sudo ./install.sh
sudo restart
```

# How do I hack it
# How did OP hack it
By looking at the dmesg information, we can see it is installed as a hid-generic driver, the vendor is 0x0eef(eGalaxy) and product is 0x0005.
0x0005 can't be found anywhere, I think the company wrote their own driver to support this.
0x0005 can't be found anywhere, OP thinks the company wrote their own driver to support this.

## dmesg infomation
```
Expand All @@ -60,9 +50,10 @@ kernel config provide us more clue:
CONFIG_USB_EGALAX_YZH=y
```

It is really a eGalaxy based device. Google this config but found nothing. I don't have a eGalxy to compare, maybe waveshare's touchscreen is only modifed the product id.
It is really a eGalaxy based device. Google this config but found nothing.
OP doesn't have a eGalxy to compare, maybe waveshare's touchscreen is only modifed the product id.

Then I look at the response of hidraw driver:
Then OP looked at the response of hidraw driver:

## hidraw driver analysis
```
Expand All @@ -81,35 +72,9 @@ Take one for example:
"bb" is start of multi-touch, and the following bytes are the position of each point.

## Write the driver
I use python to read from hidraw driver and then use uinput to emulate the mouse. It is quite easy to do. Please look at the source code.
OP used python to read from hidraw driver and then use uinput to emulate the mouse. It is quite easy to do. Please look at the source code.

## Other systems
I think this driver can work in any linux system with hidraw and uinput driver support.

## Other displays
I received an email from Adam, this driver may work with another type of screen:

> Hi there. Wanted to say thank you for writing and sharing the user space driver for 7" USB touchscreen, you have saved me!

> Mine is branded Eleduino (see here for details: http://www.eleduino.com/5-Inch-HDMI-Input-Touch-Screen-for-Raspberry-PI-2-B-B-and-Banana-pro-pi-p10440.html) and I had exactly the same issue - closed source binary driver which simply replaced kernel modules.

> Your solution worked out of the box, and didn't even need calibration.

> You're a hero!

# Another option

I found another guy wrote a C++ driver for this. Please refer to https://github.com/110yd/wshare-touchscreen.

# Pro version features (STOP DEVELOPMENT)
Please try this driver and if you need to support more, please [contact me](derekhe@april1985.com) to get the paid pro version.

1 More options:
- Set right click duration
OP thinks this driver can work in any linux system with hidraw and uinput driver support.

2 Calibration:
- On screen calibration

3 Multitouch:
- Two fingures touch to simulate right click
- Three fingures to scrool
6 changes: 2 additions & 4 deletions install.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ check_ver_lte() {


chmod +x *.sh *.py
sudo patch -b /boot/config.txt 7inch.patch
sudo ./update_boot_config
sudo apt-get install -y python3-pip libudev-dev
sudo pip-3.2 install python-uinput pyudev
#if pip-3.2 can't be found, please use pip3
#sudo pip3 install python-uinput pyudev
sudo pip3 install python-uinput pyudev

PYTHON_VERSION=`python3 -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'`
if check_ver_lte "3.4" $PYTHON_VERSION; then
Expand Down
2 changes: 1 addition & 1 deletion touch_async.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def check_device(thedevice):
with open(thedevice.device_node, 'rb') as f:
print("Opening device and initiating mouse emulation.")
tasks.clear()
tasks.append(asyncio.async(read_and_emulate_mouse(f)))
tasks.append(asyncio.ensure_future(read_and_emulate_mouse(f)))
loop.run_until_complete(asyncio.wait(tasks))
print("Device async task terminated.")

Expand Down
21 changes: 21 additions & 0 deletions update_boot_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
CONFIG=/boot/config.txt

# Adjusts or adds the required changes based on existing config.txt

# you can add or change, just make sure to keep things aligned correctly between the arrays
CONF=( hdmi_force_hotplug hdmi_group hdmi_mode max_usb_current hdmi_cvt )
VAL=( 1 2 87 1 "800 480 60 6 0 0 0" )

for (( i=0; i<${#CONF[@]}; i++ ))
do
lines=$(grep -i "${CONF[$i]}" ${CONFIG} | grep -vE '\s*?#' | wc -l)
if [ ${lines:-0} -gt 0 ]
then
#adjust the existing line
sed -i "s/^\s*${CONF[$i]}.*/${CONF[$i]} = ${VAL[$i]}/" ${CONFIG}
else
#add a line at the end
echo "${CONF[$i]} = ${VAL[$i]}" >> ${CONFIG}
fi
done