「App:Library:LVGL:Readme:Examples」の版間の差分
提供: robot-jp wiki
ナビゲーションに移動検索に移動8行目: | 8行目: | ||
|- | |- | ||
|For more examples see the <u>'''[https://github.com/lvgl/lvgl/tree/master/examples examples]'''</u> folder. | |For more examples see the <u>'''[https://github.com/lvgl/lvgl/tree/master/examples examples]'''</u> folder. | ||
− | | | + | |その他の例については、 '''<u>[https://github.com/lvgl/lvgl/tree/master/examples examples]</u>'''フォルダーを参照してください。 |
− | |} | + | |} |
:[[ファイル:LVGL Readme btn example.png]] | :[[ファイル:LVGL Readme btn example.png]] | ||
+ | <syntaxhighlight lang="C" line> | ||
+ | lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button to the current screen*/ | ||
+ | lv_obj_set_pos(btn, 10, 10); /*Set its position*/ | ||
+ | lv_obj_set_size(btn, 100, 50); /*Set its size*/ | ||
+ | lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/ | ||
+ | |||
+ | lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/ | ||
+ | lv_label_set_text(label, "Button"); /*Set the labels text*/ | ||
+ | lv_obj_center(label); /*Align the label to the center*/ | ||
+ | ... | ||
+ | |||
+ | void btn_event_cb(lv_event_t * e) | ||
+ | { | ||
+ | printf("Clicked\n"); | ||
+ | } | ||
+ | |||
+ | |||
+ | </syntaxhighlight> | ||
:[https://robot-jp.com/wiki/index.php/App:Library:LVGL 戻る : Previous] | :[https://robot-jp.com/wiki/index.php/App:Library:LVGL 戻る : Previous] |
2022年6月20日 (月) 22:23時点における版
https://github.com/lvgl/lvgl#examples
Examples
1lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button to the current screen*/
2lv_obj_set_pos(btn, 10, 10); /*Set its position*/
3lv_obj_set_size(btn, 100, 50); /*Set its size*/
4lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
5
6lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
7lv_label_set_text(label, "Button"); /*Set the labels text*/
8lv_obj_center(label); /*Align the label to the center*/
9...
10
11void btn_event_cb(lv_event_t * e)
12{
13 printf("Clicked\n");
14}
15
16
17