mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/pkg_lvgl: adapt for auto_init
This commit is contained in:
parent
4e09a54521
commit
830ea3c19c
@ -24,16 +24,7 @@
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "lvgl_riot.h"
|
||||
|
||||
#include "screen_dev.h"
|
||||
|
||||
#include "ili9341.h"
|
||||
#include "ili9341_params.h"
|
||||
#include "disp_dev.h"
|
||||
#include "ili9341_disp_dev.h"
|
||||
|
||||
static ili9341_t s_disp_dev;
|
||||
static screen_dev_t s_screen;
|
||||
|
||||
#define CPU_LABEL_COLOR "FF0000"
|
||||
#define MEM_LABEL_COLOR "0000FF"
|
||||
@ -127,18 +118,10 @@ void sysmon_create(void)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Configure the generic display driver interface */
|
||||
s_screen.display = (disp_dev_t *)&s_disp_dev;
|
||||
s_screen.display->driver = &ili9341_disp_dev_driver;
|
||||
|
||||
/* Enable backlight */
|
||||
disp_dev_backlight_on();
|
||||
|
||||
/* Initialize the concrete display driver */
|
||||
ili9341_init(&s_disp_dev, &ili9341_params[0]);
|
||||
|
||||
/* Initialize lvgl with the generic display and touch drivers */
|
||||
lvgl_init(&s_screen);
|
||||
lvgl_start();
|
||||
|
||||
/* Create the system monitor widget */
|
||||
sysmon_create();
|
||||
|
@ -23,27 +23,8 @@
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "lvgl_riot.h"
|
||||
|
||||
#include "ili9341.h"
|
||||
#include "ili9341_params.h"
|
||||
#include "disp_dev.h"
|
||||
#include "ili9341_disp_dev.h"
|
||||
|
||||
#include "stmpe811.h"
|
||||
#include "stmpe811_params.h"
|
||||
#include "touch_dev.h"
|
||||
#include "stmpe811_touch_dev.h"
|
||||
|
||||
#include "screen_dev.h"
|
||||
|
||||
static screen_dev_t s_screen;
|
||||
static ili9341_t s_disp_dev;
|
||||
static stmpe811_t s_touch_dev;
|
||||
|
||||
static void _stmpe811_event_cb(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
lvgl_wakeup();
|
||||
}
|
||||
|
||||
static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||
{
|
||||
@ -55,22 +36,8 @@ static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Configure the generic display driver interface */
|
||||
s_screen.display = (disp_dev_t *)&s_disp_dev;
|
||||
s_screen.display->driver = &ili9341_disp_dev_driver;
|
||||
|
||||
/* Initialize the concrete display driver */
|
||||
ili9341_init(&s_disp_dev, &ili9341_params[0]);
|
||||
|
||||
/* Configure the generic touch driver interface */
|
||||
s_screen.touch = (touch_dev_t *)&s_touch_dev;
|
||||
s_screen.touch->driver = &stmpe811_touch_dev_driver;
|
||||
|
||||
/* Initialize the concrete touch driver */
|
||||
stmpe811_init(&s_touch_dev, &stmpe811_params[0], _stmpe811_event_cb, NULL);
|
||||
|
||||
/* Initialize lvgl with the generic screen */
|
||||
lvgl_init(&s_screen);
|
||||
/* Enable backlight */
|
||||
disp_dev_backlight_on();
|
||||
|
||||
/* Add a button to the current screen */
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);
|
||||
@ -78,8 +45,8 @@ int main(void)
|
||||
/* Set the button position and size */
|
||||
lv_coord_t x_size = 100;
|
||||
lv_coord_t y_size = 50;
|
||||
lv_coord_t x_pos = (disp_dev_width(s_screen.display) - x_size) / 2;
|
||||
lv_coord_t y_pos = (disp_dev_height(s_screen.display) - y_size) / 2;
|
||||
lv_coord_t x_pos = (lv_obj_get_width(lv_scr_act()) - x_size) / 2;
|
||||
lv_coord_t y_pos = (lv_obj_get_height(lv_scr_act()) - y_size) / 2;
|
||||
lv_obj_set_pos(btn, x_pos, y_pos);
|
||||
lv_obj_set_size(btn, 100, 50);
|
||||
|
||||
@ -90,5 +57,7 @@ int main(void)
|
||||
lv_obj_t * label = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(label, "Click me");
|
||||
|
||||
lvgl_start();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user