3 July 2013 (updated 1 Oct 2013)
These are notes from my experience in interfacing the HY28A-LCDB on the Raspberry Pi. Most of the work was done for me, thanks to user notro on the Raspberry Pi forum. His software and documentation can be found at https://github.com/notro/fbtft/wiki and I will just reference it rather than repeat it here. I intend to write applications for the display using tslib (the touchscreen access library) and SDL (Simple Directmedia Layer library), so I'll include their installation, configuration, and use in these instructions.
Here are the steps I followed (to the best of my recollection)
1. Wired the HY28A to the RPi using notro's instructions (https://github.com/notro/fbtft/wiki/LCD-Modules#hy28a)
2. Installed the latest (at the time of this writing) RPi firmware with notro's FBTFT support (2013-05-25-wheezy-raspbian-2013-06-14-fbtft.zip) onto an SD card.
NOTE: This procedure has changed so that you can use the latest Raspbian release and rpi-update. See https://github.com/notro/fbtft/wiki#install (1 Oct 2013)
4. Put the SD card in the RPi and booted it. From this point on, I am accessing the RPi from SSH, which is enabled by default. Perform whatever configurations you want under "raspi-config" before continuing. To my knowledge, there is nothing special that needs to be configured for the following instructions to work.
NOTE: If you don't access the RPi with SSH, be aware that, at this writing, there is an issue with this firmware of keys repeating when a USB keyboard is plugged into the RPi.
3. Registered the display and touchpanel for a "Normal" configuration (https://github.com/notro/fbtft/wiki/Touchpanel). In essence, I typed these commands:
modprobe fbtft_device name=hy28a rotate=0 # Note that the device name used to be hy28afb (1 Oct 2013) # modprobe hy28afb <-- It appears that this command isn't used anymore (1 Oct 2013) modprobe ads7846_device pressure_max=255 y_min=190 y_max=3850 gpio_pendown=17 x_max=3850 x_min=230 x_plate_ohms=60 modprobe ads7846
See this page for instructions to make this permanent (https://github.com/notro/fbtft/wiki#step-by-step-using-fbtft).
4. Installed xinput and evtest
sudo apt-get -y install xinput evtest
5. Added this display's framebuffer settings to the end of /etc/fb.modes. In my case, the framebuffer device is /dev/fb1. Yours may differ.
sudo fbset -fb /dev/fb1 >> /etc/fb.modes
6. Installed tslib binaries
sudo apt-get install libts-bin
7. Ran ts_test and ts_calibrate as described in https://github.com/notro/fbtft/wiki/Touchpanel. To do this, you need to know the framebuffer device (which you should know from step 5) and the touchscreen device, which you can find out by typing:
evtest
You will see something similar to this:
No device specified, trying to scan all of /dev/input/event* Not running as root, no devices may be available. Available devices: /dev/input/event0: ADS7846 Touchscreen /dev/input/event1: SILITEK USB Keyboard Select the device event number [0-1]:
So, in my case, the touchscreen device is /dev/input/event0
NOTE: It's necessary to run ts_calibrate at least once.
8. Installed tslib development library and headers. This is needed for installing SDL with tslib support.
sudo apt-get install libts-dev
9. Download the SDL 1.2 source tarball from http://www.libsdl.org/download-1.2.php. At the time, it was http://www.libsdl.org/release/SDL-1.2.15.tar.gz
NOTE: The current version of SDL that comes with Raspbian is 1.2.15, but SDL 2.0 is now the latest release. These instructions will be updated when SDL is updated to 2.0 (1 Oct 2013)
10. After gunzipping and untarring it, change into the resulting directory and type:
./configure --enable-input-tslib
then
make
then
sudo make install
11. Wrote a C++ program using SDL. I visited http://www.sdltutorials.com/ and built up the code in "SDL Tutorial Basics" and "SDL Coordinates and Bliting." That was enough to prove that I could display a bitmap and move the mouse cursor around.
These environment variables need to be set either by exporting them or (as I did) calling putenv() in the main program:
TSLIB_TSDEVICE=/dev/input/event0
TSLIB_TSEVENTTYPE=INPUT
TSLIB_CONFFILE=/etc/ts.conf
TSLIB_CALIBFILE=/etc/pointercal
SDL_FBDEV=/dev/fb1
SDL_MOUSEDRV=TSLIB
SDL_MOUSEDEV=/dev/input/event0
SDL_NOMOUSE=1
SDL_VIDEODRIVER=FBCON
12. I needed SDL_ttf for my application, so I installed it and its development package (make sure it's the version that works with SDL 1.2).
sudo apt-get install libsdl-ttf2.0.0 libsdl-ttf2.0-dev