Connecting a Color lcd (MI0283QT-2) to the raspberry pi.

I started to look at the SPI interface of the raspberry pi for only one purpose, to be able to to use it as a control panel for some hacking project.
I had a LCD Screen laying around that I bought at watterrott so I decided to connect it to my raspberry pi.

MI0283QT-2

The MI0283QT-2 module is a nice 2.8” Color LCD with a resolution of 320×240 controlled by a hx8347 controller and a touchscreen based on the ADS7846 controller.
Since the spi interface is 3.3 – 5 V tolerant, it is directly compatible with the raspberry pi, cool.

Connection to the raspberry-pi

C++ Library

The guy from watteroot is providing an ardurino library for controlling the LCD. I decided to start from it to quicly have some working code.
In fact, it was not so easy to implemented since I have barly no experience in C/C++ and the spidev was a huge mystery at that time.
Hopefully, I managed to make it working, and here is the result of my work. The code is available from github.
At this time only the LCD library is implemented, I will work on the touch screen library as soon as this come as a priority to me
As usual feel free to check the code, and use as you wish. You will quickly see it is really a quick port.

Tips :

  • You need a kernel with a SPI library. I only tested on Chris boot kernel
  • For performance reason, some functions are sending quite big SPI command. Make sure to load the spidev with a buffer big enough.
    modprobe spidev bufsiz=256000
    

Finding that I need that parameter was not easy, the only symptom was that all screen was not clearing. After couple of hours I noticed that only function which was sending less that 4096 bytes were working.

The library does not directly support to set the led light level. However if you connect the led pin to the GPIO18 you can control it using the WiringPI gpio tools.

gpio -g mode 18 pwm
gpio -g pwm 18 100
gpio -g pwm 18 300
gpio -g pwm 18 500
gpio -g pwm 18 1000

Building instructions

git clone https://github.com/dgallot/MI0283QT2-pi
cd MI0283QT2-pi/demo
gcc -lstdc++ -iquote ../MI0283QT2 BMPDemo.cpp ../MI0283QT2/MI0283QT2.cpp ../MI0283QT2/font*.c -o BMPDemo
gcc -lstdc++ -iquote ../MI0283QT2 demo1.cpp  ../MI0283QT2/MI0283QT2.cpp ../MI0283QT2/font*.c -o demo1
gcc -lstdc++ -iquote ../MI0283QT2 gameoflife.cpp  ../MI0283QT2/MI0283QT2.cpp ../MI0283QT2/font*.c -o gameoflife

In actions

Wirings

Demo of the lib functionalities

Game of life

What next

For the moment I am trying to implements a framebufffer driver for this device. This will allows any king of gui application to work on this lcd, including the console at the boot time.
The current status is that I am able to clear the sceen. I have to admit that it is not easy task, mainly because I am lacking of C experiences, linux kernel development experiences and I do not know the kernel SPI interfaces at well. But that really challanging job.


Edit 15 March 2013
The information in this blog entry is rather oudated.
Here some informations about using a framebuffer based on my code, with support for the touch screen. MI0283QT2-pi Github project of Dronus
The model of LCD sold by Watteroot changed, and it is not compatible anymore with this code.
On the lallafa blog, you can find the appropirate frame buffer for this new LCD Watterott MI0283QT-9A Display for the Rasbperry Pi.
You can also find a true framebuffer for the old version of LCD on the same blog Watterott Display on Raspberry Pi

