using libgpio to bitbang LCDs!

Milan Obuch freebsd-arch at dino.sk
Mon Apr 27 12:13:12 UTC 2015


On Mon, 27 Apr 2015 12:48:41 +0200
Milan Obuch <freebsd-arch at dino.sk> wrote:

> On Sat, 11 Apr 2015 23:45:55 -0700
> Adrian Chadd <adrian at freebsd.org> wrote:
> 
> > Hi,
> > 
> > The library source code and a demo program is available here:
> > 
> > https://github.com/erikarn/freebsd-liblcd
> > 
> > It includes the wiring needed to hook the example OLED board up
> > (http://www.adafruit.com/products/684) to a Carambola 2 evaluation
> > board.
> > 
> > Anything you can get 5v and 5 GPIO pins from will work. (Well, as
> > long as there's also libgpio / gpio API support for your device..)
> > 
> > 
> > 
> > -adrian
> >
> 
> Hi,
> 
> I downloaded master.zip from github and now I am trying to modify it
> for my hardware - Raspberry PI and TFT display with ILI9341 chip
> https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi
> My original attempt to use SPI failed probably because ILI9341 does
> not use pure SPI, but there is one extension - DC pin. I did not
> manage to satisfy chip's timing/bit sequence/whatever, so I would
> like to try bit banging.
> 
> I found two small issues with archive downloaded -
> freebsd-liblcd-master/src/beastie_ili9340c_320x240/Makefile seems to
> ba a copy of
> freebsd-liblcd-master/src/beastie_ssd1351_128x128/Makefile, I think
> there should be a difference, after my fix
> 
> --- beastie_ili9340c_320x240/Makefile   2015-04-23 21:40:10.693847000
> +0200 +++ beastie_ssd1351_128x128/Makefile    2015-04-13
> 00:58:06.000000000 +0200 @@ -3,7 +3,7 @@
>  
>  .include <bsd.own.mk>
>  
> -PROG=beastie_ili9340c_320x240
> +PROG=beastie_ssd1351_128x128
>  SRCS=main.c
>  CFLAGS+=-I../../lib/liblcd
>  LDFLAGS+=-L../../lib/liblcd
> 
> 
> The second issue is when doing 'make install' binaries produced are
> being installed into / directory. While both are not fatal for me,
> they are annoyances at least.
> 
> I found following in source files:
> 
>         /* Configured for the carambola 2 board */
>         cfg.gpio_unit = 0;
>         cfg.pin_cs = 19;
>         cfg.pin_rst = 20;
>         cfg.pin_dc = 21;
>         cfg.pin_sck = 22;
>         cfg.pin_mosi = 23;
> 
> I see there no 'pin_miso', so does this mean only one directional
> communication is being used, no status reading, or both reading and
> writing are being carried over one pin? If the former, then all I
> should to do is change pin numbers in above given excerption to ones
> valid for Raspberry Pi, if the later, I can't use this without more
> modifications.
> 
> Also, I have simple monochrome display with PCD8544 chip, which should
> use basically the same bus design, so it could be used for this too,
> with some modification.
> 
> Regards,
> Milan
>

I decided just to try it. I copied
freebsd-liblcd-master/src/beastie_ili9340c_320x240 to
freebsd-liblcd-master/src/beastie_ili9340c_320x240-1, just to keep
things clean (and be able to revert easy if I screw something too much)
and changed configuration lines mentioned above to

        /* Configured for the Raspberry Pi board */
        cfg.gpio_unit = 0;
        cfg.pin_cs = 8;
        cfg.pin_rst = 0;
        cfg.pin_dc = 25;
        cfg.pin_sck = 11;
        cfg.pin_mosi = 10;

and it works, a bit slowly, but this could be expected. Also note there
is no reset pin connected in my display, so I put there 0, which may
not be the best value, but it works. One more issue here - picture is
turned upside down, I have four buttons below screen and I need to turn
the display to be normally readable so they are on top... but this is
not hard to solve... I can use this display now, it is slow, but works.

Regards,
Milan


More information about the freebsd-arch mailing list