In this project, I’m making a Tablet PC with a Raspberry Pi with Raspbian and a LCD Touchscreen display. I bought a LCD Touchscreen from chalkboard electronics.
Before designing the tablet, I had to set up the touchscreen. The biggest problem that I had was the power output of Raspberry Pi’s USB was smaller than the power needed from the touchscreen. These are the steps that I went through.
- Change power source of the touchscreenAt first, I changed power source of the touchscreen, because I wanted my tablet to have one power source(battery). Therefore I have to use a battery for the Raspberry Pi, and power the touchscreen through Raspberry Pi’s USB. To change the power source, you can look up this link.
You need to de-solder and solder to change the power source of this Touchscreen. So if you don’t have soldering tool, then I recommend you to use different product.
- Lower the brightness of the touchscreen
I said, Raspberry Pi’s USB output current is <500mA. And the Touchscreen’s default current is 1.2A. I can lower the consuming current of the touchscreen by decreasing brightness of touchscreen’s backlight. If you see their webpage, they provide method to decrease back-light brightness(link). But if you have problem with that method, there is another option. Actually, I had problem with using HIDAPI, which they recommended. So I used different method.Basically what they are doing is sending hex code to HID device. You can do same thing with Pyusb with python.
This is simple python script that I used.
import usb.core import sys dev = usb.core.find(idVendor=0x04d8,idProduct=0xf724) # was it found? if dev is None: sys.exit("Device Not Found") #raise ValueError('Device not found') # set the active configuration. With no arguments, the first # configuration will be the active one dev.set_configuration() # get an endpoint instance cfg = dev.get_active_configuration() intf = cfg[(0,0)] out_ep = usb.util.find_descriptor( intf, # match the first OUT endpoint custom_match = \ lambda e: \ usb.util.endpoint_direction(e.bEndpointAddress) == \ usb.util.ENDPOINT_OUT) in_ep = usb.util.find_descriptor( intf, # match the first OUT endpoint custom_match = \ lambda e: \ usb.util.endpoint_direction(e.bEndpointAddress) == \ usb.util.ENDPOINT_IN) assert out_ep is not None assert in_ep is not None # write the data data = '\x00\x20\x0A ' #Report ID(0), Command, Backlight value out_ep.write(data) ret = in_ep.read(in_ep.wMaxPacketSize)
This code sets the brightness of backlight to 10. More detail protocol is in the webpage.
- Change setting of the Raspberry PiEven though you go through previous steps, you can’t use touchscreen. If you plug HDMI and USB cable and power the Raspberry Pi, nothing shows up in the display. Still, you can see the backlight is on. When you power the touchscreen at the booting time, it works fine.
I spent a lot of time to solve this issue. I couldn’t find out exact reason for this issue. But I guess Raspberry Pi’s USB turns on little late, so touchscreen can’t be turned on the booting time. As a result, Raspberry Pi can’t recognize the touchscreen.So I change HDIM configuration. You can change HDMI settings in ‘/boot/config.txt’. I added below options in the file.
hdmi_force_hotplug=1 #Use HDMI mode even if no HDMI monitor is detected hdmi_group=1 #Depends on the display's resolution hdmi_mode=39 #Depends on the display's resolution
This options forces the Raspberry Pi to use HDMI with specific resolution. If you don’t set the resolution(hdmi_group, hdmi_mode), then the display output breaks. More detail explanation of config.txt is in this link.
So finally I powered the touchscreen with the Raspberry Pi.
In the video, you can see that the screen is unstable. I think that is due to unstable USB power during booting.