Apply clang format for samples files (#833)

Apply clang format for c source files under samples folder
This commit is contained in:
Wenyong Huang
2021-11-15 12:48:35 +08:00
committed by GitHub
parent 37a14c9825
commit 3ded9ece83
58 changed files with 1261 additions and 957 deletions

View File

@ -28,9 +28,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
@ -47,22 +48,23 @@ 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 };
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;
}
int main()
int
main()
{
void display_SDL_init();
display_SDL_init();
@ -80,23 +82,26 @@ int main()
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*/
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);
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);
lv_label_set_text(label_count1, "0");
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
while(1) {
while (1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
if ((count % 100) == 0) {
snprintf(count_str, sizeof(count_str), "%d", count/ 100);
snprintf(count_str, sizeof(count_str), "%d", count / 100);
lv_label_set_text(count_label, count_str);
}
lv_task_handler();
@ -112,31 +117,41 @@ int main()
**********************/
/**
* 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);
}
extern void display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
lv_color_t color_p);
extern void display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
const lv_color_t * color_p);
static void hal_init(void)
extern void
display_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
lv_color_t color_p);
extern void
display_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
const lv_color_t *color_p);
static void
hal_init(void)
{
/* 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; /*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)*/
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; /*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
@ -144,12 +159,12 @@ static void hal_init(void)
/* Add the mouse as input device
* Use the 'mouse' driver which reads the PC's mouse*/
// mouse_init();
// mouse_init();
lv_indev_drv_t indev_drv;
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);
}