12 Responses to “Connecting a Color lcd (MI0283QT-2) to the raspberry pi.”


  1. 142loop

    there is a driver for the ads7846 in the kernel source,
    eg https://github.com/raspberrypi/linux/blob/rpi-patches/drivers/input/touchscreen/ads7846.c
    don’t know how to make this work though

    grtx

  2. 2vis

    I’ve made a “userspace” framebuffer driver based on your code. It runs X well, a little slow but quite usable.

    I first tried making a real framebuffer driver, but dropped that for some reasons:
    1) It would not support the internal graphics, eg. no mirroring on HDMI, no GPU accelerated OpenGL, no hardware video codecs.
    2) If done simple, it would run synchronous with the draw calls, thus stalling large amounts of small draw operations by the slow SPI transfers.

    The driver is now made as a normal userspace process, that scans the original ARM framebuffer for changes and transmits them to the SPI attached display. It takes about 10-15% CPU idling though if no pixels changed.

    Get the source here: https://snr.freifunk.net/trac/vis/browser/raspberrypi/fb.cpp it compiles with same settings as the original demo sources. The program must be run with sudo.

    X must be run at 320×200 resolution to make it work. This can be done by putting https://snr.freifunk.net/trac/vis/browser/raspberrypi/10-monitors.conf into /usr/share/X11/xorg.conf.d . The LCD’s native resolution 320×240 is rejected by X, I’m into that.

  3. 3vis

    I made a fork of your library with the userspace framebuffer driver. See it here: https://github.com/dronus/MI0283QT2-pi . I added some helper scripts to make, start and stop the driver. Also, the 320×200 resolution limit is no longer a problem, X runs the native 320×240 now, I think this was solved by raspian or firmware fixes. The main issue is the very low screen space now. X chooses unreadable small fonts by default (~3px height), which must be changed in the settings dialogues while those are almost unreadable.. Also we need new icon sets, as the default ones are horrible large on this display.

  4. 4afx

    Hi! This is awesome! Now, i am waiting on my LCD module (a bit different type), if it arrives, im going to try out these things! Can, i ask for current status, did you managed to use the touch function too? Many thanks!

  5. 5Albertone74

    Hi there,

    Today I have received the touchsreen MI0283QT-9A and I am very excited abou it.

    I would appreciate if someone could help me out with this technical issue. I am not too sure how to connect the display adaptor to my my Raspberry PI with the wires.

    Shall I follow the connections as shown in this website here:

    http://lallafa.de/blog/2013/03/watterot … pberry-pi/

    and if so, would you please be so kind as to explain to me the meaning of the following connections:

    Name Raspi Display Board
    +5V 2+4 3+4
    GND 6 1+2

    Does that mean that for example I have to connect the pin 2 (Raspi) with the pin 3 (Display board) and pin 4 (Raspi) with the pin 4 (Display board) ? And in the second example the pin 6 (Raspi) with a ‘combined’ wire connected to the pin 1 and 2 (Display board)?

    or shall I use the connections shown here in this blog?

    which they would appear to be quite different.

    Many thanks in advance for your kind help!!!

  6. 6Dominique Gallot

    @Albertone74
    You need to just follow the image, which show the wire to be connected.
    The same connection can be used with the lallafa blog, but you need to check that he use the same spi id to connect the display ( CS LCD and CS TS ).

  7. 7Tobias Göbel

    Hi,

    thanks for the Library… I got a similar Display with the same Controller.. In a quick shot i tried the Libraray and got a picture (mirrored but, hey ^^) i allready fixed the mirrored picture, but got problems with clearing the screen.. it just doesn’t clear the screen.. any chance someone can halp me with that?

  8. 8kilhian

    Hi

    I have a MI0283QT9A, a RPI ver.B and soon a BeagleBone Black…both on debian.

    Does your C++ library works withb this LCD? and on a a BeagleBoneBlack?

    I don’t use Xserver…
    How do I draw label? button? touch trigger?

    Thanks

    Kilhian

  9. 9Dominique Gallot

    I do not really know who a BeagleBone works.
    But if it has the proper driver for spi-dev and linux based it should works.

    Try first to compile and see how it works.

  10. 10Dominique Gallot

    I do not have a library out of the box which is allows to have button touch lib and so on on the rpi.
    For a button lib I use TouchGui which works on adrurino, should be easy to port to c++ on linux.

    http://code.google.com/p/arduino-touch-gui/

  1. [...] Colour LCD to Raspberry PI [Link] [...]

  2. [...] * * * * /etc/lcd/screen -iEnregistrez, fermez et hop ! Tuto terminé A voir aussiLa même chose, avec un écran couleur et tactile de 36€ pour ceux qui ont les moyens Encore la même chose, avec un écran moins cher (mais du coup de [...]

Leave a Reply