I want to include LvGL-9.3.0 in my custom x86_64 OS. I build that version. Now I want to test it in my OS. Currently My VGA Driver has following
void set_pixel(int x, int y, uint32_t color);
void *get_fb0_address();
uint64_t get_fb0_width();
uint64_t get_fb0_height();
uint64_t get_fb0_pitch();
uint16_t get_fb0_bpp();
I have this for testing :
#include "../../lib/time.h"
#include "../../lib/stdio.h"
#include "../../memory/kheap.h"
#include "../../sys/timer/tsc.h"
#include "../../lib/time.h"
#include "../../driver/vga/vga.h"
#include "../../../../ext_lib/lvgl-9.3.0/lvgl.h"
#include "../../../../ext_lib/lvgl-9.3.0/src/display/lv_display.h"
#include "lvgl_fb.h"
#define BUF_WIDTH 640
#define BUF_HEIGHT 480
#define BUF_SIZE (BUF_WIDTH * BUF_HEIGHT)
lv_color_t *buf;
static void flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map) {
int32_t x, y;
for (y = area->y1; y <= area->y2; y++) {
for (x = area->x1; x <= area->x2; x++) {
// Extract color value from px_map (format depends on LV_COLOR_DEPTH)
uint32_t color = *((uint32_t *)px_map);
set_pixel(x, y, color);
px_map += LV_COLOR_FORMAT_NATIVE_WITH_ALPHA / 8; // Move to next pixel
}
}
lv_display_flush_ready(disp); // Notify LVGL that flushing is complete
}
int lvgl_test() {
lv_init();
printf("BUF_SIZE: %d\n", BUF_SIZE);
buf = (lv_color_t *)kheap_alloc(BUF_SIZE * sizeof(lv_color_t), ALLOCATE_DATA);
lv_display_t *disp = lv_display_create(640, 480);
lv_display_set_flush_cb(disp, flush_cb);
lv_display_set_buffers(disp, buf, NULL, BUF_SIZE * sizeof(lv_color_t), LV_DISPLAY_RENDER_MODE_FULL);
// Create UI
lv_obj_t *label = lv_label_create(lv_screen_active());
lv_label_set_text(label, "LVGL on VGA!");
lv_obj_center(label);
while (1) {
lv_timer_handler();
usleep(0, 5000);
}
}
But unfortunetly it is not working.
Output:
BUF_SIZE: 307200
Received Interrupt : 6
Invalid Opcode
Error Code : 0
System Halted!
Can anyone help me to find a solution?