eBook reader

The place to share and discuss your Ultibo projects.
hippy
Posts: 33
Joined: Tue Jan 02, 2018 5:54 pm
Location: UK

Re: eBook reader

Postby hippy » Fri Apr 05, 2019 6:24 pm

Gavinmc42 wrote:Just guessing, but it looks like SPI based 8 bit shift registers converting to the 16/18bit parallel LCD bus.

Looks like other 3.5" LCD's I've seen from WaveShare and the like. If it's based on the ILI9486 (LCD) /XPT2046 (Touch) chipset then it's a doddle to drive.

There is a fair amount of code out there for bit-banging and framebuffer drivers (fbtft) to use and build upon. I have just spent half a day writing code to bit-bang a bitmap out using Python on Rasbian via RPi.GPIO. Haven't cracked making 'spidev' work so it's bit-banged SPI so 'dog slow', but should zing along using bare-metal or Ultibo.
Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Sat Apr 06, 2019 12:20 am

Ron was the first to bit bang LCD, going right back to the start of Ultibo.
viewtopic.php?f=13&t=101&p=232&hilit=LCD#p232

I think there is a Free Pascal GPIO library, could it be done in Raspbian and Laz/fpc too?
This is my first IPS LCD, was interested in seeing what it looked like before spending much more on a HDMI version which should just work with Ultibo.
Touch via SPI or touch via USB are problematic in Ultibo.

Of course the Pi LCD just works and after playing with three this week at work, that is looking even easier to test.
Which I only just thought of :oops: Tunnel vision ;)
Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Sat Apr 06, 2019 6:35 am

Was installing on Raspbian Lite, no x11 so no calibration stuff for the touch screen.
Had not thought about this, if I do OpenVG there is no x11 so all the normal install stuff won't work.
Ok text mode is working in Raspbian Lite.

Was hoping for pocket size eReader using a Zero W.
Might have to stick with the 7" Official LCD for the prototype.
Then I may as well use a 3A+ and make it a mini Laptop.

Hey check this out, is it using dispmanx?
Does that mean these LCDs are supported in the start.elf?
All the rest just seems to be overlay and touch stuff?

Code: Select all

#include <stdio.h>
#include <syslog.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>

#include <bcm_host.h>

int process() {
    DISPMANX_DISPLAY_HANDLE_T display;
    DISPMANX_MODEINFO_T display_info;
    DISPMANX_RESOURCE_HANDLE_T screen_resource;
    VC_IMAGE_TRANSFORM_T transform;
    uint32_t image_prt;
    VC_RECT_T rect1;
    int ret;
    int fbfd = 0;
    char *fbp = 0;

    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;


    bcm_host_init();

    display = vc_dispmanx_display_open(0);
    if (!display) {
        syslog(LOG_ERR, "Unable to open primary display");
        return -1;
    }
    ret = vc_dispmanx_display_get_info(display, &display_info);
    if (ret) {
        syslog(LOG_ERR, "Unable to get primary display information");
        return -1;
    }
    syslog(LOG_INFO, "Primary display is %d x %d", display_info.width, display_info.height);


    fbfd = open("/dev/fb1", O_RDWR);
    if (fbfd == -1) {
        syslog(LOG_ERR, "Unable to open secondary display");
        return -1;
    }
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
        syslog(LOG_ERR, "Unable to get secondary display information");
        return -1;
    }
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
        syslog(LOG_ERR, "Unable to get secondary display information");
        return -1;
    }

    syslog(LOG_INFO, "Second display is %d x %d %dbps\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);

    screen_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, vinfo.xres, vinfo.yres, &image_prt);
    if (!screen_resource) {
        syslog(LOG_ERR, "Unable to create screen buffer");
        close(fbfd);
        vc_dispmanx_display_close(display);
        return -1;
    }

    fbp = (char*) mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
    if (fbp <= 0) {
        syslog(LOG_ERR, "Unable to create mamory mapping");
        close(fbfd);
        ret = vc_dispmanx_resource_delete(screen_resource);
        vc_dispmanx_display_close(display);
        return -1;
    }

    vc_dispmanx_rect_set(&rect1, 0, 0, vinfo.xres, vinfo.yres);

    while (1) {
        ret = vc_dispmanx_snapshot(display, screen_resource, 0);
        vc_dispmanx_resource_read_data(screen_resource, &rect1, fbp, vinfo.xres * vinfo.bits_per_pixel / 8);
        usleep(25 * 1000);
    }

    munmap(fbp, finfo.smem_len);
    close(fbfd);
    ret = vc_dispmanx_resource_delete(screen_resource);
    vc_dispmanx_display_close(display);
}

int main(int argc, char **argv) {
    setlogmask(LOG_UPTO(LOG_DEBUG));
    openlog("fbcp", LOG_NDELAY | LOG_PID, LOG_USER);

    return process();
}


Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Sat Apr 06, 2019 11:10 am

A link to the Project Looking Glass
https://en.wikipedia.org/wiki/Project_Looking_Glass

Eventually got me to here.
https://en.wikipedia.org/wiki/Vector-ba ... _interface
Now I know what type my UI is :D

Do I remember right, OpenVG can be used as a texture on 3D shapes?
Project Looking Glass could be done on Pi's?
The more I learn the more I don't know.
Don't know how to do it but know enough to believe this is possible :D

Chew on a small piece at a time?
Got the Pragmatic Programmer book, need to learn to code much better.
Returned the Art of Programming vol4a, er was not ready for that, perhaps in my the next life?

The Dragon book?
Ok that helped me figure out an OS is not what I need now but the glue, something like Bash is next.
Still should be useful to learn about compilers/interpreters etc.
User avatar
Ultibo
Site Admin
Posts: 2217
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: eBook reader

