RetroBSD
http://retrobsd.org/

TFT LCD driver and examples
http://retrobsd.org/viewtopic.php?f=5&t=37311
Page 1 of 2

Author:  vak [ Sat Oct 10, 2015 3:07 am ]
Post subject:  TFT LCD driver and examples

A new programming interface for the HX8357 TFT driver is finally finished. A set of supported ioctl calls has been extended with basis draw primitives like pixel, line, rectangle, filled rectangle, circle, image, character and string of characters. Proportonal and fixed fonts of arbitrary size are supported. Fonts are supplied from the user space.

The graphics display is available for the user programs via gpanel library. You can find a few examples in the /share/examples/gpanel directory. In case you have a Picadillo-35T board, you can try to run them. (do not forget to update your kernel and SD card first)
Code:
# cd /share/examples/gpanel
# make
cc  -o tft  tft.c
cc  -o tftetris  tftetris.c
cc  -o pixel  pixel.c -lgpanel
cc  -o line  line.c -lgpanel
cc  -o rect  rect.c -lgpanel
cc  -o fill  fill.c -lgpanel
cc  -o circle  circle.c -lgpanel
cc  -o 5x7.o -c fonts/5x7.c
cc  -o 6x9.o -c fonts/6x9.c
cc  -o digits20.o -c fonts/digits20.c
cc  -o digits32.o -c fonts/digits32.c
cc  -o lucidasans11.o -c fonts/lucidasans11.c
cc  -o lucidasans15.o -c fonts/lucidasans15.c
cc  -o lucidasans7.o -c fonts/lucidasans7.c
cc  -o lucidasans9.o -c fonts/lucidasans9.c
cc  -o verdana7.o -c fonts/verdana7.c
cc  -o font  font.c 5x7.o 6x9.o digits20.o digits32.o lucidasans11.o lucidasans15.o  lucidasans7.o lucidasans9.o verdana7.o -lgpanel
cc  -o color  color.c -lgpanel
cc  -o speed  speed.c lucidasans15.o -lgpanel
# ./pixel

Pixel demo displays a screen full of random colored dots, much like noise:
Attachment:
pixel.jpg
pixel.jpg [ 55.67 KiB | Viewed 33022 times ]

Line demo draws random lines of random colors:
Code:
# ./line
Attachment:
line.jpg
line.jpg [ 67.88 KiB | Viewed 33022 times ]

Rect demo draws random rectangle frames of random colors:
Code:
# ./rect
Attachment:
rect.jpg
rect.jpg [ 61.51 KiB | Viewed 33020 times ]

Fill demo shows rectangles filled with random colors:
Code:
# ./fill
Attachment:
fill.jpg
fill.jpg [ 21.55 KiB | Viewed 33020 times ]

Circle demo draws random circles:
Code:
# ./circle
Attachment:
circle.jpg
circle.jpg [ 63.23 KiB | Viewed 33020 times ]

The Picadillo-35T display supports 64k colors. Color demo tries to demonstrate available palette. Unfortunately, a photo camera of my smartphone had distorted the colors: in reality it looks more naturally.
Code:
# ./color
Attachment:
color.jpg
color.jpg [ 14.79 KiB | Viewed 33020 times ]

Font demo shows a few fonts of different sizes. You can find these font files in directory /share/examples/gpanel/fonts. The font data were generated from Lucida_Sans_Unicode.ttf and Verdana.ttf files using otf2bdf and convbdf utilities. You can generate your own fonts of needed typefaces, sizes and character sets. See Makefile in this directory for details.
Code:
# ./font
Screen size 480 x 320.
Draw fonts.
Press ^C to stop.
Font Lucida Sans 15: press Enter...
Font Lucida Sans 11: press Enter...
Font Lucida Sans 9: press Enter...
Font Lucida Sans 7: press Enter...
Font Verdana 7: press Enter...
Font Fixed 6x9: press Enter...
Font Fixed 5x7: press Enter...
Font Digits 32: press Enter...
Font Digits 20: press Enter...
^C
Attachment:
lucidasans15.jpg
lucidasans15.jpg [ 46.08 KiB | Viewed 33020 times ]
Attachment:
lucidasans11.jpg
lucidasans11.jpg [ 42.75 KiB | Viewed 33020 times ]
Attachment:
lucidasans9.jpg
lucidasans9.jpg [ 40.76 KiB | Viewed 33020 times ]
Attachment:
lucidasans7.jpg
lucidasans7.jpg [ 36.79 KiB | Viewed 33020 times ]
Attachment:
verdana7.jpg
verdana7.jpg [ 37.47 KiB | Viewed 33020 times ]
Attachment:
fixed6x9.jpg
fixed6x9.jpg [ 39.68 KiB | Viewed 33020 times ]
Attachment:
fixed5x7.jpg
fixed5x7.jpg [ 38.28 KiB | Viewed 33020 times ]
Attachment:
digits32.jpg
digits32.jpg [ 32.88 KiB | Viewed 33020 times ]
Attachment:
digits20.jpg
digits20.jpg [ 31.11 KiB | Viewed 33020 times ]

