Adding touch support for the MI0283QT* displays

In my last posts I showed how to integrate Watterott’s MI0283QT-2 and the newer -9 displays as a frame buffer device in Raspberry Pi’s Linux kernel. Now I will focus on adding support for the touch controller found on the display boards.

The touch controller is an ADS7846 chip that already has a device driver in the Linux kernel. User dronus has patched the vanilla driver to make it work with the MI0283QT displays and the Raspberry Pi.

Fine, we already have everything in place now to give it a try!

Hardware

First, we need to add two additional wires in our hardware setup to connect the touch controller (see old wiring in last post) with the RPi:

Signal     Raspi      Display   Comment
T_IRQ      GPIO25       13       Interrupt line from ADS7846
T_CS       SPI0_CE0_N   11       SPI chip select 0

Software

I assume you already have a patched Linux kernel with the tft driver patches applied. Here is quick list with the next steps:

  • (Manually) apply dronus small patch to your kernel tree. This adds the necessary modifications of the ADS driver.
  • Note: I had to replace the invert_x with the invert_y entry in the ADS configuration to match the display orientation we use in the frame buffer driver
  • Your SPI config for the display now should look like this (for the newer *-9 display): linux/file arch/arm/mach-bcm2708/bcm2708.c
static struct ads7846_platform_data ads7846_config = {
  .x_max      = 0x0fff,
  .y_max      = 0x0fff,
  .x_plate_ohms    = 180,
  .pressure_max    = 255,
  .debounce_max    = 10,
  .debounce_tol    = 3,
  .debounce_rep    = 1,
  .gpio_pendown    = 25,
  .keep_vref_on    = 1,
  .swap_xy     = true,
  .invert_y    = true
};

static struct spi_board_info bcm2708_spi_devices[] = {
        {
                // ads7846 touchscreen on chipsel=0 device
                .modalias    = "ads7846",
                .bus_num    = 0,
                .chip_select    = 0,
                .max_speed_hz           = 500000,
                .irq      = GPIO_IRQ_START+25,
                .platform_data    = &ads7846_config,
                .mode = SPI_MODE_0
        }, {
                // display on chipsel=1 device
                .modalias = "ili9341fb",
                .max_speed_hz = 16000000,
                .bus_num = 0,
                .chip_select = 1,
                .mode = SPI_MODE_0,
                .platform_data = &(struct fbtft_platform_data) {
                        .gpios = (const struct fbtft_gpio []) {
                                { "reset", 23 },
                                { "led", 24 },
                                {},
                        },
                        .fps = 10
                }
        }
};
  • I use GPIO 25 for the touch IRQ (mainly because wiring was easier this way :) and had to change the relevant entries. dronus used GPIO 17 instead.
  • I reduced the SPI rate of the display to 16 MHz and the frame rate to 10 fps. This proved to be more stable with activated touch controller.
  • The older -2 display works similarly. You only have to exchange the second block with the one of the r61505u driver. See old post for details
  • Open the configuration of the kernel and select the ADS driver:
> make menuconfig
Select "Device Drivers -> Input Device Support -> [*] Touchscreens -> [*] ADS7846..."
  • Make sure to include the ADS driver directly into the kernel and NOT in a module
  • Ok, thats it! (Re-)compile kernel and install it on your RPi…

Test

