summaryrefslogtreecommitdiff
path: root/tests/projects/android/native_app/lvgl_basic/src
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-16 23:50:36 +0800
committerruki <[email protected]>2025-12-16 23:50:36 +0800
commitf9c398cb56d74f4f2cd3d9f0b6f07626de65ce5e (patch)
tree3e9e61f0e6c97f6f695cdd2778cb6c9131e30383 /tests/projects/android/native_app/lvgl_basic/src
parent858fd30a65ac524600e5d3c35539d9204fbea73e (diff)
format code
Diffstat (limited to 'tests/projects/android/native_app/lvgl_basic/src')
-rw-r--r--tests/projects/android/native_app/lvgl_basic/src/main.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/tests/projects/android/native_app/lvgl_basic/src/main.c b/tests/projects/android/native_app/lvgl_basic/src/main.c
index 56518a22a..9335f60ea 100644
--- a/tests/projects/android/native_app/lvgl_basic/src/main.c
+++ b/tests/projects/android/native_app/lvgl_basic/src/main.c
@@ -32,7 +32,7 @@ static void my_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * p
int32_t width = lv_area_get_width(area);
int32_t height = lv_area_get_height(area);
-
+
// Assume 32-bit RGBA
uint32_t * dst_base = (uint32_t *)buffer.bits;
uint32_t * src = (uint32_t *)px_map;
@@ -58,7 +58,7 @@ static void create_ui(void) {
lv_label_set_text(label, "Hello Xmake + LVGL!");
lv_obj_set_style_text_font(label, &lv_font_montserrat_14, 0);
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 50);
-
+
// FPS label
lv_obj_t * label_fps = lv_label_create(lv_screen_active());
lv_label_set_text(label_fps, "FPS: 0");
@@ -74,20 +74,20 @@ static void handle_cmd(struct android_app* app, int32_t cmd) {
window_width = ANativeWindow_getWidth(native_window);
window_height = ANativeWindow_getHeight(native_window);
ANativeWindow_setBuffersGeometry(native_window, window_width, window_height, WINDOW_FORMAT_RGBA_8888);
-
+
if (!display) {
display = lv_display_create(window_width, window_height);
lv_display_set_color_format(display, LV_COLOR_FORMAT_ARGB8888);
lv_display_set_flush_cb(display, my_flush_cb);
-
+
size_t buf_size = window_width * window_height * 4;
void * buf = malloc(buf_size);
lv_display_set_buffers(display, buf, NULL, buf_size, LV_DISPLAY_RENDER_MODE_FULL);
-
+
lv_indev_t * indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_input_read);
-
+
create_ui();
} else {
lv_display_set_resolution(display, window_width, window_height);
@@ -117,10 +117,10 @@ static int32_t handle_input(struct android_app* app, AInputEvent* event) {
void android_main(struct android_app* app) {
lv_init();
-
+
app->onAppCmd = handle_cmd;
app->onInputEvent = handle_input;
-
+
int frame_count = 0;
time_t last_time = time(NULL);
@@ -128,26 +128,26 @@ void android_main(struct android_app* app) {
int ident;
int events;
struct android_poll_source* source;
-
+
uint32_t timeout = lv_timer_handler();
if (timeout > 50) timeout = 50;
-
+
while ((ident = ALooper_pollAll(timeout, NULL, &events, (void**)&source)) >= 0) {
if (source != NULL) source->process(app, source);
if (app->destroyRequested != 0) return;
}
-
+
lv_tick_inc(timeout);
frame_count++;
- time_t current_time = time(NULL);
- if (current_time - last_time >= 1) {
- lv_obj_t * label_fps = lv_obj_get_child(lv_screen_active(), 1); // 0: label, 1: fps
- if (label_fps) {
- lv_label_set_text_fmt(label_fps, "FPS: %d", frame_count);
- }
- frame_count = 0;
- last_time = current_time;
- }
+ time_t current_time = time(NULL);
+ if (current_time - last_time >= 1) {
+ lv_obj_t * label_fps = lv_obj_get_child(lv_screen_active(), 1); // 0: label, 1: fps
+ if (label_fps) {
+ lv_label_set_text_fmt(label_fps, "FPS: %d", frame_count);
+ }
+ frame_count = 0;
+ last_time = current_time;
+ }
}
}