A performance of graphics primitives can be measured by the speed test:
Code:
# ./speed
Screen size 480 x 320.
Graphics speed:
 76045 pixels/second
 1764 lines/second
 486 rectangles/second
 816 circles/second
 6079 characters/second

Author:  Pito [ Sat Oct 10, 2015 6:39 am ]
Post subject:  Re: TFT LCD driver and examples

Fantastic!

And now the obvious question - how do I connect my junk box tft displays - ie. SPI ones: 2.2in w/ ILI9341, 1.8in w/ ST7735, not mentioned a 3.5in 16bit one I ran once because of a lot of wires :) ??
All the displays work fine under arduino with adafruit libs..

Author:  vak [ Sat Oct 10, 2015 6:48 am ]
Post subject:  Re: TFT LCD driver and examples

You will need to create a driver for every type of display controller. Use Matt's HX8357 driver as a prototype. Adafruit sources can help a lot.

Author:  wiz [ Sat Oct 10, 2015 7:14 am ]
Post subject:  Re: TFT LCD driver and examples

Hi Serge and Pito and all,

And the 2nd 'obvious' question.

What about a graphics html5 or java output.

So I can use the WebSocket protocol to drive my attached [usb or wifi] cheap phone.

Wiz

Author:  vak [ Sat Oct 10, 2015 7:41 am ]
Post subject:  Re: TFT LCD driver and examples

Hi Wiz,

I still don't understand how do you plan to connect pic32 to the phone. Neither usb not wifi are available.

The only way I could imagine is to use the W5100 Ethernet shield and to create an application which implements a web server with WebSocket support. This is possible right now: RetroBSD already has everything required for this task. The only challenge is to fit a web server into 96 kbytes of user memory.

It has nothing to do with graphics library and TFT driver, though.

--Serge

Author:  vak [ Sat Oct 10, 2015 8:27 am ]
Post subject:  Re: TFT LCD driver and examples

Pito wrote:
And now the obvious question - how do I connect my junk box tft displays - ie. SPI ones: 2.2in w/ ILI9341, 1.8in w/ ST7735,

I have a display shield based on ST7781 controller. May be I'll make a driver for it someday. The interface seems pretty simple.

Image

Author:  Pito [ Sat Oct 10, 2015 8:48 am ]
Post subject:  Re: TFT LCD driver and examples

There is maybe dozen of tft's ILI or ST chips :)
And there are 3 variants of the ST7735 chip based 1.8in tft's - red, black, green :) which differ in few ST chip settings..

Author:  majenko [ Sat Oct 10, 2015 11:45 am ]
Post subject:  Re: TFT LCD driver and examples

If you want drivers to adapt that are written mainly with the pic32 in mind you can pick your way through DisplayCore: https://github.com/MajenkoLibraries/DisplayCore

Author:  majenko [ Sat Oct 10, 2015 11:46 am ]
Post subject:  Re: TFT LCD driver and examples

Pito wrote:
There is maybe dozen of tft's ILI or ST chips :)
And there are 3 variants of the ST7735 chip based 1.8in tft's - red, black, green :) which differ in few ST chip settings..

They're not variants of the chip - they are variants of the display panel the chip is used with - mainly to do with RGB/BGR ordering.

