ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Adafruit 1.8" TFT with RPi

Mon Jul 30, 2012 12:30 am

Hi all,

I just wanted to share that I've soldered an Adafruit 1.8" TFT (http://adafruit.com/products/358) onto an Adafruit Proto Pi Plate (http://adafruit.com/products/801) and written code to display some info on it from the Pi. I've uploaded a video of it in action to http://www.flickr.com/photos/ngreatorex/7672743302/. I used pygame to produce the simple display show in the video.

The kernel module source is at https://github.com/ngreatorex/st7735fb if anyone is interested in doing the same. The module is based on the excellent work of Matt Porter at TI (see http://elinux.org/images/1/19/Passing_T ... Driver.pdf).

Cheers,
Neil

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

Re: Adafruit 1.8" TFT with RPi

Mon Oct 29, 2012 3:02 pm

I would love to know how you got this wired up.
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Re: Adafruit 1.8" TFT with RPi

Mon Oct 29, 2012 4:13 pm

It is quite simple to wire up. It's very similar to the Arduino (see http://learn.adafruit.com/1-8-tft-displ ... spi-wiring). Instead of using the Arduino pin numbers, you use the Raspberry Pi pin numbers as found at http://elinux.org/images/2/2a/GPIOs.png. For the TFT_CS and D/C pins, you should just pick unused GPIOs and ensure they are referenced in the code.

Kamal Mostafa has tidied up the code and made all the pins configurable. His code is linked to from http://www.whence.com/rpi/.

Hope that helps.

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

Re: Adafruit 1.8" TFT with RPi

Tue Nov 13, 2012 7:16 pm

Thanks for the reply Neil.
After a couple of goes, I think I may have it working.

I have compiled the drivers as modules, I can now see /dev/fb1
I used;
modprobe st7735fb
modprobe st7735fb_map

I tried fbterm, but no luck. Nothing on the display.
I used;
Export FRAMEBUFFER=/dev/fb1
/usr/bin/fbterm –r 1 -- /bin/login < /dev/tty1

Would you be able to share the code you used to show the data on the framebuffer with pygame? Maybe I can give this a go.
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Re: Adafruit 1.8" TFT with RPi

Tue Nov 13, 2012 10:34 pm

mwilliams03 wrote:Thanks for the reply Neil.
After a couple of goes, I think I may have it working.

I have compiled the drivers as modules, I can now see /dev/fb1
I used;
modprobe st7735fb
modprobe st7735fb_map

I tried fbterm, but no luck. Nothing on the display.
I used;
Export FRAMEBUFFER=/dev/fb1
/usr/bin/fbterm –r 1 -- /bin/login < /dev/tty1

Would you be able to share the code you used to show the data on the framebuffer with pygame? Maybe I can give this a go.
Hi,

Are you using Kamal's code? My original code won't work with fbterm. Kamal has fixed this in his branch at https://github.com/kamalmostafa/raspberrypi-linux.

I have attached a gziped version of my pygame code.

Cheers,
Neil
Attachments
lcd-clock.py.gz
PyGame code
(1.06 KiB) Downloaded 384 times

munklefish
Posts: 92
Joined: Tue Oct 02, 2012 5:35 pm
Location: Neumarkt in der Oberpfalz
Contact: Website

Re: Adafruit 1.8" TFT with RPi

Wed Nov 14, 2012 3:43 pm

Does anyone know what sort of power consumption these units have??

Would it be possible for the OP to give us an estimation of total power draw on this full set-up as is running the software, pi and screen??

Thanks.
http://www.codeclinic.de

ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Re: Adafruit 1.8" TFT with RPi

Mon Nov 19, 2012 2:59 pm

munklefish wrote:Does anyone know what sort of power consumption these units have??

Would it be possible for the OP to give us an estimation of total power draw on this full set-up as is running the software, pi and screen??

Thanks.
I took some quick measurements with a plug in watt meter today and this is what I got:

