Monkey¶
A simple monkey test. Use random input to stress test the application.
Usage¶
Enable LV_USE_MONKEY
in lv_conf.h
.
First configure monkey, use lv_monkey_config_t
to define the configuration structure, set the type
(check input devices for the supported types), and then set the range of period_range
and input_range
, the monkey will output random operations at random times within this range. Call lv_monkey_create
to create monkey. Finally call lv_monkey_set_enable(monkey, true)
to enable monkey.
If you want to pause the monkey, call lv_monkey_set_enable(monkey, false)
. To delete the monkey, call lv_monkey_del(monkey)
.
Note that input_range
has different meanings in different type
:
LV_INDEV_TYPE_POINTER
No effect, click randomly within the pixels of the screen resolution.LV_INDEV_TYPE_ENCODER
The minimum and maximum values ofenc_diff
.LV_INDEV_TYPE_BUTTON
The minimum and maximum values ofbtn_id
. Uselv_monkey_get_indev()
to get the input device, and uselv_indev_set_button_points()
to map the key ID to the coordinates.LV_INDEV_TYPE_KEYPAD
No effect, Send random Keys.
Example¶
Touchpad monkey example¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_MONKEY && LV_BUILD_EXAMPLES
void lv_example_monkey_1(void)
{
/*Create pointer monkey test*/
lv_monkey_config_t config;
lv_monkey_config_init(&config);
config.type = LV_INDEV_TYPE_POINTER;
config.period_range.min = 10;
config.period_range.max = 100;
lv_monkey_t * monkey = lv_monkey_create(&config);
/*Start monkey test*/
lv_monkey_set_enable(monkey, true);
}
#endif
Error encountered while trying to open /home/runner/work/100ask_lvgl_docs/100ask_lvgl_docs/examples/others/monkey/lv_example_monkey_1.py
Encoder monkey example¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_MONKEY && LV_BUILD_EXAMPLES
void lv_example_monkey_2(void)
{
/*Create encoder monkey test*/
lv_monkey_config_t config;
lv_monkey_config_init(&config);
config.type = LV_INDEV_TYPE_ENCODER;
config.period_range.min = 50;
config.period_range.max = 500;
config.input_range.min = -5;
config.input_range.max = 5;
lv_monkey_t * monkey = lv_monkey_create(&config);
/*Set the default group*/
lv_group_t * group = lv_group_create();
lv_indev_set_group(lv_monkey_get_indev(monkey), group);
lv_group_set_default(group);
/*Start monkey test*/
lv_monkey_set_enable(monkey, true);
}
#endif
Error encountered while trying to open /home/runner/work/100ask_lvgl_docs/100ask_lvgl_docs/examples/others/monkey/lv_example_monkey_2.py
Button monkey example¶
C code
GitHub#include "../../lv_examples.h"
#if LV_USE_MONKEY && LV_BUILD_EXAMPLES
void lv_example_monkey_3(void)
{
static lv_point_t btn_points[3];
lv_coord_t hor_res = LV_HOR_RES;
/*Create button monkey test*/
lv_monkey_config_t config;
lv_monkey_config_init(&config);
config.type = LV_INDEV_TYPE_BUTTON;
config.period_range.min = 50;
config.period_range.max = 500;
config.input_range.min = 0;
config.input_range.max = sizeof(btn_points) / sizeof(lv_point_t) - 1;
lv_monkey_t * monkey = lv_monkey_create(&config);
/*Set the coordinates bound to the button*/
btn_points[0].x = hor_res / 4;
btn_points[0].y = 10;
btn_points[1].x = hor_res / 2;
btn_points[1].y = 10;
btn_points[2].x = hor_res * 3 / 4;
btn_points[2].y = 10;
lv_indev_set_button_points(lv_monkey_get_indev(monkey), btn_points);
/*Start monkey test*/
lv_monkey_set_enable(monkey, true);
}
#endif
Error encountered while trying to open /home/runner/work/100ask_lvgl_docs/100ask_lvgl_docs/examples/others/monkey/lv_example_monkey_3.py
API¶
Typedefs
-
typedef struct _lv_monkey lv_monkey_t¶
Functions
-
void lv_monkey_config_init(lv_monkey_config_t *config)¶
Initialize a monkey config with default values
- 参数
config -- pointer to 'lv_monkey_config_t' variable to initialize
-
lv_monkey_t *lv_monkey_create(const lv_monkey_config_t *config)¶
Create monkey for test
- 参数
config -- pointer to 'lv_monkey_config_t' variable
- 返回
pointer to the created monkey
-
lv_indev_t *lv_monkey_get_indev(lv_monkey_t *monkey)¶
Get monkey input device
- 参数
monkey -- pointer to a monkey
- 返回
pointer to the input device
-
void lv_monkey_set_enable(lv_monkey_t *monkey, bool en)¶
Enable monkey
- 参数
monkey -- pointer to a monkey
en -- set to true to enable
-
bool lv_monkey_get_enable(lv_monkey_t *monkey)¶
Get whether monkey is enabled
- 参数
monkey -- pointer to a monkey
- 返回
return true if monkey enabled
-
void lv_monkey_set_user_data(lv_monkey_t *monkey, void *user_data)¶
Set the user_data field of the monkey
- 参数
monkey -- pointer to a monkey
user_data -- pointer to the new user_data.
-
void *lv_monkey_get_user_data(lv_monkey_t *monkey)¶
Get the user_data field of the monkey
- 参数
monkey -- pointer to a monkey
- 返回
the pointer to the user_data of the monkey
-
void lv_monkey_del(lv_monkey_t *monkey)¶
Delete monkey
- 参数
monkey -- pointer to monkey
-
struct lv_monkey_config_t¶
Public Members
-
lv_indev_type_t type¶
< Input device type Monkey execution period
-
uint32_t min¶
-
uint32_t max¶
-
struct lv_monkey_config_t::[anonymous] period_range¶
The range of input value
-
int32_t min
-
int32_t max
-
struct lv_monkey_config_t::[anonymous] input_range¶
-
lv_indev_type_t type¶