Postby Ultibo » Sat Apr 06, 2019 11:24 pm

Gavinmc42 wrote:Hey check this out, is it using dispmanx?
Does that mean these LCDs are supported in the start.elf?

SPI based LCDs are not supported by the VC4, the only thing it can output to is a DispmanX layer.

What you see in that piece of code is copying the pixels from DispmanX to a framebuffer which is then written to the LCD.

The key line is here:

Code: Select all

    while (1) {
        ret = vc_dispmanx_snapshot(display, screen_resource, 0);

You can use vc_dispmanx_snapshot() in Ultibo to copy an OpenGL ES or OpenVG output to an SPI framebuffer (or something else for that matter, like a screenshot), the complete DispmanX API is supported and usable.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Sun Apr 07, 2019 12:56 am

What you see in that piece of code is copying the pixels from DispmanX to a framebuffer which is then written to the LCD.

Thanks Garry, would that be the ARM doing the copying from the framebuffer?
DPI? would that use the VC4?
Time to get one and find out.
I saw a French $10 PCB for a Zero based mini terminal with tiny keyboard.
It could be using DPI?

Edit - https://liliputing.com/2019/03/this-10- ... splay.html

Been having a look at lots of LCD interfaces, seems like they use all sorts and need to make drivers for them.
The driver for this one is a bit weird, defaults to a white screen, backlight on, all pixels on?

The HDMI version uses a chip that takes the HDMI and converts to parallel LCD.
Adding these chips means adding cost and reducing cloning.
So far I have found two different HDMI driver chips.
I think the only thing needed to use them is setting the resolution etc in the config.txt.

SPI or USB touch will be trouble.
The HDMI/USB say they are for other computers not just Pi's, HID mouse emulation?

To make a pocket size eReader, Zero + DPI LCD?
Put that on the back burner while I use the Pi LCD and model 3A+ for software testing ;)
Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Sun Apr 07, 2019 1:47 am

Carrying HDMI and USB input to the "nex" level
https://www.kickstarter.com/projects/ne ... ref=97jyun

Will these be everywhere one day?
One way to turn a Pi into a Desktop/Laptop ;)
User avatar
Ultibo
Site Admin
Posts: 2217
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: eBook reader

Postby Ultibo » Sun Apr 07, 2019 11:45 pm

Gavinmc42 wrote:would that be the ARM doing the copying from the framebuffer?

Yes it looks like it is (would need to follow the userland code to be sure) since the passed buffer has been mem mapped from Linux.

Gavinmc42 wrote:DPI? would that use the VC4?

Both DPI and DSI seem to be driven directly from the VC4 firmware. In theory it would be possible for the firmware to drive an SPI display but it wouldn't be much point given the speed of the SPI bus,

Gavinmc42 wrote:SPI or USB touch will be trouble.
The HDMI/USB say they are for other computers not just Pi's, HID mouse emulation?

An SPI touch screen driver shouldn't be any more difficult to implement than an I2C based one (which we have a couple of already), the Texas Instruments ADS7846 is one which is used regularly and we probably will support if we have a reason to write the driver. As for USB touch we think one of the most important future additions to Ultibo will be generic HID drivers for keyboard, mouse, gamepad and touch which would make many of these touchscreens automatically usable.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Mon Apr 08, 2019 1:04 am

future additions to Ultibo will be generic HID drivers for keyboard, mouse, gamepad and touch

Ouch, USB drivers, such fun ;)
I did notice in the code the word "joystick", which for touch probably makes sense as it would needs absolute positioning on the screen.
In Linux it uses overlays etc

The install script does a bunch of things apart from copying the binary exe file fbcp.
It is a generic one for all their displays and copies the screen res into the config.txt etc.
Tried to install on my other fav Linux PiCore but it's way too different.

Install scripts are ok for one particular OS to make it easy for users, but they blowup when used on different distributions,
It's all learning ;)
Gavinmc42
Posts: 1595
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: eBook reader

Postby Gavinmc42 » Mon Apr 08, 2019 10:54 am

I think I have linked this before, but perhaps on the Pi Forums?
http://www.pp4s.co.uk/main/tu-trans-comp-jc-intro.html

Finally sat down and starting working through the Tuts.
I got up to Parse07 then it clicked, hey this is the code I need for the Steam Punk OS Calculator.
Section IV is Interpreters and Compilers are a bit later, section X on.
I also learned how to generate x86 assembler ;) er i think it is x86 ;)
Plus there is a Tiny IDE :o http://www.pp4s.co.uk/main/tu-trans-comp-jc-pi-ide.html

But wait there is more, Calculator code
http://www.pp4s.co.uk/main/tu-trans-interp.html

Had another look, PascalScript is too much for me to chew on, still learning the basics.

There is also the Free Pascal stuff which is now making a bit more sense.
Flc-passrc is already in Ultibo.
http://wiki.freepascal.org/Make_your_ow ... n_analyzer
I suspect regexpr may also be useful, what else is already in the Ultibo toolbox of parts?

http://wiki.freepascal.org/fcl-base
A bunch of parsers that do???
RTFparser? Hmm RTF fileformat, that will be handy ;)

Might be running out of enough years to learn all this ;)
Of course without Ultibo I would still be trying to figure out stubs, memory registers, threads, mutexes and other horrible stuff ;)

Edit -Still looking
https://ultibo.org/wiki/Current_Status
fcl-js - yep that does look like a Javascript parser :o
https://github.com/graemeg/freepascal/t ... ges/fcl-js

The RTFparser is HTML aware, fcl-js is Javascript = minibrowser?
So many pieces in Ultibo, gluing them all together, any Laz/FPC examples?
These libraries don't just magically appear, someone uses them to make stuff.
2+ years into Ultibo and I'm not even close to using all the pieces.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 0 guests