Apply clang format for samples files (#833)
Apply clang format for c source files under samples folder
This commit is contained in:
@ -11,25 +11,32 @@
|
||||
#include "lvgl/lv_misc/lv_color.h"
|
||||
#include "lvgl/lv_hal/lv_hal_indev.h"
|
||||
|
||||
extern void display_init(void);
|
||||
extern void
|
||||
display_init(void);
|
||||
|
||||
extern void display_deinit(void);
|
||||
extern void
|
||||
display_deinit(void);
|
||||
|
||||
extern void display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color);
|
||||
extern void
|
||||
display_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color);
|
||||
|
||||
extern bool display_input_read(lv_indev_data_t *data);
|
||||
extern bool
|
||||
display_input_read(lv_indev_data_t *data);
|
||||
|
||||
extern void display_vdb_write(void *buf,
|
||||
lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t *color, lv_opa_t opa);
|
||||
extern void
|
||||
display_vdb_write(void *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t *color, lv_opa_t opa);
|
||||
|
||||
void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color);
|
||||
void
|
||||
display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color);
|
||||
|
||||
void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color);
|
||||
void
|
||||
display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color);
|
||||
|
||||
extern uint32_t time_get_ms(void);
|
||||
extern uint32_t
|
||||
time_get_ms(void);
|
||||
|
||||
#endif
|
||||
|
||||
@ -29,9 +29,10 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void hal_init(void);
|
||||
//static int tick_thread(void * data);
|
||||
//static void memory_monitor(void * param);
|
||||
static void
|
||||
hal_init(void);
|
||||
// static int tick_thread(void * data);
|
||||
// static void memory_monitor(void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@ -48,13 +49,14 @@ uint32_t count = 0;
|
||||
char count_str[11] = { 0 };
|
||||
lv_obj_t *hello_world_label;
|
||||
lv_obj_t *count_label;
|
||||
lv_obj_t * btn1;
|
||||
lv_obj_t *btn1;
|
||||
|
||||
lv_obj_t * label_count1;
|
||||
lv_obj_t *label_count1;
|
||||
int label_count1_value = 0;
|
||||
char label_count1_str[11] = { 0 };
|
||||
|
||||
void timer1_update(user_timer_t timer1)
|
||||
void
|
||||
timer1_update(user_timer_t timer1)
|
||||
{
|
||||
if ((count % 100) == 0) {
|
||||
snprintf(count_str, sizeof(count_str), "%d", count / 100);
|
||||
@ -64,23 +66,23 @@ void timer1_update(user_timer_t timer1)
|
||||
++count;
|
||||
}
|
||||
|
||||
|
||||
static lv_res_t btn_rel_action(lv_obj_t * btn)
|
||||
static lv_res_t
|
||||
btn_rel_action(lv_obj_t *btn)
|
||||
{
|
||||
label_count1_value++;
|
||||
snprintf(label_count1_str, sizeof(label_count1_str),
|
||||
"%d", label_count1_value);
|
||||
snprintf(label_count1_str, sizeof(label_count1_str), "%d",
|
||||
label_count1_value);
|
||||
lv_label_set_text(label_count1, label_count1_str);
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
void on_init()
|
||||
void
|
||||
on_init()
|
||||
{
|
||||
/*Initialize LittlevGL*/
|
||||
/* Initialize LittlevGL */
|
||||
lv_init();
|
||||
|
||||
/*Initialize the HAL (display, input devices, tick) for LittlevGL*/
|
||||
/* Initialize the HAL (display, input devices, tick) for LittlevGL */
|
||||
hal_init();
|
||||
|
||||
hello_world_label = lv_label_create(lv_scr_act(), NULL);
|
||||
@ -90,12 +92,17 @@ void on_init()
|
||||
count_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(count_label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
|
||||
|
||||
btn1 = lv_btn_create(lv_scr_act(), NULL); /*Create a button on the currently loaded screen*/
|
||||
lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK, btn_rel_action); /*Set function to be called when the button is released*/
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 20); /*Align below the label*/
|
||||
btn1 = lv_btn_create(
|
||||
lv_scr_act(),
|
||||
NULL); /* Create a button on the currently loaded screen */
|
||||
lv_btn_set_action(btn1, LV_BTN_ACTION_CLICK,
|
||||
btn_rel_action); /* Set function to be called when the
|
||||
button is released */
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0,
|
||||
20); /* Align below the label */
|
||||
|
||||
/*Create a label on the button*/
|
||||
lv_obj_t * btn_label = lv_label_create(btn1, NULL);
|
||||
/* Create a label on the button */
|
||||
lv_obj_t *btn_label = lv_label_create(btn1, NULL);
|
||||
lv_label_set_text(btn_label, "Click ++");
|
||||
|
||||
label_count1 = lv_label_create(lv_scr_act(), NULL);
|
||||
@ -116,56 +123,67 @@ void on_init()
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
|
||||
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics
|
||||
* library
|
||||
*/
|
||||
void display_flush_wrapper(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t * color_p)
|
||||
void
|
||||
display_flush_wrapper(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
const lv_color_t *color_p)
|
||||
{
|
||||
display_flush(x1, y1, x2, y2, color_p);
|
||||
lv_flush_ready();
|
||||
}
|
||||
|
||||
void display_vdb_write_wrapper(uint8_t *buf,
|
||||
lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
void
|
||||
display_vdb_write_wrapper(uint8_t *buf, lv_coord_t buf_w, lv_coord_t x,
|
||||
lv_coord_t y, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
display_vdb_write(buf, buf_w, x, y, &color, opa);
|
||||
}
|
||||
|
||||
void display_fill_wrapper(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color)
|
||||
void
|
||||
display_fill_wrapper(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
lv_color_t color)
|
||||
{
|
||||
display_fill(x1, y1, x2, y2, &color);
|
||||
}
|
||||
|
||||
static void hal_init(void)
|
||||
static void
|
||||
hal_init(void)
|
||||
{
|
||||
/* Add a display*/
|
||||
/* Add a display */
|
||||
lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
disp_drv.disp_flush = display_flush_wrapper; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/
|
||||
disp_drv.disp_fill = display_fill_wrapper; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/
|
||||
disp_drv.disp_map = display_map; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/
|
||||
lv_disp_drv_init(&disp_drv); /* Basic initialization */
|
||||
disp_drv.disp_flush =
|
||||
display_flush_wrapper; /* Used when `LV_VDB_SIZE != 0` in lv_conf.h
|
||||
(buffered drawing) */
|
||||
disp_drv.disp_fill =
|
||||
display_fill_wrapper; /* Used when `LV_VDB_SIZE == 0` in lv_conf.h
|
||||
(unbuffered drawing) */
|
||||
disp_drv.disp_map = display_map; /* Used when `LV_VDB_SIZE == 0` in
|
||||
lv_conf.h (unbuffered drawing) */
|
||||
#if LV_VDB_SIZE != 0
|
||||
disp_drv.vdb_wr = display_vdb_write_wrapper;
|
||||
#endif
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
/* Add the mouse as input device
|
||||
* Use the 'mouse' driver which reads the PC's mouse*/
|
||||
// mouse_init();
|
||||
* Use the 'mouse' driver which reads the PC's mouse */
|
||||
// mouse_init();
|
||||
lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
lv_indev_drv_init(&indev_drv); /* Basic initialization */
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read = display_input_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
|
||||
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||
indev_drv.read =
|
||||
display_input_read; /* This function will be called periodically (by the
|
||||
library) to get the mouse position and state */
|
||||
lv_indev_t *mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
|
||||
/* Implement empry main function as wasi start function calls it */
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -5,4 +5,5 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
uint32_t time_get_ms(void);
|
||||
uint32_t
|
||||
time_get_ms(void);
|
||||
|
||||
Reference in New Issue
Block a user