chore: update some code and docs to use v9 API (#5876)

Co-authored-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
zylalx1
2024-04-10 15:17:44 +08:00
committed by GitHub
parent 0143320f1f
commit 47ec2784d8
54 changed files with 115 additions and 117 deletions

View File

@@ -47,7 +47,7 @@ void my_disp_flush( lv_display_t *disp, const lv_area_t *area, uint8_t * px_map)
*/
/*Call it to tell LVGL you are ready*/
lv_disp_flush_ready(disp);
lv_display_flush_ready(disp);
}
/*Read the touchpad*/
@@ -112,7 +112,7 @@ void setup()
/* Create a simple label
* ---------------------
lv_obj_t *label = lv_label_create( lv_scr_act() );
lv_obj_t *label = lv_label_create( lv_screen_active() );
lv_label_set_text( label, "Hello Arduino, I'm LVGL!" );
lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );
@@ -129,7 +129,7 @@ void setup()
lv_demo_widgets();
*/
lv_obj_t *label = lv_label_create( lv_scr_act() );
lv_obj_t *label = lv_label_create( lv_screen_active() );
lv_label_set_text( label, "Hello Arduino, I'm LVGL!" );
lv_obj_align( label, LV_ALIGN_CENTER, 0, 0 );
@@ -138,6 +138,6 @@ void setup()
void loop()
{
lv_task_handler(); /* let the GUI do its work */
lv_timer_handler(); /* let the GUI do its work */
delay(5); /* let this time pass */
}

View File

@@ -33,7 +33,7 @@ void lv_example_observer_5(void)
lv_subject_add_observer(&fw_update_status_subject, fw_upload_manager_observer_cb, NULL);
/*Create start FW update button*/
lv_obj_t * btn = lv_btn_create(lv_screen_active());
lv_obj_t * btn = lv_button_create(lv_screen_active());
lv_obj_add_event_cb(btn, fw_update_btn_clicked_event_cb, LV_EVENT_CLICKED, NULL);
lv_obj_center(btn);
lv_obj_t * label = lv_label_create(btn);

View File

@@ -175,7 +175,7 @@ static lv_obj_t * my_button_create(lv_obj_t * parent, const char * text, lv_even
lv_subject_add_observer_with_target(&theme_subject, my_button_style_observer_cb, &styles, NULL);
}
lv_obj_t * btn = lv_btn_create(parent);
lv_obj_t * btn = lv_button_create(parent);
lv_obj_remove_style_all(btn);
lv_obj_add_style(btn, &styles.style_main, 0);
lv_obj_add_style(btn, &styles.style_pressed, LV_STATE_PRESSED);

View File

@@ -186,10 +186,10 @@ static void touchpad_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
/*Save the pressed coordinates and the state*/
if(touchpad_is_pressed()) {
touchpad_get_xy(&last_x, &last_y);
data->state = LV_INDEV_STATE_PR;
data->state = LV_INDEV_STATE_PRESSED;
}
else {
data->state = LV_INDEV_STATE_REL;
data->state = LV_INDEV_STATE_RELEASED;
}
/*Set the last pressed coordinates*/
@@ -232,10 +232,10 @@ static void mouse_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
/*Get whether the mouse button is pressed or released*/
if(mouse_is_pressed()) {
data->state = LV_INDEV_STATE_PR;
data->state = LV_INDEV_STATE_PRESSED;
}
else {
data->state = LV_INDEV_STATE_REL;
data->state = LV_INDEV_STATE_RELEASED;
}
}
@@ -277,7 +277,7 @@ static void keypad_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
/*Get whether the a key is pressed and save the pressed key*/
uint32_t act_key = keypad_get_key();
if(act_key != 0) {
data->state = LV_INDEV_STATE_PR;
data->state = LV_INDEV_STATE_PRESSED;
/*Translate the keys to LVGL control characters according to your key definitions*/
switch(act_key) {
@@ -301,7 +301,7 @@ static void keypad_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
last_key = act_key;
}
else {
data->state = LV_INDEV_STATE_REL;
data->state = LV_INDEV_STATE_RELEASED;
}
data->key = last_key;
@@ -339,7 +339,7 @@ static void encoder_handler(void)
/*Your code comes here*/
encoder_diff += 0;
encoder_state = LV_INDEV_STATE_REL;
encoder_state = LV_INDEV_STATE_RELEASED;
}
/*------------------
@@ -362,11 +362,11 @@ static void button_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
int8_t btn_act = button_get_pressed_id();
if(btn_act >= 0) {
data->state = LV_INDEV_STATE_PR;
data->state = LV_INDEV_STATE_PRESSED;
last_btn = btn_act;
}
else {
data->state = LV_INDEV_STATE_REL;
data->state = LV_INDEV_STATE_RELEASED;
}
/*Save the last pressed button's ID*/

View File

@@ -81,7 +81,7 @@ void lv_example_scale_3(void)
lv_scale_set_rotation(scale_img, 135);
/* image must point to the right. E.g. -O------>*/
needle_img = lv_img_create(scale_img);
needle_img = lv_image_create(scale_img);
lv_image_set_src(needle_img, &img_hand);
lv_obj_align(needle_img, LV_ALIGN_CENTER, 47, -2);
lv_image_set_pivot(needle_img, 3, 4);