Idle, without screen attached: 3.5W
Running fbterm, with screen attached: 3.5W
Running the lcd-clock script in my last post: 4.3W
Playing raw 66x160 video at 25fps: 4.4W

munklefish
Posts: 92
Joined: Tue Oct 02, 2012 5:35 pm
Location: Neumarkt in der Oberpfalz
Contact: Website

Re: Adafruit 1.8" TFT with RPi

Mon Nov 19, 2012 3:37 pm

ngreatorex wrote: I took some quick measurements with a plug in watt meter today and this is what I got:

Idle, without screen attached: 3.5W
Running fbterm, with screen attached: 3.5W
Running the lcd-clock script in my last post: 4.3W
Playing raw 66x160 video at 25fps: 4.4W
Excellent. Thanks!!
http://www.codeclinic.de

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

Re: Adafruit 1.8" TFT with RPi

Wed Nov 21, 2012 3:54 am

thanks Neil... it worked first go.

thanks for your help getting this going.

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

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Mon Nov 26, 2012 11:04 pm

Hi all,

Been really impressed with the work you lot have been doing. Have an ST7735 based 1.8" LCD from Sainsmart that came as part of an Arduino UNO package.

Over the last few days I've been trying to get the 1.8" LCD working with the RPi for a project that I'm working on as it'll mean I can possibly eliminate the use of an Atmel MCU / Arduino. However I've had no such luck with the ST7735 driver.

So far I've attempted to compile Kamal's branch using the Occidentals 0.2 distro aswell as the wheezy-raspbian (2012-10-28). I've followed Kamal's guide from "Configuring the kernel build", which goes through asking questions about configuring the ST7735 driver. I've used the same GPIO's as Kamal for RST/DC, and just hit enter on the others. Even wired up the LCD the same.
However after rebooting using the new kernel I have no framebuffer device under /dev, all I have is fb0 but no fb1.

Would anybody care to help as it's about my 3rd-4th compile of the kernel, and I'm doing it directly on the RPi which takes a good part of a day to do.

Regards
Darryl

ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Re: Adafruit 1.8" TFT with RPi

Mon Nov 26, 2012 11:11 pm

darryl wrote: Would anybody care to help as it's about my 3rd-4th compile of the kernel, and I'm doing it directly on the RPi which takes a good part of a day to do.
Hi Darryl,

I'll certainly try to help!

First, could you post your kernel config (if you don't already know, it's saved as ".config" in the directory of the kernel sources) and also the output of running "dmesg" when the kernel has booted.

Hopefully that should indicate the source of any problems.

Cheers,
Neil

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

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 12:44 am

Try this;
http://marks-space.com/2012/11/23/raspberrypi-tft/
I documented the full process to try and help others.
I used cross compiling, it is a bit more complicated.. but I can compile a new kernel for my Pi in 15mins.
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 12:48 am

Hi Neil,

Though you guys would most likely want some dump of my setup. My latest attempt has been with wheezy distro and Kamal's branch. To setup the config I did as per his guide and used "make bcmrpi_defconfig", followed by the SED command to modify the config file so that the make oldconfig would run through setup questions relating to the ST7735.


Here are my files:

.config

and

dmesg

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

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 1:36 am

I could only get my working if i compiled it as a module.
this is what i did;
CONFIG_FB_ST7735=m
CONFIG_FB_ST7735_PANEL_TYPE_RED_TAB=y
CONFIG_FB_ST7735_MAP=m
CONFIG_FB_ST7735_MAP_RST_GPIO=25
CONFIG_FB_ST7735_MAP_DC_GPIO=24
CONFIG_FB_ST7735_MAP_SPI_BUS_NUM=0
CONFIG_FB_ST7735_MAP_SPI_BUS_CS=0
CONFIG_FB_ST7735_MAP_SPI_BUS_SPEED=4000000
CONFIG_FB_ST7735_MAP_SPI_BUS_MODE=3

Then, after the kernel finishes compiling.. and you have built your modules... do this;

