Hello
Today I will describe my LCD module driver for ST7565. This driver based on fbtft library solution created by Noralf Tronnes.
As I mentioned in a previous post the frame buffer is the intermediate layer
between higher kernel layers and video drivers. The frame
buffer provider general abstraction to handle all forms of video device.
Our device can communicate with system via different types of bus ( eg.
SPI, I2C or parallel ) therefore we have to link specific bus driver with frame
buffer interface. Below we can see "par" structure where "xxx platform
device" or "xxx spi device" can be plug in.
"xxx platform device" is a device defined in platform specific
files, used to parallel bus connection.
"xxx spi device" is a spi device driver.
"xxx spi device" is a spi device driver.
The Linux device model is based on bus and device concepts. More
information you can find o
The frame buffer is a platform specific segment of the system. The most
popular implementation for Raspberry Pi is Fbtft created by Noralf Tronnes. More information you can find here
https://github.com/notro/fbtft/wiki
I decided to use fbtft because all frame buffer interface methods are
implemented and my job was only to create a new device file with a few methods to
implement a specialized interface for st7565 driver.
The most important methods are:
- static int init_display(struct fbtft_par *par) - executed during
initialization in fbtft_register_framebuffer implemented in fbtft
library.
- static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) -
executed
during screen refreshing process. This function is taking a picture image
from video memory buffer and convert it to appropriate to display device
format. In my case video memory buffer have a format RGB 565 (16 bpp) with
screen resolution 132 x 64. Because my LCD has only two colors I convert 16 bpp
video memory format to 2bpp device format black and white. Conversion RGB
565 to 2bpp pattern is simple: zero values cast to black pixels and all the
other to white pixels.
Last thing to do is prepare fbtft_display structure, in this structure we
define parameters which are passed to fb_var_screeninfo and fb_fix_screeninfo structures.
Second thing is our device specific operation which are assigned to fbtftops
structure:
static struct fbtft_display display = {.regwidth = 8,.width = WIDTH,.height = HEIGHT,.txbuflen = TXBUFLEN,.gamma_num = 1,.gamma_len = 1,.gamma = DEFAULT_GAMMA,.fbtftops = {.init_display = init_display,.set_addr_win = set_addr_win,.set_var = set_var,.write_vmem = write_vmem,.set_gamma = set_gamma,},.backlight = 1,};
You can find all code on this repository :
https://github.com/zanaster/fbtft
Ok - and this is result of my work :
Hi Karol,
ReplyDeletefirst thanks for your effort and the fbtft fork.
Could you please post your exact wiring? I try to get an st7565 display up and running (http://www.adafruit.com/products/438). The only thing that works so far is the backlight control...
Thanks a lot.
istr
Hello istr
ReplyDeleteExact wiring - it can take a while. In general I follow the instructions from notro wiki : https://github.com/notro/fbtft/wiki/Development. Are you able to run fb_hello from this side? Did you check your SPI connection ?
I found this fb7565 very usefull, but as u have above written that 16 bpp --> 2bpp is very simple... can you give me the hint how can i do that..? because i am also using a black white display and all pixels go on when i try something..
ReplyDeleteHi
DeleteSorry for late response. I write it some time ago and I don't remember everything but as fat as I remember I used kind program like this :
http://www.hobbytronics.co.uk/bmp-lcd-converter
I'm not sure if this is what you expect, a lot of useful information about frame buffer usage can be found here: https://github.com/notro/fbtft/wiki/Framebuffer-use
hi.. thank you for the reply. I have already follwed notro and you as my resources. but thanks for the link.
Deletebut How can i implement bmp lcd library in our fb_7565.c framebuffer driver. I want the right direction to work ahead. i hope you are getting my quetion.
i found this one also as a Arduino Library but i dont know how can i integrate it in our FB driver..
Deletehttps://github.com/adafruit/ST7565-LCD
and
http://www.ladyada.net/learn/lcd/st7565.html
for your info:
I am using all this on AM335 Sitara Proce(same as Beaglebone) on Linux BSP
Now I remember it was possible to use fbi program and load images in jpg format. Did you try it?
Deleteya i have read about fbi , fbset but i cant install it directy in my linux sstem BSP... i must find a weg.. :)
Delete