MI0283QT-2, RPi ShieldBridge & Linux Device Trees

Guide to installing old lcd display on a RPi Model (A) 2011 running the latest 4.x Raspbian

assume your logged in with root permissions
Watterott MI0283QT-2 Rev 1.0 lcd display with touch screen RPi ShieldBridge Rev 1.1
Upgrade to the latest linux kernel version with DT support
apt-get update && apt-get upgrade

Check the modules are available :-

modprobe -c | grep -e spi_bcm  -e ads7846 -e fb_hx8347d -e fbtft
...
alias platform:bcm2708_spi spi_bcm2708
alias platform:fb_hx8347d fb_hx8347d
...
alias spi:ads7846 ads7846
alias spi:fb_hx8347d fb_hx8347d
...
alias symbol:fbtft_dbg_hex fbtft
alias symbol:fbtft_framebuffer_alloc fbtft
...

Check the fbtft_device will load the MI0283QT-2 driver :-

modprobe fbtft_device name=list; dmesg
...
[15006.905292] fbtft_device:  SPI devices registered:
[15006.905376] fbtft_device:      ads7846 spi0.1 2000kHz 8 bits mode=0x00
[15006.905399] fbtft_device:  'fb' Platform devices registered:
[15006.905459] fbtft_device:      soc:fb id=-1 pdata? no
[15006.905534] fbtft_device:  Supported displays:
[15006.905549] fbtft_device:      adafruit18
[15006.905616] fbtft_device:      agm1264k-fl
[15006.905626] fbtft_device:      dogs102
...
[15006.905727] fbtft_device:      itdb24
[15006.905759] fbtft_device:      mi0283qt-2
[15006.905769] fbtft_device:      mi0283qt-9a
[15006.905780] fbtft_device:      mi0283qt-v2
...

Update config.txt to load the required spi and touch screen overlay

nano /boot/config.txt
dtparam=spi=on
dtoverlay=ads7846,cs=1,speed=2000000,penirq=25,swapxy=1,xmin=250,xmax=3780,ymin=160,ymax=3930,pmax=255,xohms=60

Update cmdline to map the default console onto the display

Note: linux kernel command line is limited to 1024 characters.
nano /boot/cmdline
.... elevator=deadline rootwait consoleblank=0 fbcon=map:10

Update modules to load the fbtft_device driver

nano /etc/modules
fbtft_device name=mi0283qt-2 cs=0 gpios=reset:23,led:24 speed=20000000

Modify the RPi ShieldBridge

Solder bridge JIRQ IO7, IO8, IO23, IO24 & IO25 usage

Troubleshooting

Manually loading the lcd module

modprobe fbtft_device name=mi0283qt-2 cs=0 gpios=reset:23,led:24 speed=20000000 debug=3

lsmod

Module                  Size  Used by
fbtft_device           35066  0 
fb_hx8347d              4747  2 
fbtft                  34291  2 fb_hx8347d,fbtft_device
fb_sys_fops             1573  1 fbtft
syscopyarea             3113  1 fbtft
sysfillrect             3592  1 fbtft
sysimgblt               2286  1 fbtft

ls /dev/fb*

/dev/fb0  /dev/fb1


Testing the lcd module

dd if=/dev/zero bs=512 count=300 | tr "\000" "\377" > /dev/fb1
Set the screen white

dd if=/dev/zero bs=512 count=300 | tr "\000" "\150" > /dev/fb1
Set the screen purple

dd if=/dev/fb1 of=raw.bmp
Note : the display is written RGB565 (16bit) per pixel = 153600 bytes (320x240x2)
You can then import/export using the GIMP raw bmp format:-

Manually loading the touch screen

modprobe ads7846 cs=1 speed=2000000 penirq=25 swapxy=1 xmin=250 xmax=3780 ymin=160 ymax=3930 pmax=255 xohms=60
lsmod

Module                  Size  Used by
ads7846                12520  0 
hwmon                   4420  1 ads7846

ls /dev/input/*
/dev/input/event0  /dev/input/mice  /dev/input/mouse0

/dev/input/by-path:
platform-20204000.spi-event

Testing the touch screen

apt-get install evtest
evtest /dev/input/event0

Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "ADS7846 Touchscreen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min      250
      Max     3780
    Event code 1 (ABS_Y)
      Value      0
      Min        1
      Max     4095
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max    65535
Properties:
Testing ... (interrupt to exit)
Event: time 1439880623.938423, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1439880623.938423, type 3 (EV_ABS), code 0 (ABS_X), value 1519
Event: time 1439880623.938423, type 3 (EV_ABS), code 1 (ABS_Y), value 1350
Event: time 1439880623.938423, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65158
Event: time 1439880623.938423, -------------- SYN_REPORT ------------
Event: time 1439880623.948523, type 3 (EV_ABS), code 0 (ABS_X), value 1503
Event: time 1439880623.948523, type 3 (EV_ABS), code 1 (ABS_Y), value 1391
Event: time 1439880623.948523, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65149
Event: time 1439880623.948523, -------------- SYN_REPORT ------------
Event: time 1439880623.958356, type 3 (EV_ABS), code 0 (ABS_X), value 1455
Event: time 1439880623.958356, type 3 (EV_ABS), code 1 (ABS_Y), value 1472
Event: time 1439880623.958356, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65147
...


Calibrating the touch screen

apt-get install libts-bin
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb1
ts_calibrate

No comments:

Post a Comment