notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart 1.8

Mon Jan 28, 2013 4:25 pm

I have written a kernel module that simplifies writing drivers for many small TFT LCD display modules.
Currently two displays are supported (both SPI):
* Adafruit 2.2" [1]
* Sainsmart 1.8"

Project page: https://github.com/notro/fbtft
Here's a video: http://youtu.be/0vfDifIU7gw

I have a ordered an ITDB02-2.8 display with a 8-bit data interface to be my next project. The two other display uses SPI, so I want to see how well an 8-bit interface fits with the FBTFT module.

[1] The Adafruit display is 9-bit SPI.
Threre's not support for this at the present in Raspian, but I have made a Pull Request to try and remedy this: https://github.com/raspberrypi/linux/pull/202

User avatar
mwilliams03
Posts: 126
Joined: Mon Oct 29, 2012 2:56 pm
Contact: Website

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Mon Jan 28, 2013 7:19 pm

Nice work. I have managed to get my Adafruit 1.8" working, but never my 2.2"

When wiring, can they share any pins on the GPIO?
Looking at your code, I see that the Adafruit uses 25 for reset... and nothing for DC.
And the Sainsmart uses 24 for reset and 23 for DC.


BTW; as the Sainsmart use a ST7735R, your driver should also be able to run the Adafruit 1.8" http://adafruit.com/products/358

I'll give your driver a go tonight.
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Mon Jan 28, 2013 10:11 pm

The Adafruit 2.2" uses 9-bit SPI, so D/C is the 9nth bit. But to get it to work on the rPi, the SPI controller must be patched as mentioned in the post. This is my patched version: https://github.com/notro/linux/blob/LoS ... -bcm2708.c
When wiring, can they share any pins on the GPIO?
Well, projects using two displays, could share reset, but one driver will then control the line for both displays. For D/C, this can't be shared between drivers.

The project is in an early phase, so documentation is a bit scarce.
But I have made a detailed howto for installing the drivers: https://github.com/notro/fbtft/wiki/Bui ... ft-drivers

I haven't been able to write anything about spidevices yet. But in short:
Set the values you want. Comment out a device if you don't need it.
Build the module and load it before you load the driver.
I have used spidevices during development, but now I have arrived at a stable setup, so I have moved the info to the platform setup in arch/arm/mach-bcm2708/bcm2708.c
If anything is unclear please ask.

Setting #define DEBUG at the very top of fbtft.c and drivers, will give debug output to dmesg
BTW; as the Sainsmart use a ST7735R, your driver should also be able to run the Adafruit 1.8"
Yes I guess it does. I started my work based on the st7735fb.c driver. But I haven't got one, so I don't know for sure.
I'll give your driver a go tonight.
Nice, let me know how it goes.

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Mon Jan 28, 2013 11:06 pm

I did a quick writeup on spidevices: https://github.com/notro/fbtft/wiki/Module:-spidevices

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Tue Jan 29, 2013 5:10 am

BTW; as the Sainsmart use a ST7735R, your driver should also be able to run the Adafruit 1.8"
I just remembered that the Sainsmart display was configured BGR instead of RGB. The colors were wrong, so I had to do a conversion. So even if they have the same controller, they are configured differently.
According to the datasheet, Mode selection pin SRGB decides between RGB and BGR.

I will have to make a separate driver for the Adafruit 1.8" display.

tuxlover
Posts: 1
Joined: Sat May 12, 2012 10:07 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Tue Jan 29, 2013 2:59 pm

A very cool project.

Go on
Michael

User avatar
mwilliams03
Posts: 126
Joined: Mon Oct 29, 2012 2:56 pm
Contact: Website

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat Mar 16, 2013 1:01 am

Thanks notro ... With your code and instructions I was able to get my Adafruit 2.2" TFT working on the first try.
It is a very clear display... a lot better than the 1.8" TFT.

Great work... thanks!
Image
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat Mar 16, 2013 10:30 am

Thanks for posting back. Did you use 8 or 9-bit SPI?
I had a look at your website, and the Balancing robot project of yours looks cool!

User avatar
mwilliams03
Posts: 126
Joined: Mon Oct 29, 2012 2:56 pm
Contact: Website

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat Mar 16, 2013 8:36 pm

a stupid question, how do I know if I'm using 8 or 9 bit SPI?

BTW: I just realized that if I do a reboot, the display stops working.
I have to actually remove the power, wait about 10 secs, then restart.

That balancing robot is the reason why it took me so long to test your code out. :D
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat Mar 16, 2013 8:52 pm

mwilliams03 wrote:a stupid question, how do I know if I'm using 8 or 9 bit SPI?
If you don't know, you're using 8-bit because that's what the native SPI controller driver supports.
The display is 9-bit, but since my 9-bit patch hasn't been pulled into the raspi kernel, I made an emulation mode to the driver.
mwilliams03 wrote: BTW: I just realized that if I do a reboot, the display stops working.
I have to actually remove the power, wait about 10 secs, then restart.
I haven't experienced that. Have you connected the RST reset pin to a GPIO?

