This repository was archived by the owner on Oct 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathscreen.c
More file actions
97 lines (83 loc) · 2.38 KB
/
screen.c
File metadata and controls
97 lines (83 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include "screen.h"
#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_drivers/indev/evdev.h"
#include "ui/ui.h"
#include "ui_index.h"
#define DISP_BUF_SIZE (300 * 240 * 2)
static lv_color_t buf[DISP_BUF_SIZE];
static lv_disp_draw_buf_t disp_buf;
static lv_disp_drv_t disp_drv;
static lv_indev_drv_t indev_drv;
void init_lvgl() {
lv_init();
fbdev_init();
lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
lv_disp_drv_init(&disp_drv);
disp_drv.draw_buf = &disp_buf;
disp_drv.flush_cb = fbdev_flush;
disp_drv.hor_res = 240;
disp_drv.ver_res = 300;
disp_drv.rotated = LV_DISP_ROT_270;
disp_drv.sw_rotate = true;
// disp_drv.full_refresh = true;
lv_disp_drv_register(&disp_drv);
evdev_init();
evdev_set_file("/dev/input/event1");
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = evdev_read;
lv_indev_drv_register(&indev_drv);
ui_init();
lv_label_set_text(ui_Home_Content_Ip, "...");
lv_label_set_text(ui_Home_Header_Cloud_Status_Label, "0 active");
}
void *run_lvgl_loop(void *arg) {
while(1) {
lv_timer_handler();
usleep(5000);
}
}
uint32_t 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;
}
lv_obj_t *ui_get_obj(const char *name) {
for (size_t i = 0; i < ui_objects_size; i++) {
if (strcmp(ui_objects[i].name, name) == 0) {
return *ui_objects[i].obj;
}
}
return NULL;
}
lv_img_dsc_t *ui_get_image(const char *name) {
for (size_t i = 0; i < ui_images_size; i++) {
if (strcmp(ui_images[i].name, name) == 0) {
return ui_images[i].img;
}
}
return NULL;
}
void ui_set_text(const char *name, const char *text) {
lv_obj_t *obj = ui_get_obj(name);
if(obj == NULL) {
printf("ui_set_text %s %s, obj not found\n", name, text);
return;
}
lv_label_set_text(obj, text);
}