feat(others) add monkey test (#2885)
* fix(Kconfig) remove duplicate LV_BUILD_EXAMPLES configuration * feat(refr) add reset of FPS statistics * fix(conf) mismatched macro judgment * feat(others) add monkey test Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> * fix(monkey) use lv_memset_00 to initialize monkey config * fix(monkey) random upper limit value Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> * feat(examples) add monkey test example * feat(docs) add monkey test description * feat(monkey) add user_data Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> * docs(monkey) add instructions Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> * fix(monkey) EX -> EXAMPLE Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> * feat(monkey) add comments to monkey config * docs(monkey) update usage * feat(Kconfig) add monkey test configuration * fix(monkey) rand() -> lv_rand() * feat(example) add button monkey test * docs(monkey) add button introduction Signed-off-by: FASTSHIFT <vifextech@foxmail.com> * fix(monkey) obj -> monkey Signed-off-by: FASTSHIFT <vifextech@foxmail.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -14,6 +14,8 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "snapshot/lv_example_snapshot.h"
|
||||
#include "monkey/lv_example_monkey.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
18
examples/others/monkey/index.rst
Normal file
18
examples/others/monkey/index.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
Touchpad monkey example
|
||||
"""""""""""""""""""
|
||||
|
||||
.. lv_example:: others/monkey/lv_example_monkey_1
|
||||
:language: c
|
||||
|
||||
Encoder monkey example
|
||||
"""""""""""""""""""
|
||||
|
||||
.. lv_example:: others/monkey/lv_example_monkey_2
|
||||
:language: c
|
||||
|
||||
Button monkey example
|
||||
"""""""""""""""""""
|
||||
|
||||
.. lv_example:: others/monkey/lv_example_monkey_3
|
||||
:language: c
|
||||
40
examples/others/monkey/lv_example_monkey.h
Normal file
40
examples/others/monkey/lv_example_monkey.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @file lv_example_monkey.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_EXAMPLE_MONKEY_H
|
||||
#define LV_EXAMPLE_MONKEY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_example_monkey_1(void);
|
||||
void lv_example_monkey_2(void);
|
||||
void lv_example_monkey_3(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_EXAMPLE_MONKEY_H*/
|
||||
18
examples/others/monkey/lv_example_monkey_1.c
Normal file
18
examples/others/monkey/lv_example_monkey_1.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#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
|
||||
25
examples/others/monkey/lv_example_monkey_2.c
Normal file
25
examples/others/monkey/lv_example_monkey_2.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#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
|
||||
33
examples/others/monkey/lv_example_monkey_3.c
Normal file
33
examples/others/monkey/lv_example_monkey_3.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user