rohmer
December 8, 2021, 5:13pm
1
So, I have upgraded to 8 and I am having an issue getting the framebuffer driver initialized and working.
As a test I wrote to /dev/fb0 and got data on the screen, so the actual device is working.
Here is my intialization:
lv_init();
fbdev_init();
/Initialize a descriptor for the buffer /
lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
/*Initialize and register a display driver*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.draw_buf = &disp_buf;
disp_drv.flush_cb = fbdev_flush;
disp_drv.hor_res = 800;
disp_drv.ver_res = 480;
lv_disp_drv_register(&disp_drv);
lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT);
I end up with nothing displaying on the screen. Im at a bit of a loss.
rohmer
December 8, 2021, 5:47pm
2
Disregard for now, seems I had a weird hybrid of v7 and v8
rohmer
December 8, 2021, 6:10pm
3
Sadly that was not it. Still same thing, I do all the init, create a window but it doesnt appear on the screen.
I can’t think of anything off the top of my head. The usual mistake is to not make disp_drv
static but you did that already. Perhaps try enabling logging and asserts; hopefully it will give a clue as to what the problem is.
rohmer
December 8, 2021, 8:31pm
5
Ill do so and report back what I find
deonm
December 9, 2021, 8:16am
6
Ditto,
My code below is similar to yours and it is working on Raspberry Pi.
deon@pi4-lcd7c:~ $ uname -a
Linux pi4-lcd7c 5.10.63-v7l+ #1496 SMP Wed Dec 1 15:58:56 GMT 2021 armv7l GNU/Linux
#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include "lv_demos/lv_demo.h"
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#define DISP_BUF_SIZE (128 * 1024)
static void hal_init(void);
static void every100ms(void);
int main(void)
{
/*LVGL init*/
lv_init();
hal_init();
/*Create a Demo*/
lv_demo_widgets();
/*Handle LVGL tasks (tickless mode)*/
while( 1 ) {
lv_task_handler();
usleep( 5000 );
static uint16_t ctr;
if( ++ctr >= 1000000/5000/10 ) {
ctr = 0;
every100ms();
}
}
return 0;
}
/*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
uint32_t app_custom_tick_get ( void )
{
static uint64_t start_ms = 0;
if( start_ms == 0 ) {
struct timeval tv_start;
gettimeofday( &tv_start, NULL );
start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
}
struct timeval tv_now;
gettimeofday( &tv_now, NULL );
uint64_t now_ms;
now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
uint32_t time_ms = now_ms - start_ms;
return time_ms;
}
#include <stdio.h>
#include <stdlib.h>
static bool backlightOn;
static uint16_t backlightOnTmr;
static bool BacklightOn ( void )
{
if( backlightOn ) return true;
backlightOn = true;
backlightOnTmr = 600;
system( "/home/deon/backlight-on.sh" );
printf( "Backlight On\n" );
return true;
}
static bool BacklightOff ( void )
{
if( !backlightOn ) return false;
backlightOn = false;
system( "/home/deon/backlight-off.sh" );
printf( "Backlight Off\n" );
return false;
}
static void every100ms(void)
{
if( backlightOnTmr )
if( !--backlightOnTmr )
BacklightOff();
}
static void _evdev_read ( lv_indev_drv_t *drv, lv_indev_data_t *data )
{
evdev_read( drv, data );
if( data->state == LV_INDEV_STATE_PRESSED ) {
if(!backlightOn)
BacklightOn();
else
backlightOnTmr = 600;
}
}
void hal_init(void)
{
/*Linux frame buffer device init*/
fbdev_init();
/*A small buffer for LVGL to draw the screen's content*/
static lv_color_t buf[ DISP_BUF_SIZE ];
/*Initialize a descriptor for the buffer*/
static lv_disp_draw_buf_t disp_buf;
lv_disp_draw_buf_init( &disp_buf, buf, NULL, DISP_BUF_SIZE );
/*Initialize and register a display driver*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init( &disp_drv );
disp_drv.draw_buf = &disp_buf;
disp_drv.flush_cb = fbdev_flush;
disp_drv.hor_res = 800;
disp_drv.ver_res = 480;
lv_disp_drv_register( &disp_drv );
lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT);
#if USE_EVDEV
BacklightOn();
evdev_init();
static lv_indev_drv_t indev_drv_touch;
lv_indev_drv_init( &indev_drv_touch );
indev_drv_touch.type = LV_INDEV_TYPE_POINTER;
indev_drv_touch.read_cb = _evdev_read;
lv_indev_drv_register( &indev_drv_touch );
#endif
}
1 Like
rohmer
December 9, 2021, 3:41pm
7
Do I have to admit my stupidity?
I wasnt calling task handler…
rohmer
December 9, 2021, 3:44pm
9
So annoying, but so norrmal, big project, lots of moving parts doing lots of cool things…
Forget something simple.