LittlevGL, uGFX, create GUI apps for Linux framebuffer
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
LittlevGL, uGFX, create GUI apps for Linux framebuffer
Perhaps this topic is not "off topic", as my intention is to be able to create a GUI app, statically compiled, that will run in the initramfs. An example would be a keyboard-layout selector and/or a password-entry app, in the initramfs before the main Puppy filesystem starts up.
On the desktop, LittlevGL and uGFX use SDL2, so perhaps, not really sure, but it might be possible to create reasonably small static apps for the desktop.
I had some feedback from technosaurus about what is out there, for creating GUI apps that will run on the framebuffer:
http://bkhome.org/news/201808/gui-creat ... uffer.html
I have started to evaluate LittlevGL:
http://bkhome.org/news/201808/first-go- ... levgl.html
http://bkhome.org/news/201808/tentative ... levgl.html
regarding uGFX, have not yet done a hands-on, but have posted info:
http://bkhome.org/news/201808/considering-ugfx.html
I think that this is a very interesting topic, and perhaps others who hang out on this forum will also find it interesting, so have started this thread...
On the desktop, LittlevGL and uGFX use SDL2, so perhaps, not really sure, but it might be possible to create reasonably small static apps for the desktop.
I had some feedback from technosaurus about what is out there, for creating GUI apps that will run on the framebuffer:
http://bkhome.org/news/201808/gui-creat ... uffer.html
I have started to evaluate LittlevGL:
http://bkhome.org/news/201808/first-go- ... levgl.html
http://bkhome.org/news/201808/tentative ... levgl.html
regarding uGFX, have not yet done a hands-on, but have posted info:
http://bkhome.org/news/201808/considering-ugfx.html
I think that this is a very interesting topic, and perhaps others who hang out on this forum will also find it interesting, so have started this thread...
[url]https://bkhome.org/news/[/url]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
Re: LittlevGL, uGFX, create GUI apps for Linux framebuffer
Disregard that paragraph. It is just wishful thinking. I don't see how a "reasonably sized" statically-linked GUI app can be created for the desktop.BarryK wrote:On the desktop, LittlevGL and uGFX use SDL2, so perhaps, not really sure, but it might be possible to create reasonably small static apps for the desktop.
But, direct to the framebuffer in the initramfs, or anywhere you want to run just one small GUI app, no X.
[url]https://bkhome.org/news/[/url]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
Regarding LittlevGL, I couldn't see how to add mouse support, without SDL, running without X, so posted a question to the developer's github:
https://github.com/littlevgl/lvgl/issues/374
Helpful responses. 'kisvegabor' is the main developer guy.
His comment:
https://github.com/littlevgl/lvgl/issues/374
Helpful responses. 'kisvegabor' is the main developer guy.
His comment:
...I will need to think about that.Keep in mind, AFAIK, in command line mode (if you kill Xorg) the evdev's are not working by default.
[url]https://bkhome.org/news/[/url]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
With help from a couple of guys at the LVGL developer site, got it figured out. Now have mouse working, see photo.
Have posted review part 3:
http://bkhome.org/news/201808/littlevgl ... art-3.html
Have posted review part 3:
http://bkhome.org/news/201808/littlevgl ... art-3.html
- Attachments
-
- lvgl-demo3.jpg
- (46.36 KiB) Downloaded 910 times
[url]https://bkhome.org/news/[/url]
Why not use a ncurses type interface. Along with gpm so that the mouse works in the console ... and its not too bad. For instance with gpm server loaded in FatDog, running mc in a console window and using the mouse to navigate around the menus/files ... works well.
[size=75]( ͡° ͜ʖ ͡°) :wq[/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
Yes, that is the alternative, but of course is a text-mode UI.rufwoof wrote:Why not use a ncurses type interface. Along with gpm so that the mouse works in the console ... and its not too bad. For instance with gpm server loaded in FatDog, running mc in a console window and using the mouse to navigate around the menus/files ... works well.
With LittlevGL we have all the graphical goodies, such as images, translucency, antialiased fonts, well, it does about everything you are able to do in a gtk/qt app.
So I guess it is a question of how you want to present your product.
[url]https://bkhome.org/news/[/url]
Simple example of adding a fb image to the console i.e. gcc it and run it under a ctrl-alt-Fn console terminal. This just draws a box with colour scaling, but could be any size/location/image ...
Merged with a basic mouse pointer position/click detection within a while loop ...etc. and potentially lightweight
Compiles to a 7.6K sized binary under FatDog.
Merged with a basic mouse pointer position/click detection within a while loop ...etc. and potentially lightweight
Compiles to a 7.6K sized binary under FatDog.
Code: Select all
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
// Open the file for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (fbfd == -1) {
perror("Error: cannot open framebuffer device");
exit(1);
}
// printf("The framebuffer device was opened successfully.\n");
// Get fixed screen information
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) {
perror("Error reading fixed information");
exit(2);
}
// Get variable screen information
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
perror("Error reading variable information");
exit(3);
}
// printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
// Figure out the size of the screen in bytes
// screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
screensize = vinfo.xres_virtual * vinfo.yres_virtual * (vinfo.bits_per_pixel / 8);
// Map the device to memory
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
if ((int)fbp == -1) {
perror("Error: failed to map framebuffer device to memory");
exit(4);
}
// printf("The framebuffer device was mapped to memory successfully.\n");
x = 100; y = 100; // Where we are going to put the pixel
// Figure out where in memory to put the pixel
for (y = 100; y < 300; y++)
for (x = 100; x < 300; x++) {
location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
(y+vinfo.yoffset) * finfo.line_length;
if (vinfo.bits_per_pixel == 32) {
*(fbp + location) = 100; // Some blue
*(fbp + location + 1) = 15+(x-100)/2; // A little green
*(fbp + location + 2) = 200-(y-100)/5; // A lot of red
*(fbp + location + 3) = 0; // No transparency
//location += 4;
} else { //assume 16bpp
int b = 10;
int g = (x-100)/6; // A little green
int r = 31-(y-100)/16; // A lot of red
unsigned short int t = r<<11 | g << 5 | b;
*((unsigned short int*)(fbp + location)) = t;
}
}
munmap(fbp, screensize);
close(fbfd);
return 0;
}
[size=75]( ͡° ͜ʖ ͡°) :wq[/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
Under-Pup is another option. In the past I've had a 70MB - 80MB or so thin pup that booted to a gui/X desktop that then dropped itself to be replaced with another fuller version. I was using that to pull down a larger puppy sfs over the net such that the main pup could be centrally managed/updated once, applied to many. IIRC I used X-vesa for that first layered pup for the greater simplicity/diversity of supported hardware.
IIRC got the idea from one of your older blog postings that I believe have since been lost/deleted. Not sure you called it Under-Pup, but was some name like that.
IIRC got the idea from one of your older blog postings that I believe have since been lost/deleted. Not sure you called it Under-Pup, but was some name like that.
[size=75]( ͡° ͜ʖ ͡°) :wq[/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
Just tried running vlc to watch a mp4 in a console session (under FatDog) and surprised to see it work so well, sound played OK also.
[size=75]( ͡° ͜ʖ ͡°) :wq[/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
[url=http://murga-linux.com/puppy/viewtopic.php?p=1028256#1028256][size=75]Fatdog multi-session usb[/url][/size]
[size=75][url=https://hashbang.sh]echo url|sed -e 's/^/(c/' -e 's/$/ hashbang.sh)/'|sh[/url][/size]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
That would be Underdog!rufwoof wrote:Under-Pup is another option. In the past I've had a 70MB - 80MB or so thin pup that booted to a gui/X desktop that then dropped itself to be replaced with another fuller version. I was using that to pull down a larger puppy sfs over the net such that the main pup could be centrally managed/updated once, applied to many. IIRC I used X-vesa for that first layered pup for the greater simplicity/diversity of supported hardware.
IIRC got the idea from one of your older blog postings that I believe have since been lost/deleted. Not sure you called it Under-Pup, but was some name like that.
Mentioned here:
http://bkhome.org/archive/puppylinux/de ... works.html
Mentioned on forum:
http://murga-linux.com/puppy/viewtopic.php?t=13750
The Underdog concept started in Jan. 2006:
http://bkhome.org/archive/blog1/news2006a.htm
[url]https://bkhome.org/news/[/url]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
LittlevGL is really just the same, but with bells and whistles.rufwoof wrote:Simple example of adding a fb image to the console i.e. gcc it and run it under a ctrl-alt-Fn console terminal. This just draws a box with colour scaling, but could be any size/location/image ...
Merged with a basic mouse pointer position/click detection within a while loop ...etc. and potentially lightweight
Compiles to a 7.6K sized binary under FatDog.
It has code like that for writing to the framebuffer.
For input, reads /dev/input/event# directly, gpm not needed.
I have hit a limitation, the developer has mostly designed LVGL for touch input, including for evdev. I have posted how he could expand that and include keyboard input:
https://github.com/littlevgl/lvgl/issues/377
What I am creating is a password entry app for the initrd. LVGL has a nice customizable on-screen keyboard, that works nice with a mouse, but I want it to work from a real keyboard also.
[url]https://bkhome.org/news/[/url]
- BarryK
- Puppy Master
- Posts: 9392
- Joined: Mon 09 May 2005, 09:23
- Location: Perth, Western Australia
- Contact:
I posted about LVGL in technosaurus's thread "Unbloated coding resources", about a limitation of LVGL:
http://murga-linux.com/puppy/viewtopic. ... 07#1003207
The limitation is that there is no keyboard support via evdev (only mouse and touchpad).
http://murga-linux.com/puppy/viewtopic. ... 07#1003207
The limitation is that there is no keyboard support via evdev (only mouse and touchpad).
[url]https://bkhome.org/news/[/url]