User avatar
mwilliams03
Posts: 126
Joined: Mon Oct 29, 2012 2:56 pm
Contact: Website

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat Mar 16, 2013 9:13 pm

Okay... i worked it out.
I had the Back light connected to the 5v pin, I was thinking that it just needed power.
I moved it to pin 23, and it works fine now.

thanks!
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

beefbanger1
Posts: 2
Joined: Mon Mar 25, 2013 4:20 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Mon Mar 25, 2013 4:54 pm

@notro,

I am having difficulty with the installation of the drivers for the adafruit18fb after downloading your fbtft git. I have set the following in the bcm2708.c:

#include <linux/fbtft.h>

static struct_spi_board_info bcm2708_spi_devices[] = {
{
.modalias = "adafruit18fb",
.max_speed_hz = 4000000,
.bus_num = 0,
.chip_select = 0,
.mode = SPI_MODE_0,
.platform_data = &(struct fbtft_platform_data) {
.gpios = (const struct fbtft_gpio []) {
{ "reset", 25 },
{ "dc", 24 },
{ "led", 23 },
{},
},
}
}, {
.modalias = "spidev",
.max_speed_hz = 500000,
.bus_num = 0,
.chip_select = 1,
.mode = SPI_MODE_0,
}
};

I have followed the rest of your instructions but when I make the menuconfig and go to
"Device Drivers > Graphics Support > < > Support for small TFT LCD display modules (NEW) --->"
I find no drivers listed and no way to select it as built-in or as a module.

I have made sure the SPI is not blacklisted and I have added the lines to the Kconfig and Makefile files. The fbtft.h file has been linked to the ../include/linux/ path

I am new to Linux so I was wondering if there is something I am missing in the setup which may be obvious to an expert. I have loaded the latest version of wheezy (3.6.11+) and made sure that I did an update and upgrade to all modules. I have now been trying this for two days and I would appreciate any help you could give me regarding this. Attached is a screenshot of the menuconfig (via ssh)
Attachments
Screenshot.jpg
Screenshot of menuconfig
Screenshot.jpg (55.95 KiB) Viewed 10931 times

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Mon Mar 25, 2013 6:10 pm

@beefbanger1,

You haven't activated it.
In the Device Drivers > Graphics Support > screen you have to <Y> or <M> the feature before you select the submenu:
<*> Support for small TFT LCD display modules --->
<M> Support for small TFT LCD display modules --->

This decides whether fbtft should be a module or compiled into the kernel.

beefbanger1
Posts: 2
Joined: Mon Mar 25, 2013 4:20 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Mon Mar 25, 2013 6:24 pm

@notro,

Thanks. It worked. I was trying to select Y in the following menu. I will try to compile later.

nejemia
Posts: 10
Joined: Mon Apr 29, 2013 12:53 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 9:40 am

nejemia wrote:
Hello everybody:
I have the 1.8" Adafruit working and need some extra information-
Change orientation-- I need the Display to work in "landscape" - the echo "1" > /sys/class/graphics/fbcon/rotate works but once issued, Display stops to work (weird).
Also, I would like to use "fbterm", any idea how to instruct "fbterm" to use /dev/fb1 and /dev/tty1 ?
Is it possible to change fonts ? Too big for the 1.8" Display.
By the way, I used sainsmart and adafruit with same Display and did not notice differences, need to run more testings.
I want to have this secondary display as an auxiliary display for different kind of Text (formatted in Color, Size and Background colors), any sugestion?
Well, thank you all a million and congratulation for this fantastic work !!
All the best.
Nelson

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 10:56 am

nejemia wrote: I have the 1.8" Adafruit working and need some extra information-
Have you built the kernel your self or have you used an image from: https://github.com/notro/fbtft/wiki ?
nejemia wrote: Also, I would like to use "fbterm", any idea how to instruct "fbterm" to use /dev/fb1 and /dev/tty1 ?
See bottom of this page: http://www.whence.com/rpi/
nejemia wrote: Is it possible to change fonts ? Too big for the 1.8" Display.
The fbtft image has the MINI4x6 font compiled in. See : https://github.com/notro/fbtft/wiki/Boot-console
I don't know if these fonts are used by fbterm.
nejemia wrote: By the way, I used sainsmart and adafruit with same Display and did not notice differences, need to run more testings.
If you by this mean the sainsmart18fb and adafruit18fb drivers, they are identical except for:
* adafruit18fb slows down the SPI bus when sending commands, and has 4 MHz as default speed (fbtft_device).
* sainsmart18fb flips RED and BLUE and supports rotation, and has 32MHz as default speed (fbtft_device). Add the bgr parameter when used with an Adafruit 1.8" display. https://github.com/notro/fbtft/wiki/LCD ... insmart_18

nejemia
Posts: 10
Joined: Mon Apr 29, 2013 12:53 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 11:24 am