Author:  Pito [ Sat Oct 10, 2015 11:55 am ]
Post subject:  Re: TFT LCD driver and examples

Yes, exactly.

Author:  wiz [ Sat Oct 10, 2015 3:45 pm ]
Post subject:  Re: TFT LCD driver and examples

Hi Serge,

How to connect html5 or java from PIC32 to phone?

Good point. I don't know how to connect it right now either.

But given even a little starting point, maybe java or html5 in a file to load to the phone and some data to drive the phone, I bet I can get it going :). [ maybe :) ]

I notice that the SDR in the Netherlands uses html5/java over WebSocket so that might be copied to get a starting point?

I am assuming the PIC32 will send java/html5 to the phone and then 'talk' to that java/html5 with 'real-time' data carried eventually by the WebSocket protocol.

I haven't looked at the 5th wire of usb on the go, but maybe that can carry some of the required data. [ I assume it is some sort of serial protocol associated with the 'regular' USB handshake(s). ]

Besides we all need a 'real' challenge once and a while :).

Lots of fun :).

Wiz

Author:  majenko [ Sat Oct 10, 2015 8:25 pm ]
Post subject:  Re: TFT LCD driver and examples

Quote:
I haven't looked at the 5th wire of usb on the go, but maybe that can carry some of the required data. [ I assume it is some sort of serial protocol associated with the 'regular' USB handshake(s). ]

No, it is a simple digital input to the MCU. Either HIGH or LOW. One indicates it's to run in host mode, the other for device mode (I forget which is which off hand). It can't carry any data. An OTG cable hard wires that pin either to +5V or GND.

Author:  vak [ Wed Oct 14, 2015 2:44 am ]
Post subject:  Re: TFT LCD driver and examples

Pito wrote:
There is maybe dozen of tft's ILI or ST chips :)
And there are 3 variants of the ST7735 chip based 1.8in tft's - red, black, green :) which differ in few ST chip settings..

I have ordered two more shields of this kind: with spfd5408 and ili9340 controllers. It should be possible to autodetect the chip in the driver.

majenko wrote:
If you want drivers to adapt that are written mainly with the pic32 in mind you can pick your way through DisplayCore: https://github.com/MajenkoLibraries/DisplayCore

Thank you for DisplayCore library - it's a great source of information.

Author:  Pito [ Wed Oct 14, 2015 10:25 am ]
Post subject:  Re: TFT LCD driver and examples

In the future it would be nice to have a template for SPI based TFTs, ie ILI9341.
There is a lot of such tfts in users junkboxes - easier to connect (less wires) :), but still good for none-video streaming apps..

Author:  vak [ Wed Oct 14, 2015 5:38 pm ]
Post subject:  Re: TFT LCD driver and examples

Pito wrote:
In the future it would be nice to have a template for SPI based TFTs, ie ILI9341.
There is a lot of such tfts in users junkboxes - easier to connect (less wires) :), but still good for none-video streaming apps..
Someday, someday.

Author:  Pito [ Wed Oct 14, 2015 10:11 pm ]
Post subject:  Re: TFT LCD driver and examples

An exercise for long winter evenings :)

Author:  majenko [ Wed Oct 14, 2015 10:40 pm ]
Post subject:  Re: TFT LCD driver and examples

They don't get those in californ-i-a.

Author:  Pito [ Wed Oct 14, 2015 10:55 pm ]
Post subject:  Re: TFT LCD driver and examples

Would a move to Alaska (or nearby Siberia) help? In Oymyakon I would be happy to sit in a small warm room writing drivers :)

Author:  majenko [ Wed Oct 14, 2015 11:12 pm ]
Post subject:  Re: TFT LCD driver and examples

Personally I'd prefer Jokkmokk. It's nice there, though the mosquitoes can be a bit of a pain in the summer (both days of it).

I speak from personal experience there...

Author:  vak [ Thu Oct 15, 2015 1:24 am ]
Post subject:  Re: TFT LCD driver and examples

You don't have to wait until I move to Oymyakon or Jokkmokk.
Just sit and write your own driver. :)
All the building blocks are already there: the SPI layer and ST7781 driver as a prototype.

Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/