-sp-bcm2708 is blacklisted, we need to comment it out so it loads at boot.
pi@raspberrypi ~ $ sudo vi /etc/modprobe.d/raspi-blacklist.conf

-Put a hash in font of the line with ‘blacklist spi-bcm2708′ E.g..
#blacklist spi-bcm2708



-Now set the order in which the modules are loaded.
pi@raspberrypi ~ $ sudo vi /etc/modules
-Add these three lines to the bottom of the list;
st7735fb
spi-bcm2708
st7735fb_map
Mark -- OzzMaker.com -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+BerryGPS-GSM
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 2:46 am

Hi,

This is an issue that I've been discussing with Kamal. The problem is that if you build in the ST7735 driver you also have to build in the BCM2708 SPI driver.

Change CONFIG_SPI_BCM2708=m to CONFIG_SPI_BCM2708=y and it should work.

Cheers,
Neil

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 8:46 am

My previous post didn't include the URL's properly, think it must of been the quotes around the url address so I've reposted.

.config:

https://docs.google.com/open?id=0B1m8uJ ... E1FRm9DOXc

and

dmesg:

https://docs.google.com/open?id=0B1m8uJ ... XhtR0JobEU


The two things that I thought might be a problem is the fact that I've built the ST7735 module into the kernel, but Kamal doesn't seem to have a problem with this. My other thought was the BCM2708 conflicting with the ST7735.

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 8:53 am

mwilliams03 wrote:Try this;
http://marks-space.com/2012/11/23/raspberrypi-tft/
I documented the full process to try and help others.
I used cross compiling, it is a bit more complicated.. but I can compile a new kernel for my Pi in 15mins.
I think I'll be installing nix on my laptop soon and cross compiling. Will make it a little less time consuming.

ngreatorex
Posts: 7
Joined: Mon Jul 30, 2012 12:26 am

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 9:03 am

darryl wrote:My previous post didn't include the URL's properly, think it must of been the quotes around the url address so I've reposted.

.config:

https://docs.google.com/open?id=0B1m8uJ ... E1FRm9DOXc

and

dmesg:

https://docs.google.com/open?id=0B1m8uJ ... XhtR0JobEU


The two things that I thought might be a problem is the fact that I've built the ST7735 module into the kernel, but Kamal doesn't seem to have a problem with this. My other thought was the BCM2708 conflicting with the ST7735.
ngreatorex wrote:Hi,

This is an issue that I've been discussing with Kamal. The problem is that if you build in the ST7735 driver you also have to build in the BCM2708 SPI driver.

Change CONFIG_SPI_BCM2708=m to CONFIG_SPI_BCM2708=y and it should work.

Cheers,
Neil
Hi Darryl,

Were you able to try the fix I mentioned in the post I've quoted above? I'm pretty confident that will solve your problem!

Cheers,
Neil

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 9:55 am

ngreatorex wrote:
darryl wrote:My previous post didn't include the URL's properly, think it must of been the quotes around the url address so I've reposted.

.config:

https://docs.google.com/open?id=0B1m8uJ ... E1FRm9DOXc

and

dmesg:

https://docs.google.com/open?id=0B1m8uJ ... XhtR0JobEU


The two things that I thought might be a problem is the fact that I've built the ST7735 module into the kernel, but Kamal doesn't seem to have a problem with this. My other thought was the BCM2708 conflicting with the ST7735.
ngreatorex wrote:Hi,

This is an issue that I've been discussing with Kamal. The problem is that if you build in the ST7735 driver you also have to build in the BCM2708 SPI driver.

Change CONFIG_SPI_BCM2708=m to CONFIG_SPI_BCM2708=y and it should work.

Cheers,
Neil
Hi Darryl,

Were you able to try the fix I mentioned in the post I've quoted above? I'm pretty confident that will solve your problem!