Dear Nostro:
Thank you and I am impressed with your work. After several weeks working with Arduinos and other boards to have a Display I came across this fantastic job of yours.
I am using the .img provided in your site. It works fine.
I want to have the Display working in Landscape mode and want to Display formatted texts from a Text file generated by another program.
What is the best (correct) way to do it?
Also, I have another Display which uses ILI9320 and is 320x240 so I will try it. It is SPI controlled and uses SPI mode 3 to work ( at least with Arduino).
Again, thanks a lot and congratulations, you are the Master of the Raspi Displays!

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 12:45 pm

nejemia wrote: ... want to Display formatted texts from a Text file generated by another program.
What is the best (correct) way to do it?
Sorry, can't help you with that.
nejemia wrote: Also, I have another Display which uses ILI9320 and is 320x240 so I will try it. It is SPI controlled and uses SPI mode 3 to work ( at least with Arduino).
Do you have a link to the product page ? I have only come across a Watterott of that size and with SPI, but Watterott uses ili9341.
You could try and use the flexfb driver for the ili9320: https://github.com/notro/fbtft/wiki/flexfb
nejemia wrote: Again, thanks a lot and congratulations, you are the Master of the Raspi Displays!
Thanks for the praise :oops:

nejemia
Posts: 10
Joined: Mon Apr 29, 2013 12:53 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 2:22 pm

Dear Master notro:
I have the 1.8" displaying beautiful pictures of my first grandaughter Debbie (2 month old !) and it is amazing ! Again, CONGRATULATIONS for a fabulous work you have done indeed !
The Display I am planning to test is the following: http://www.hotmcu.com/28-touch-screen-t ... -p-42.html
I have it working with Arduino, SPI speed reduced to 1/4th and SPI mode 0x03 (?).
I still need some help with the 1.8" Display, I can not make it to display in the Landscape mode, I apply the rotate command, but each time I resume the use of the framebuffer, everything returns to the normal vertical view.
Well, let me know and by the way, I have downloaded fbtext and it works, however, only in Vertical position ... can not apply the rotate to the image :cry:
All the best master and will be in touch soon !!
Nelson

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 2:52 pm

nejemia wrote: The Display I am planning to test is the following: http://www.hotmcu.com/28-touch-screen-t ... -p-42.html
Oh yes, I remember that one now. I have it on the shelf, but haven't used it since the pins is spaced so close. What do you use to connect to the headers?
nejemia wrote: I still need some help with the 1.8" Display, I can not make it to display in the Landscape mode, I apply the rotate command, but each time I resume the use of the framebuffer, everything returns to the normal vertical view.
With an Adafruit 1.8" display this should probably work:

Code: Select all

modprobe fbtft_device name=sainsmart18fb speed=8000000
modprobe sainsmart18fb bgr rotate=1

nejemia
Posts: 10
Joined: Mon Apr 29, 2013 12:53 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Wed May 01, 2013 3:39 pm

It worked :)
Now the new TFT Display is waiting !
A lot of work to come.
All the best !!!
Nelson

nejemia
Posts: 10
Joined: Mon Apr 29, 2013 12:53 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Thu May 02, 2013 12:02 pm

Dear notro:
I have checked the HY28-A Display SPI version and it does not use the D0-D7 data lines, just plain commands through the SPI like the Adafruit.
Do you think the generic tftfb driver can handle this?
I have another beautiful display using the same controler but 3.2", unfortunately this uses 16 data lines along the SPI...
Any suggestion how to manage both options?
Cheers,
Nelson

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Thu May 02, 2013 12:34 pm

nejemia wrote: I have checked the HY28-A Display SPI version and it does not use the D0-D7 data lines, just plain commands through the SPI like the Adafruit.
Do you think the generic tftfb driver can handle this?
Maybe, flexfb was made for this purpose, but I haven't had any reports about it yet.
https://github.com/notro/fbtft/wiki/flexfb#ili9320
nejemia wrote: I have another beautiful display using the same controler but 3.2", unfortunately this uses 16 data lines along the SPI...
I guess SPI is for the touch controller.
This thread discusses a controller with a 16-bit databus and a SPI interfacing circuit: http://www.raspberrypi.org/phpBB3/viewt ... 64&t=33679

I'm awaiting some 74HC4094 chips with the purpose of adding SPI support for the Sainsmart 3.2" display (16-bit databus).

fdufnews
Posts: 289
Joined: Fri Oct 07, 2011 5:37 pm

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat May 25, 2013 10:18 am

Hi notro thank you for your frame buffer.
Following the informations on your wiki, I have tested with success the MIO283QT-2

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: Linux Framebuffer Driver for Adafruit 2.2" and Sainsmart

Sat May 25, 2013 10:35 am

fdufnews wrote:Hi notro thank you for your frame buffer.
Following the informations on your wiki, I have tested with success the MIO283QT-2
Thanks for letting me know. I had reports that the other Wattterott display didn't work, so I wasn't sure about the state of the r61505ufb driver.
And it's always nice to hear that what I've made is of use for others :-)

Return to “Other projects”