当前位置:网站首页>RT thread simulator lvgl control: button button event
RT thread simulator lvgl control: button button event
2022-06-13 07:06:00 【Zhangshizheng】
Environment building
- RT-Thread 4.1.0
- BSP Simulator
simulator
- LVGL software package
function
- LVGL Draw a button , Click button , Generate button event
Method
- Button control ,LVGL There are official routines , It can be directly used for the verification of button events
- route :
simulator\packages\LVGL-latest\examples\get_started\lv_example_get_started_1.c
- Operation method : hold
lv_example_get_started_1.c
Copy to :simulator\applications\lvgl\demo\lv_btn_01.c
, Then simply modify , Add to visual studio 2022 Chinese compiler , Pay attention to modifying the header file
#include <rtthread.h>
#include "lvgl.h"
static void btn_event_cb(lv_event_t *e)
{
static uint32_t cnt = 0;
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *btn = lv_event_get_target(e);
if (code == LV_EVENT_CLICKED)
{
cnt++;
/*Get the first child of the button which is the label and change its text*/
lv_obj_t *label = lv_obj_get_child(btn, 0);
lv_label_set_text_fmt(label, "button: %d", cnt);
rt_kprintf("%s : click count = %d\r\n", __func__, cnt);
}
}
/** * Create a button with a label and react on click event. */
void lv_btn_01_init(void)
{
lv_obj_t *btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, 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);
}
Compile operation
- Run discovery , After clicking the button , The callback function of the button executes
Summary
- Continue to study LVGL Use of various controls for , Later, it can be used in embedded products
边栏推荐
- RT thread simulator lvgl control: switch switch button control
- Application of DS18B20 temperature sensor based on FPGA
- ML之FE:Vintage曲线/Vintage分析的简介、计算逻辑、案例应用之详细攻略
- Yolov5 analysis | parameters and performance indicators
- Department store center supply chain management system
- 微隔离(MSG)
- June 12, 2022: if there are n*n pieces in an n*n square chessboard, each grid can have exactly one piece. But now some pieces are gathered on a grid, such as 2030100300. The above two-dimensional arra
- Br backup test
- C # using multithreading
- RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
猜你喜欢
How to use Wangyou DFM software for cold plate analysis
Network planning common interview knowledge (I)
Why is the new e-commerce outlet mode so popular? What is the specific mode?
Upper computer development (detailed design of firmware download software)
Why is the blind box e-commerce mode so popular?
Ticdc introduction
Raspberry school advanced development - "writing of IO port driver code" includes bus address, physical \u virtual address and bcm2835 chip manual knowledge
Tidb data migration (DM) Introduction
测试开发程序员,你还在迷茫吗?不能把自己定义为码农......
RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
随机推荐
105. constructing binary trees from preorder and inorder traversal sequences
Local file upload FTP or remote directory
Implementation of fruit mall wholesale platform based on SSM
【转】FPGA面试题
Detailed Mr Atlas of hip joint (Reprinted)
Ticdc introduction
【騰訊阿裏最全面試題集錦】(四面:3輪技術+1輪HR)
What is the new business model of Taishan crowdfunding in 2022?
杭州网上开户是安全的吗?
检测循环数“142857“
如何从头自己制作开发板?图文并茂,一步步操作给你看。
First day of learning MySQL Basics
New Taishan crowdfunding business diversion fission growth model in 2022
Tikv key performance parameters and optimization
16、 IO stream (II)
Jinglianwen Technology: current situation and solutions of data acquisition and labeling industry
Host computer development (Architecture Design of firmware download software)
基于SSM实现水果商城批发平台
How to make a development board from scratch? Illustrated and illustrated, step by step operation for you to see.
Periodontitis investigation (ongoing)