Cheers,
Neil
Neil, not long been up but read it this morning. Haven't been able to try it as I'll have to build the kernel again on the RPi and as yet don't have any other nix dev platform to work on. Just in the process of grabbing mint and get my laptop setup as I'm sick of 8-11 hour build times :(

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 7:14 pm

Just an update. Followed Mark's guide and cross compiled the kernel with the drivers as modules on my laptop and copied them across and now have the hobbit trailer running on the RPi.

Going to try and build them again using the built-in method.

Haven't managed to get fbterm working, might give the fbcon method a go but not sure if that will work with driver as modules?

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Tue Nov 27, 2012 11:36 pm

Update:

Have recompiled so that spi_bcm2708 and st7735 are builtin to the kernel. Have had success with fbterm displaying the login and using mplayer. However still no luck with fbcon, adding the options to cmdline.txt seems to prevent the RPi from booting. Have checked .config and fbcon seems to be builtin:

Code: Select all

# Console display driver support
#
CONFIG_DUMMY_CONSOLE=y
CONFIG_FRAMEBUFFER_CONSOLE=y
# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
# CONFIG_FONTS is not set
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_LOGO=y
I've also tried con2fbmap but couldn't get it to work.

kamalmostafa
Posts: 3
Joined: Wed Sep 19, 2012 6:02 pm

Re: Adafruit 1.8" TFT with RPi

Wed Nov 28, 2012 1:49 am

Hi Darryl-

Great that you've got the driver up and working!...
darryl wrote: ... However still no luck with fbcon, adding the options to cmdline.txt seems to prevent the RPi from booting.
What exactly happens when it prevents it from booting?
darryl wrote: Have checked .config and fbcon seems to be builtin:
Try adding/changing these config options (assuming you're trying to boot with "fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11" as recommended on my project page):

Code: Select all

CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
CONFIG_FONTS=y
CONFIG_FONT_6x11=y
darryl wrote:I've also tried con2fbmap but couldn't get it to work.
What exactly happens? This works for me ...

Code: Select all

$ con2fbmap 1 0    # sets tty1 to the HDMI console
$ con2fbmap 1 1    # sets tty1 to the ST7735 console

kamalmostafa
Posts: 3
Joined: Wed Sep 19, 2012 6:02 pm

Re: Adafruit 1.8" TFT with RPi

Wed Nov 28, 2012 1:58 am

darryl wrote: ... might give the fbcon method a go but not sure if that will work with driver as modules?
It will not. To use fbcon, you must build the pair of drivers (st7735fb and st7735fb_map) as built-ins, not as modules (you must set their configs to "=y", not "=m").

And, as Neil mentioned, whenever you build the st7735 pair as built-ins you also need SPI_BCM2708 to be built-in... Currently, you must manually set CONFIG_SPI_BCM2708 to "=y". We're working on determining a proper way to get that bit to happen automatically.

darryl
Posts: 12
Joined: Mon Nov 26, 2012 10:49 pm

Re: Adafruit 1.8" TFT with RPi

Wed Nov 28, 2012 10:00 am

kamalmostafa wrote:Hi Darryl-

Great that you've got the driver up and working!...
darryl wrote: ... However still no luck with fbcon, adding the options to cmdline.txt seems to prevent the RPi from booting.
What exactly happens when it prevents it from booting?
darryl wrote: Have checked .config and fbcon seems to be builtin:
Try adding/changing these config options (assuming you're trying to boot with "fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11" as recommended on my project page):

Code: Select all

CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
CONFIG_FONTS=y
CONFIG_FONT_6x11=y
darryl wrote:I've also tried con2fbmap but couldn't get it to work.
What exactly happens? This works for me ...

Code: Select all

$ con2fbmap 1 0    # sets tty1 to the HDMI console
$ con2fbmap 1 1    # sets tty1 to the ST7735 console

Hi Kamal,

Since following Mark's guide into building the kernel with the drivers as modules I followed Neil's initial advice about changing CONFIG_SPI_BCM2708 to 'Y' instead of 'M' so that it's a builtin. Did the same for the ST7735 driver aswell and rebuilt the kernel on the laptop. Which is great as the compile times don't take all day :).

As for fbcon, I'm using the settings that you posted on your page and did wonder if it was due to the .config settings for font of 8x8 and 8x16 preventing it from booting. I was going to attempt to change the cmdline.txt to 8x8 or 8x16 as an easy fix to test if that was the problem without having to rebuild the kernel. I'm not sure what is happening when I use fbcon, all I know is that when I add the lines to cmdline.txt and restart the RPi it then is unreachable via SSH. I could hook it upto the TV but it would mean rooting around and removing HDMI cables from the XBox, going to see if I can get a cheapy HDMI cable off eBay.

I've been getting a bit sidetracked and have been writing some test C/C++ code to display pixels on the framebuffer device. Seems to be working fine. Have noticed with the code that I'm using that the device gets returned as 16bpp in an RGB565 format. I know the LCD is sold as 18bit but I'm guessing the driver makes the fbdev into 16bit for some reason.

Just remembered something aswell, in the example you had "fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11". After reading some docs on fbcon, I did wonder if the map was right as I would of thought to get tty1 to display on fb1 shouldn't it be "fbcon=map:11"?

With con2fbmap I've been using 1 0, 1 1 and a variety of other options to try and get it to to work. After hitting enter the cursor isn't returned to the CLI and you can't do anything. FYI, I am trying to run con2fbmap from an SSH session with the RPi. Perhaps having the RPi plugged in via HDMI to a TV and executing con2fbmap directly would work.

kamalmostafa
Posts: 3
Joined: Wed Sep 19, 2012 6:02 pm

Re: Adafruit 1.8" TFT with RPi

Wed Nov 28, 2012 3:11 pm

darryl wrote: As for fbcon, I'm using the settings that you posted on your page and did wonder if it was due to the .config settings for font of 8x8 and 8x16 preventing it from booting. I was going to attempt to change the cmdline.txt to 8x8 or 8x16 as an easy fix to test if that was the problem without having to rebuild the kernel.
Hi Darryl-

It's fine to leave the 8x8 and 8x16 fonts enabled in your .config -- I do not recommend that you disable them. An even more straightforward test would be to not use any fbcon=font or fbcon=rotation settings in cmdline.txt at all... Try adding just "fbcon=map:10" to your cmdline.txt. That should work even if you don't have the additional font and console_rotation CONFIG's enabled.
darryl wrote:Have noticed with the code that I'm using that the device gets returned as 16bpp in an RGB565 format. I know the LCD is sold as 18bit but I'm guessing the driver makes the fbdev into 16bit for some reason.
The panel supports a few different color modes; The driver currently implements only the RGB565 (16bpp) mode.
darryl wrote: Just remembered something aswell, in the example you had "fbcon=map:10 fbcon=rotate:1 fbcon=font:ProFont6x11". After reading some docs on fbcon, I did wonder if the map was right as I would of thought to get tty1 to display on fb1 shouldn't it be "fbcon=map:11"?
No, my suggested map setting (fbcon=map:10) is correct: it maps tty1 to fb1 (the ST7735 panel) and tty2 to fb0 (the Pi's native GPU framebuffer). See http://www.kernel.org/doc/Documentation/fb/fbcon.txt for more details.
darryl wrote: With con2fbmap I've been using 1 0, 1 1 and a variety of other options to try and get it to to work. After hitting enter the cursor isn't returned to the CLI and you can't do anything. FYI, I am trying to run con2fbmap from an SSH session with the RPi. Perhaps having the RPi plugged in via HDMI to a TV and executing con2fbmap directly would work.
Running con2fbmap from an ssh session should work fine (it does for me). Doing so from an HDMI-connected tty instead won't make any difference, I expect.

Is it that the whole system hangs (doesn't respond to ping?) after you run con2fbmap?

Finally (and most importantly)... Do you have my latest version of the driver source? (I suspect not, since the latest version would have enabled those font configs automatically for you). I updated my github branch with some important fbcon fixes within the past few days. The current latest version is commit 247163d79e... from https://github.com/kamalmostafa/raspberrypi-linux.git.

Return to “Other projects”