Skip to content

Commit

Permalink
add ui_test.c/h
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Jan 9, 2025
1 parent b3dbe88 commit 7f30594
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
81 changes: 81 additions & 0 deletions examples/ui_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @file ui_test.c
*
*/

/*********************
* INCLUDES
*********************/
#include "ui_test.h"

#if LV_USE_XML == 0
#error "Enable LV_USE_XML in lv_conf.h"
#endif

/*********************
* DEFINES
*********************/

/**********************
* TYPEDEFS
**********************/

/**********************
* GLOBAL PROTOTYPES
**********************/
void dark_slider_register(void);
void slider_box_register(void);

/**********************
* STATIC PROTOTYPES
**********************/

/**********************
* STATIC VARIABLES
**********************/

/**********************
* MACROS
**********************/

/**********************
* GLOBAL FUNCTIONS
**********************/

void ui_test_from_c(void)
{
ui_init("A:xml_examples/");

/*Create the home component by calling a C function*/
home_create(lv_screen_active());

}
void ui_test_from_xml(void)
{
ui_init("A:xml_examples/");

/*Register the fonts. Will be required for XML parsing.*/
lv_xml_register_font("inter_sm", inter_sm);
lv_xml_register_font("inter_md", inter_md);
lv_xml_register_font("inter_xl", inter_xl);

/*Register the components and widgets*/
lv_xml_component_register_from_file("A:xml_examples/components/buttons/button_default.xml");
lv_xml_component_register_from_file("A:xml_examples/components/buttons/button_warning.xml");
lv_xml_component_register_from_file("A:xml_examples/components/buttons/button_error.xml");
lv_xml_component_register_from_file("A:xml_examples/components/headings/h1.xml");
lv_xml_component_register_from_file("A:xml_examples/components/headings/h2.xml");
lv_xml_component_register_from_file("A:xml_examples/components/headings/h3.xml");
lv_xml_component_register_from_file("A:xml_examples/components/home.xml");
lv_xml_component_register_from_file("A:xml_examples/components/scratchpad.xml");

dark_slider_register();
slider_box_register();

/*Create the home component directly from XML*/
lv_xml_create(lv_screen_active(), "home", NULL);
}

/**********************
* STATIC FUNCTIONS
**********************/
55 changes: 55 additions & 0 deletions examples/ui_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @file ui_test.h
*
*/

#ifndef UI_TEST_H
#define UI_TEST_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
* INCLUDES
*********************/
#include "ui.h"


/*********************
* DEFINES
*********************/

/**********************
* TYPEDEFS
**********************/

/**********************
* GLOBAL VARIABLES
**********************/

/**********************
* GLOBAL PROTOTYPES
**********************/

/**
* Call after lv_init() and your driver inits to test the example UI
* directly from C.
*/
void ui_test_from_c(void);

/**
* Call after lv_init() and your driver inits to test the example UI
* directly from XML.
*/
void ui_test_from_xml(void);

/**********************
* MACROS
**********************/

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif /*UI_TEST_H*/

0 comments on commit 7f30594

Please sign in to comment.