After a reboot your system shows a new input device in /dev/input/*. If no other USB mouse or keyboard is connected then the devices found there are all created by the touch controller.

You can use the evtest utility to check the touch operation (Install with ‘apt-get install evtest’ first!):

> evtest /dev/input/event0

When you tap on the display you will see the incoming events. Note the x and y coordinates mapping if you tap on different corners of the display.

Now with the basic operation tested you can start X11 on your display (see last post) and use your fingers or a stylus to navigate the mouse cursor!

Open Topic

While touch operation with this driver is rock solid and works very precisely I have found one little nuisance: I can’t move the X11 cursor into the border regions of the display :( Approx 5 mm at the border of the visibile display area my touch movements are not recognized anymore and I can’t move the pointer there… I am not sure if this is a limitation of the display, of the ADS driver or the parameter set for the driver… If you find a workaround for this then please post a comment!

[Update: 21.4.2013] Pre-compiled Kernel

A pre-compiled Raspbian Wheezy Kernel 3.6.11+ with both ili9341 display and ads7846 touch driver (i.e. supporting all devices on the MI0283QT-9 board) is available for download here:

pifon: an audio baby monitor for two Raspberry Pis

Becoming a dad does not only completely change your life but also changes the scope of your hobby projects (If time still permits :) ) My first self-made project made especially for my newborn baby boy Felix is called pifon and is an audio baby monitor realized with two Raspberry Pi devices.

the pifon project: two Raspberry Pis converted into an audio baby monitor

Hardware

The hardware setup is fairly simple: one Pi, the pifon server, has a USB web cam attached. I use its internal microphone to record the voice of my little boy. The other Pi is the pifon monitor and has a set of analog speakers attached for the output. Additionaly, the mon device has an Adafruit RGB LCD Plate attached and I use the LCD on this little plate as output device and its 5 keys as user input. I did not mount the plate directly on the Pi but used a ribbon cable to detach it: This allows me to package the plate in its own housing (As it is easier to find a case for the plate alone):

pifon/mon: the listening Pi with the control panel attached

Continue reading pifon: an audio baby monitor for two Raspberry Pis

Watterott MI0283QT-9A Display for the Rasbperry Pi

In my last post I attached the Watterott Display to my Raspi. The model MI0283QT-2 I have here is not available anymore and was replaced with the newer MI0283QT-9A display modul. Unfortunately, this new display uses a different graphics chip and thus the driver I wrote won’t work for these panels… :(

With my new display driver skills, I thought about adding this new module, too :) A few days ago I received this new model and on the weekend I finally found a little time to investigate the new driver code… The new chip is an ILI9341 and uses a 9 bit SPI protocol to receive its commands… Phew, sounds a bit strange but notro’s fbtft driver framework again comes to the rescue: he has already supported the Adafruit22 which also uses 9 bit transfers and he also added an 9-bit SPI patch for the Raspi Linux kernel… With this starting point I was able to support the new display in a few hours:

Watterott's new MI0283QT-9A display running the boot console

Since the display supports the Linux framebuffer interface its also possible to run X11 with Xorg’s framebuffer driver on it:

The display also runs the X11 desktop

Again I was able to drive the display with a 32 MHz SPI clock (even 48 MHz works) and got a stable and smooth 25 fps for the 320×240 pixels in 16 Bit RGB.

If you want to setup this display on your own Raspi then read on…

Continue reading Watterott MI0283QT-9A Display for the Rasbperry Pi

Watterott Display on Raspberry Pi

I really like my Raspberry Pi, but what I am missing is a tiny display matching the size of the board that can be used as primary display, the boot console or some graphics later on.

A very nice and cheap TFT display is the MI0283QT-Adapter (note: I got the -2 version not the newer -9 version that has another display driver chip!) sold by Watterott. Its mainly focused to be an add on for the Arduinos, but it should work on every embedded system providing SPI access.

For the Linux running on the Raspberry Pi a framebuffer driver for the display would be the best solution, as it allows you to use it as a boot console and then you can run everything that runs on a framebuffer device (e.g. X11, SDL, mplayer, …).

First I thought about writing a fresh driver from scratch but some google-fu showed me that there already exists a nice solution: user notro has written fbtft, a driver framework that allows to simplify writing an own driver for those tiny TFTs.

For the R61505u display chip found on my display board, there was no driver available, but thanks to notro’s powerful framework and Watterott’s example code (Thanks to Markus for porting the code to the Raspi), I was able to derive a new driver for this chip in a few hours: See my cloned fbtft Git Hub repository for the source.

It works really nice: with 32 MHz SPI clock I can run 25 frames per second and even watch movies with smooth display:

Playing Big Bug Bunny with MPlayer's fbdev output

If you compile the driver directly in your kernel (i.e. no modules) then you can use the display directly as the boot console of your board:

Linux Boot Console running on display

If you want to build this setup yourself then read on…

Continue reading Watterott Display on Raspberry Pi

SD Card “disk box”

Its getting colder outside and its time for cool retro projects!

Today I had a really fine idea on how to better store all the SD cards I have lying around here on my desk…

With lots of retro projects using SD card as primary storage media I have lots of them here on my desk (e.g. for sd2iec, Chameleon 64, some Raspberry Pis, Arduinos …). All are usually shipped with their crystal plastic cases that also take up space…In daily use most of them are piled on the desk and the cases fly around somewhere else. So I really needed something to clean up this mess a bit.

Today, I copied some 5.25 inch diskettes for my real C64 machine and while storing the floppy disks back in the floppy disk box, I had an idea… why no build a disk box for SD cards? :)

After some hours of paper work the job was done:

If you want to build your own SD card disk box: Here are some hints:

  • Basic housing was the packaging of a SAM 256 uController from Olimex
  • I cut away the top cover and used the spare cardboard to model the separator in the middle
  • Finally I completely covered the box with self-adhesive plastic foil (Here in germany its called d c fix)
  • The foldaway dividers were cut out from SD card packaging (its a mixture of cardboard and plastic foil and its really durable) and stuck into a ground plate so you can move them a bit.

Now, its on to you! Prepare your scissors and start the paper hacking today :)

BTW: Another retro paperware project fits very well with this project: There is a thread on Forum64 that describes how to build scale replicas of 5.25 disk sleeves for your SD cards. See this thread for details and also downloadable PDFs with the sheets of construction paper…

vamos runs on Windows now

User kyberias was so kind to port the native part of vamos (the m68k emulation) to Windows and send me his patches for inclusion. The port is now included in my source tree and Windows user can now enjoy using vamos on their platform, too. Have a look at the README.WIN for build instruction.

With Mac OS X and Linux/*nix support available since the beginning, vamos is now available on all major platforms.. Yay!

Build an Arduino-based Temperature Logger

Ok, this time its no retro project, but a rather useful tool to measure your temperatue at home over a longer period of time. I had trouble with my heating devices at home and so I wanted to record and present temperature curves of various rooms to show that something is wrong…

This was a friday night project and done in a few hours (some might call it a hardware hack – but it works fairly stable for weeks now!). All you need is an Arduino 2009 Board, a Logger Shield, a push button, 2 1k resistors, and a DS18S20 temperature sensor. With these ingredients I was able to build the following compact temperature logger:

Arduino and Logger Shield: Temperature Logger

The logger samples the temperature every 10s and gives you a digital temperature value with +/-0.5 degree Celsius precision. It has a RTC (real-time-clock) on board that time stamps every measurement. Addionally, the SD card allows you to store the temperature samples in log files.

The logger has two modes of operation: Either directly read the temperature via a Mac/PC connected via the virtual serial port available on USB or write a temperature log onto the SD card. The latter mode allows you to use the device stand alone in any room without the need to directly connect your computer.

Read on for the full build and usage instructions…

Continue reading Build an Arduino-based Temperature Logger

added new amitool: xdfscan

I added a new tool to amitools, my set of cross platform classic Amiga tools: xdfscan!

What does this tool do?

Its a disk image file scanner that inspects Amiga disk (.adf) or hard disk (.hdf) image files for AmigaOS OFS or FFS file systems. If such a file system is found then the scanner runs a validator that does an in-depth check of the whole file system structure. If anything does not match or does not fulfill the file system specification then error or warning messages are generated. Warnings are usually not critical and the files on the image are all accessible, but error messages may hint to file corruption in the image. In the latter case it is advisable to recover the image by running a xdftool repack command or by issuing a DiskSalv running on an emulator.

This tool either scans a single disk image file or scans through a full directory tree. The latter operation allows you to quickly scan your disk image collection with a single run…

Have fun scanning your disk collections for corrupt or even broken images… (I must admit that the scanner is really picky and it found some issues on images I believed that were running Ok for years on a real machine… So don’t panic if lots of warnings or errors are reported… AmigaOS is quite robust handling these disks without reporting trouble…)

plipbox 0.2: added support for AVR-NET-IO board

I discovered a new board that is even more suitable for plipbox than the Arduino: It’s called the AVR-NET-IO and is available from german electronics distributor Pollin. Its fairly cheap (20 EUR for the kit) and you can also buy it pre-assembled (28 EUR). It contains all things we need: an AVR ATmega32, the right ethernet chip (ENC 28j60) and even the DB 25 connector for the parallel port of the Amiga!

Only a single wire is missing to make it fully compatible to plipbox. But you can add this one easily…

I added support for this board to the firmware and with v0.2 I ship a new firmware image just for this board… Besides adding the new board nothing has changed in this release. So Arduino users can still stay at v0.1 without any drawbacks.

See the plipbox hardware and firmware page for all details on the new board.

plipbox firmware 0.1 released

The wait is over: the first firmware release of the plipbox project is available. Simply head over to my plipbox page and fetch your copy…

The first release includes full DHCP support and statically configured Ethernet operation, so it should work on most local networks out there. With ARP and TCP/UDP/IP bridging in place, it has all essential features I envisioned for this project already available… And it really works well: I am already totally used to have my Amiga 500 in the network… (without thinking about starting a SLIP server first ;)

Now I hope that it works for you, too… just drop me a comment if you found bugs or have any remarks!