Refactor the wasm graphic layer (wgl) and the gui sample (#231)

This commit is contained in:
Wang Xin 2020-04-12 16:30:01 +08:00 committed by GitHub
parent 5e196253f6
commit bf8fbee92e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 1911 additions and 1503 deletions

View File

@ -15,238 +15,6 @@ extern "C" {
#include <stdbool.h>
#include "lv_conf.h"
typedef lv_coord_t wgl_coord_t; /* lv_coord_t is defined in lv_conf.h */
typedef void * wgl_font_user_data_t;
/**
* Represents a point on the screen.
*/
typedef struct
{
lv_coord_t x;
lv_coord_t y;
} wgl_point_t;
/** Represents an area of the screen. */
typedef struct
{
lv_coord_t x1;
lv_coord_t y1;
lv_coord_t x2;
lv_coord_t y2;
} wgl_area_t;
/** Describes the properties of a glyph. */
typedef struct
{
uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width. 8 bit integer, 4 bit fractional */
uint8_t box_w; /**< Width of the glyph's bounding box*/
uint8_t box_h; /**< Height of the glyph's bounding box*/
int8_t ofs_x; /**< x offset of the bounding box*/
int8_t ofs_y; /**< y offset of the bounding box*/
uint8_t bpp; /**< Bit-per-pixel: 1, 2, 4, 8*/
}wgl_font_glyph_dsc_t;
/*Describe the properties of a font*/
typedef struct _wgl_font_struct
{
/** Get a glyph's descriptor from a font*/
bool (*get_glyph_dsc)(const struct _wgl_font_struct *, wgl_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next);
/** Get a glyph's bitmap from a font*/
const uint8_t * (*get_glyph_bitmap)(const struct _wgl_font_struct *, uint32_t);
/*Pointer to the font in a font pack (must have the same line height)*/
uint8_t line_height; /**< The real line height where any text fits*/
uint8_t base_line; /**< Base line measured from the top of the line_height*/
void * dsc; /**< Store implementation specific data here*/
#if LV_USE_USER_DATA
wgl_font_user_data_t user_data; /**< Custom user data for font. */
#endif
} wgl_font_t;
#if LV_COLOR_DEPTH == 1
#define LV_COLOR_SIZE 8
#elif LV_COLOR_DEPTH == 8
#define LV_COLOR_SIZE 8
#elif LV_COLOR_DEPTH == 16
#define LV_COLOR_SIZE 16
#elif LV_COLOR_DEPTH == 32
#define LV_COLOR_SIZE 32
#else
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
/**********************
* TYPEDEFS
**********************/
typedef union
{
uint8_t blue : 1;
uint8_t green : 1;
uint8_t red : 1;
uint8_t full : 1;
} wgl_color1_t;
typedef union
{
struct
{
uint8_t blue : 2;
uint8_t green : 3;
uint8_t red : 3;
} ch;
uint8_t full;
} wgl_color8_t;
typedef union
{
struct
{
#if LV_COLOR_16_SWAP == 0
uint16_t blue : 5;
uint16_t green : 6;
uint16_t red : 5;
#else
uint16_t green_h : 3;
uint16_t red : 5;
uint16_t blue : 5;
uint16_t green_l : 3;
#endif
} ch;
uint16_t full;
} wgl_color16_t;
typedef union
{
struct
{
uint8_t blue;
uint8_t green;
uint8_t red;
uint8_t alpha;
} ch;
uint32_t full;
} wgl_color32_t;
#if LV_COLOR_DEPTH == 1
typedef uint8_t wgl_color_int_t;
typedef wgl_color1_t wgl_color_t;
#elif LV_COLOR_DEPTH == 8
typedef uint8_t wgl_color_int_t;
typedef wgl_color8_t wgl_color_t;
#elif LV_COLOR_DEPTH == 16
typedef uint16_t wgl_color_int_t;
typedef wgl_color16_t wgl_color_t;
#elif LV_COLOR_DEPTH == 32
typedef uint32_t wgl_color_int_t;
typedef wgl_color32_t wgl_color_t;
#else
#error "Invalid LV_COLOR_DEPTH in lv_conf.h! Set it to 1, 8, 16 or 32!"
#endif
typedef uint8_t wgl_opa_t;
/*Border types (Use 'OR'ed values)*/
enum {
WGL_BORDER_NONE = 0x00,
WGL_BORDER_BOTTOM = 0x01,
WGL_BORDER_TOP = 0x02,
WGL_BORDER_LEFT = 0x04,
WGL_BORDER_RIGHT = 0x08,
WGL_BORDER_FULL = 0x0F,
WGL_BORDER_INTERNAL = 0x10, /**< FOR matrix-like objects (e.g. Button matrix)*/
};
typedef uint8_t wgl_border_part_t;
/*Shadow types*/
enum {
WGL_SHADOW_BOTTOM = 0, /**< Only draw bottom shadow */
WGL_SHADOW_FULL, /**< Draw shadow on all sides */
};
typedef uint8_t wgl_shadow_type_t;
/**
* Objects in LittlevGL can be assigned a style - which holds information about
* how the object should be drawn.
*
* This allows for easy customization without having to modify the object's design
* function.
*/
typedef struct
{
uint8_t glass : 1; /**< 1: Do not inherit this style*/
/** Object background. */
struct
{
wgl_color_t main_color; /**< Object's main background color. */
wgl_color_t grad_color; /**< Second color. If not equal to `main_color` a gradient will be drawn for the background. */
wgl_coord_t radius; /**< Object's corner radius. You can use #WGL_RADIUS_CIRCLE if you want to draw a circle. */
wgl_opa_t opa; /**< Object's opacity (0-255). */
struct
{
wgl_color_t color; /**< Border color */
wgl_coord_t width; /**< Border width */
wgl_border_part_t part; /**< Which borders to draw */
wgl_opa_t opa; /**< Border opacity. */
} border;
struct
{
wgl_color_t color;
wgl_coord_t width;
wgl_shadow_type_t type; /**< Which parts of the shadow to draw */
} shadow;
struct
{
wgl_coord_t top;
wgl_coord_t bottom;
wgl_coord_t left;
wgl_coord_t right;
wgl_coord_t inner;
} padding;
} body;
/** Style for text drawn by this object. */
struct
{
wgl_color_t color; /**< Text color */
wgl_color_t sel_color; /**< Text selection background color. */
const wgl_font_t * font;
wgl_coord_t letter_space; /**< Space between letters */
wgl_coord_t line_space; /**< Space between lines (vertical) */
wgl_opa_t opa; /**< Text opacity */
} text;
/**< Style of images. */
struct
{
wgl_color_t color; /**< Color to recolor the image with */
wgl_opa_t intense; /**< Opacity of recoloring (0 means no recoloring) */
wgl_opa_t opa; /**< Opacity of whole image */
} image;
/**< Style of lines (not borders). */
struct
{
wgl_color_t color;
wgl_coord_t width;
wgl_opa_t opa;
uint8_t rounded : 1; /**< 1: rounded line endings*/
} line;
} wgl_style_t;
/* Object native function IDs */
enum {

View File

@ -7,6 +7,7 @@
#define _GUI_API_H_
#include "bh_platform.h"
#include "bi-inc/wgl_shared_utils.h"
#ifdef __cplusplus
extern "C" {

View File

@ -0,0 +1,46 @@
#!/bin/bash
WGL_ROOT=$(cd "$(dirname "$0")/" && pwd)
LVGL_REPO_DIR=${WGL_ROOT}/../../../deps/lvgl
ls $LVGL_REPO_DIR
#if [ ! -d "${LVGL_REPO_DIR}" ]; then
# echo "lvgl repo not exist, please git pull the lvgl v6.0 first"
# exit 1
#fi
cd ${WGL_ROOT}/wa-inc/lvgl
pwd
if [ -d src ]; then
rm -rf src
echo "deleted the src folder from previous preparation."
fi
mkdir src
cd src
cp ${LVGL_REPO_DIR}/src/*.h ./
for folder in lv_core lv_draw lv_hal lv_objx lv_font lv_misc lv_themes
do
echo "Prepare fold $folder...done"
mkdir $folder
cp ${LVGL_REPO_DIR}/src/${folder}/*.h ./${folder}/
done
cp -f ../lv_obj.h ./lv_core/lv_obj.h
echo "test the header files..."
cd ..
gcc test.c -o test.out
if [ $? != 0 ];then
echo "failed to compile the test.c"
exit 1
else
echo "okay"
rm test.out
fi
echo "lvgl header files for WASM application ready."

View File

@ -3,24 +3,24 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "bh_platform.h"
#include "gui_api.h"
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, argv, ARGC)
wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy)
lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
return (lv_obj_t *)argv[0];
}
void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl)
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -28,7 +28,7 @@ void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
}
void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state)
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -36,14 +36,14 @@ void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
}
void wgl_btn_toggle(wgl_obj_t btn)
void lv_btn_toggle(lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_TOGGLE);
}
void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time)
void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -51,7 +51,7 @@ void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_IN_TIME);
}
void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time)
void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -59,7 +59,7 @@ void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_WAIT_TIME);
}
void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time)
void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time)
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -73,15 +73,15 @@ void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time)
// //wasm_btn_set_style(btn, type, style);
//}
//
wgl_btn_state_t wgl_btn_get_state(const wgl_obj_t btn)
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_STATE);
return (wgl_btn_state_t)argv[0];
return (lv_btn_state_t)argv[0];
}
bool wgl_btn_get_toggle(const wgl_obj_t btn)
bool lv_btn_get_toggle(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -89,7 +89,7 @@ bool wgl_btn_get_toggle(const wgl_obj_t btn)
return (bool)argv[0];
}
uint16_t wgl_btn_get_ink_in_time(const wgl_obj_t btn)
uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -97,7 +97,7 @@ uint16_t wgl_btn_get_ink_in_time(const wgl_obj_t btn)
return (uint16_t)argv[0];
}
uint16_t wgl_btn_get_ink_wait_time(const wgl_obj_t btn)
uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -105,7 +105,7 @@ uint16_t wgl_btn_get_ink_wait_time(const wgl_obj_t btn)
return (uint16_t)argv[0];
}
uint16_t wgl_btn_get_ink_out_time(const wgl_obj_t btn)
uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn)
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;

View File

@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
@ -11,17 +12,17 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_CB_NATIVE_FUNC(id) wasm_cb_native_call(id, argv, ARGC)
wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy)
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
return (lv_obj_t *)argv[0];
}
void wgl_cb_set_text(wgl_obj_t cb, const char * txt)
void lv_cb_set_text(lv_obj_t * cb, const char * txt)
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
@ -30,7 +31,7 @@ void wgl_cb_set_text(wgl_obj_t cb, const char * txt)
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_TEXT);
}
void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt)
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt)
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
@ -45,7 +46,7 @@ void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt)
//}
//
unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
static unsigned int wgl_cb_get_text_length(lv_obj_t * cb)
{
uint32 argv[1] = {0};
argv[0] = (uint32)cb;
@ -53,7 +54,7 @@ unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
return argv[0];
}
char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
static char *wgl_cb_get_text(lv_obj_t * cb, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
@ -63,6 +64,14 @@ char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
return (char *)argv[0];
}
// TODO: need to use a global data buffer for the returned text
const char * lv_cb_get_text(const lv_obj_t * cb)
{
return NULL;
}
//const wgl_style_t * wgl_cb_get_style(const wgl_obj_t cb, wgl_cb_style_t type)
//{
// //TODO

View File

@ -4,7 +4,8 @@
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
@ -12,17 +13,17 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_LABEL_NATIVE_FUNC(id) wasm_label_native_call(id, argv, ARGC)
wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy)
lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy)
{
uint32 argv[2] = {0};
argv[0] = (uint32)par;
argv[1] = (uint32)copy;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
return (lv_obj_t *)argv[0];
}
void wgl_label_set_text(wgl_obj_t label, const char * text)
void lv_label_set_text(lv_obj_t * label, const char * text)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -32,7 +33,7 @@ void wgl_label_set_text(wgl_obj_t label, const char * text)
}
void wgl_label_set_array_text(wgl_obj_t label, const char * array, uint16_t size)
void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -42,7 +43,7 @@ void wgl_label_set_array_text(wgl_obj_t label, const char * array, uint16_t size
}
void wgl_label_set_static_text(wgl_obj_t label, const char * text)
void lv_label_set_static_text(lv_obj_t * label, const char * text)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -52,7 +53,7 @@ void wgl_label_set_static_text(wgl_obj_t label, const char * text)
}
void wgl_label_set_long_mode(wgl_obj_t label, wgl_label_long_mode_t long_mode)
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -61,7 +62,7 @@ void wgl_label_set_long_mode(wgl_obj_t label, wgl_label_long_mode_t long_mode)
}
void wgl_label_set_align(wgl_obj_t label, wgl_label_align_t align)
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -70,7 +71,7 @@ void wgl_label_set_align(wgl_obj_t label, wgl_label_align_t align)
}
void wgl_label_set_recolor(wgl_obj_t label, bool en)
void lv_label_set_recolor(lv_obj_t * label, bool en)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -79,7 +80,7 @@ void wgl_label_set_recolor(wgl_obj_t label, bool en)
}
void wgl_label_set_body_draw(wgl_obj_t label, bool en)
void lv_label_set_body_draw(lv_obj_t * label, bool en)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -88,7 +89,7 @@ void wgl_label_set_body_draw(wgl_obj_t label, bool en)
}
void wgl_label_set_anim_speed(wgl_obj_t label, uint16_t anim_speed)
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -97,7 +98,7 @@ void wgl_label_set_anim_speed(wgl_obj_t label, uint16_t anim_speed)
}
void wgl_label_set_text_sel_start(wgl_obj_t label, uint16_t index)
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -106,7 +107,7 @@ void wgl_label_set_text_sel_start(wgl_obj_t label, uint16_t index)
}
void wgl_label_set_text_sel_end(wgl_obj_t label, uint16_t index)
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -114,7 +115,7 @@ void wgl_label_set_text_sel_end(wgl_obj_t label, uint16_t index)
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT_SEL_END);
}
unsigned int wgl_label_get_text_length(wgl_obj_t label)
unsigned int wgl_label_get_text_length(lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -122,7 +123,7 @@ unsigned int wgl_label_get_text_length(wgl_obj_t label)
return argv[0];
}
char * wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len)
char * wgl_label_get_text(lv_obj_t * label, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -132,26 +133,34 @@ char * wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len)
return (char *)argv[0];
}
// TODO:
char * lv_label_get_text(const lv_obj_t * label)
{
wgl_label_long_mode_t wgl_label_get_long_mode(const wgl_obj_t label)
return NULL;
}
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LONG_MODE);
return (wgl_label_long_mode_t)argv[0];
return (lv_label_long_mode_t)argv[0];
}
wgl_label_align_t wgl_label_get_align(const wgl_obj_t label)
lv_label_align_t lv_label_get_align(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ALIGN);
return (wgl_label_align_t)argv[0];
return (lv_label_align_t)argv[0];
}
bool wgl_label_get_recolor(const wgl_obj_t label)
bool lv_label_get_recolor(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -160,7 +169,7 @@ bool wgl_label_get_recolor(const wgl_obj_t label)
}
bool wgl_label_get_body_draw(const wgl_obj_t label)
bool lv_label_get_body_draw(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -169,7 +178,7 @@ bool wgl_label_get_body_draw(const wgl_obj_t label)
}
uint16_t wgl_label_get_anim_speed(const wgl_obj_t label)
uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -178,7 +187,7 @@ uint16_t wgl_label_get_anim_speed(const wgl_obj_t label)
}
void wgl_label_get_letter_pos(const wgl_obj_t label, uint16_t index, wgl_point_t * pos)
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos)
{
uint32 argv[4] = {0};
argv[0] = (uint32)label;
@ -189,7 +198,7 @@ void wgl_label_get_letter_pos(const wgl_obj_t label, uint16_t index, wgl_point_t
}
uint16_t wgl_label_get_letter_on(const wgl_obj_t label, wgl_point_t * pos)
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -200,7 +209,7 @@ uint16_t wgl_label_get_letter_on(const wgl_obj_t label, wgl_point_t * pos)
}
bool wgl_label_is_char_under_pos(const wgl_obj_t label, wgl_point_t * pos)
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -211,7 +220,7 @@ bool wgl_label_is_char_under_pos(const wgl_obj_t label, wgl_point_t * pos)
}
uint16_t wgl_label_get_text_sel_start(const wgl_obj_t label)
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -220,7 +229,7 @@ uint16_t wgl_label_get_text_sel_start(const wgl_obj_t label)
}
uint16_t wgl_label_get_text_sel_end(const wgl_obj_t label)
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -229,7 +238,7 @@ uint16_t wgl_label_get_text_sel_end(const wgl_obj_t label)
}
void wgl_label_ins_text(wgl_obj_t label, uint32_t pos, const char * txt)
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
{
uint32 argv[4] = {0};
argv[0] = (uint32)label;
@ -240,7 +249,7 @@ void wgl_label_ins_text(wgl_obj_t label, uint32_t pos, const char * txt)
}
void wgl_label_cut_text(wgl_obj_t label, uint32_t pos, uint32_t cnt)
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt)
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;

View File

@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
@ -12,7 +13,7 @@
#define CALL_LIST_NATIVE_FUNC(id) wasm_list_native_call(id, argv, ARGC)
wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
{
uint32 argv[2] = {0};
@ -20,7 +21,7 @@ wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
argv[1] = (uint32)copy;
CALL_LIST_NATIVE_FUNC(LIST_FUNC_ID_CREATE);
return (wgl_obj_t)argv[0];
return (lv_obj_t *)argv[0];
}
//
//
@ -30,7 +31,7 @@ wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
//}
//
wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * txt)
lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * txt)
{
uint32 argv[3] = {0};
@ -40,7 +41,7 @@ wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * tx
argv[1] = (uint32)txt;
argv[2] = strlen(txt) + 1;
CALL_LIST_NATIVE_FUNC(LIST_FUNC_ID_ADD_BTN);
return (wgl_obj_t)argv[0];
return (lv_obj_t *)argv[0];
}
//
//

View File

@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <stdlib.h>
#include <string.h>
@ -14,9 +15,8 @@
typedef struct _obj_evt_cb {
struct _obj_evt_cb *next;
wgl_obj_t obj;
wgl_event_cb_t event_cb;
lv_obj_t * obj;
lv_event_cb_t event_cb;
} obj_evt_cb_t;
static obj_evt_cb_t *g_obj_evt_cb_list = NULL;
@ -24,29 +24,29 @@ static obj_evt_cb_t *g_obj_evt_cb_list = NULL;
/* For lvgl compatible */
char g_widget_text[100];
wgl_res_t wgl_obj_del(wgl_obj_t obj)
lv_res_t lv_obj_del(lv_obj_t * obj)
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL);
return (wgl_res_t)argv[0];
return (lv_res_t)argv[0];
}
void wgl_obj_del_async(wgl_obj_t obj)
void lv_obj_del_async(struct _lv_obj_t *obj)
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL_ASYNC);
}
void wgl_obj_clean(wgl_obj_t obj)
void lv_obj_clean(lv_obj_t * obj)
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_CLEAN);
}
void wgl_obj_align(wgl_obj_t obj, const wgl_obj_t base, wgl_align_t align, wgl_coord_t x_mod, wgl_coord_t y_mod)
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
{
uint32 argv[5] = {0};
argv[0] = (uint32)obj;
@ -57,7 +57,7 @@ void wgl_obj_align(wgl_obj_t obj, const wgl_obj_t base, wgl_align_t align, wgl_c
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_ALIGN);
}
wgl_event_cb_t wgl_obj_get_event_cb(const wgl_obj_t obj)
lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj)
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb != NULL) {
@ -70,7 +70,7 @@ wgl_event_cb_t wgl_obj_get_event_cb(const wgl_obj_t obj)
return NULL;
}
void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb)
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
{
obj_evt_cb_t *obj_evt_cb;
uint32 argv[1] = {0};
@ -102,7 +102,7 @@ void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb)
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_SET_EVT_CB);
}
void on_widget_event(wgl_obj_t obj, wgl_event_t event)
void on_widget_event(lv_obj_t * obj, lv_event_t event)
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;

View File

@ -1,162 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_BTN_H
#define WAMR_GRAPHIC_LIBRARY_BTN_H
#ifdef __cplusplus
extern "C" {
#endif
/** Possible states of a button.
* It can be used not only by buttons but other button-like objects too*/
enum {
/**Released*/
WGL_BTN_STATE_REL,
/**Pressed*/
WGL_BTN_STATE_PR,
/**Toggled released*/
WGL_BTN_STATE_TGL_REL,
/**Toggled pressed*/
WGL_BTN_STATE_TGL_PR,
/**Inactive*/
WGL_BTN_STATE_INA,
/**Number of states*/
_WGL_BTN_STATE_NUM,
};
typedef uint8_t wgl_btn_state_t;
/**Styles*/
enum {
/** Release style */
WGL_BTN_STYLE_REL,
/**Pressed style*/
WGL_BTN_STYLE_PR,
/** Toggle released style*/
WGL_BTN_STYLE_TGL_REL,
/** Toggle pressed style */
WGL_BTN_STYLE_TGL_PR,
/** Inactive style*/
WGL_BTN_STYLE_INA,
};
typedef uint8_t wgl_btn_style_t;
/* Create a button */
wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy);
/*=====================
* Setter functions
*====================*/
/**
* Enable the toggled states. On release the button will change from/to toggled state.
* @param btn pointer to a button object
* @param tgl true: enable toggled states, false: disable
*/
void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl);
/**
* Set the state of the button
* @param btn pointer to a button object
* @param state the new state of the button (from wgl_btn_state_t enum)
*/
void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state);
/**
* Toggle the state of the button (ON->OFF, OFF->ON)
* @param btn pointer to a button object
*/
void wgl_btn_toggle(wgl_obj_t btn);
/**
* Set time of the ink effect (draw a circle on click to animate in the new state)
* @param btn pointer to a button object
* @param time the time of the ink animation
*/
void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time);
/**
* Set the wait time before the ink disappears
* @param btn pointer to a button object
* @param time the time of the ink animation
*/
void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time);
/**
* Set time of the ink out effect (animate to the released state)
* @param btn pointer to a button object
* @param time the time of the ink animation
*/
void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time);
/**
* Set a style of a button.
* @param btn pointer to button object
* @param type which style should be set
* @param style pointer to a style
* */
//void wgl_btn_set_style(wgl_obj_t btn, wgl_btn_style_t type, const wgl_style_t * style);
/*=====================
* Getter functions
*====================*/
/**
* Get the current state of the button
* @param btn pointer to a button object
* @return the state of the button (from wgl_btn_state_t enum)
*/
wgl_btn_state_t wgl_btn_get_state(wgl_obj_t btn);
/**
* Get the toggle enable attribute of the button
* @param btn pointer to a button object
* @return true: toggle enabled, false: disabled
*/
bool wgl_btn_get_toggle(wgl_obj_t btn);
/**
* Get time of the ink in effect (draw a circle on click to animate in the new state)
* @param btn pointer to a button object
* @return the time of the ink animation
*/
uint16_t wgl_btn_get_ink_in_time(wgl_obj_t btn);
/**
* Get the wait time before the ink disappears
* @param btn pointer to a button object
* @return the time of the ink animation
*/
uint16_t wgl_btn_get_ink_wait_time(wgl_obj_t btn);
/**
* Get time of the ink out effect (animate to the releases state)
* @param btn pointer to a button object
* @return the time of the ink animation
*/
uint16_t wgl_btn_get_ink_out_time(wgl_obj_t btn);
/**
* Get style of a button.
* @param btn pointer to button object
* @param type which style should be get
* @return style pointer to the style
* */
//const wgl_style_t * wgl_btn_get_style(const wgl_obj_t btn, wgl_btn_style_t type);
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_BTN_H */

View File

@ -1,79 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_CB_H
#define WAMR_GRAPHIC_LIBRARY_CB_H
#ifdef __cplusplus
extern "C" {
#endif
/** Checkbox styles. */
enum {
WGL_CB_STYLE_BG, /**< Style of object background. */
WGL_CB_STYLE_BOX_REL, /**< Style of box (released). */
WGL_CB_STYLE_BOX_PR, /**< Style of box (pressed). */
WGL_CB_STYLE_BOX_TGL_REL, /**< Style of box (released but checked). */
WGL_CB_STYLE_BOX_TGL_PR, /**< Style of box (pressed and checked). */
WGL_CB_STYLE_BOX_INA, /**< Style of disabled box */
};
typedef uint8_t wgl_cb_style_t;
/**
* Create a check box objects
* @param par pointer to an object, it will be the parent of the new check box
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
* @return pointer to the created check box
*/
wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy);
/*=====================
* Setter functions
*====================*/
/**
* Set the text of a check box. `txt` will be copied and may be deallocated
* after this function returns.
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void wgl_cb_set_text(wgl_obj_t cb, const char * txt);
/**
* Set the text of a check box. `txt` must not be deallocated during the life
* of this checkbox.
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt);
/*=====================
* Getter functions
*====================*/
/**
* Get the length of the text of a check box
* @param label the check box object
* @return the length of the text of the check box
*/
unsigned int wgl_cb_get_text_length(wgl_obj_t cb);
/**
* Get the text of a check box
* @param label the check box object
* @param buffer buffer to save the text
* @param buffer_len length of the buffer
* @return the text of the check box, note that the text will be truncated if buffer is not long enough
*/
char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len);
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_CB_H */

View File

@ -1,66 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_LABEL_H
#define WAMR_GRAPHIC_LIBRARY_LABEL_H
#ifdef __cplusplus
extern "C" {
#endif
/** Long mode behaviors. Used in 'wgl_label_ext_t' */
enum {
WGL_LABEL_LONG_EXPAND, /**< Expand the object size to the text size*/
WGL_LABEL_LONG_BREAK, /**< Keep the object width, break the too long lines and expand the object
height*/
WGL_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
WGL_LABEL_LONG_SROLL, /**< Keep the size and roll the text back and forth*/
WGL_LABEL_LONG_SROLL_CIRC, /**< Keep the size and roll the text circularly*/
WGL_LABEL_LONG_CROP, /**< Keep the size and crop the text out of it*/
};
typedef uint8_t wgl_label_long_mode_t;
/** Label align policy*/
enum {
WGL_LABEL_ALIGN_LEFT, /**< Align text to left */
WGL_LABEL_ALIGN_CENTER, /**< Align text to center */
WGL_LABEL_ALIGN_RIGHT, /**< Align text to right */
};
typedef uint8_t wgl_label_align_t;
/** Label styles*/
enum {
WGL_LABEL_STYLE_MAIN,
};
typedef uint8_t wgl_label_style_t;
/* Create a label */
wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy);
/* Set text for the label */
void wgl_label_set_text(wgl_obj_t label, const char * text);
/**
* Get the length of the text of a label
* @param label the label object
* @return the length of the text of the label
*/
unsigned int wgl_label_get_text_length(wgl_obj_t label);
/**
* Get the text of a label
* @param label the label object
* @param buffer buffer to save the text
* @param buffer_len length of the buffer
* @return the text of the label, note that the text will be truncated if buffer is not long enough
*/
char *wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len);
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_LABEL_H */

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_LIST_H
#define WAMR_GRAPHIC_LIBRARY_LIST_H
#ifdef __cplusplus
extern "C" {
#endif
/** List styles. */
enum {
WGL_LIST_STYLE_BG, /**< List background style */
WGL_LIST_STYLE_SCRL, /**< List scrollable area style. */
WGL_LIST_STYLE_SB, /**< List scrollbar style. */
WGL_LIST_STYLE_EDGE_FLASH, /**< List edge flash style. */
WGL_LIST_STYLE_BTN_REL, /**< Same meaning as the ordinary button styles. */
WGL_LIST_STYLE_BTN_PR,
WGL_LIST_STYLE_BTN_TGL_REL,
WGL_LIST_STYLE_BTN_TGL_PR,
WGL_LIST_STYLE_BTN_INA,
};
typedef uint8_t wgl_list_style_t;
/**
* Create a list objects
* @param par pointer to an object, it will be the parent of the new list
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
* @return pointer to the created list
*/
wgl_obj_t wgl_list_create(wgl_obj_t par, wgl_obj_t copy);
/*======================
* Add/remove functions
*=====================*/
/**
* Add a list element to the list
* @param list pointer to list object
* @param img_fn file name of an image before the text (NULL if unused)
* @param txt text of the list element (NULL if unused)
* @return pointer to the new list element which can be customized (a button)
*/
wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * txt);
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_LIST_H */

View File

@ -1,90 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_OBJ_H
#define WAMR_GRAPHIC_LIBRARY_OBJ_H
#ifdef __cplusplus
extern "C" {
#endif
typedef void * wgl_obj_t;
enum {
WGL_EVENT_PRESSED, /**< The object has been pressed*/
WGL_EVENT_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
WGL_EVENT_PRESS_LOST, /**< User is still pressing but slid cursor/finger off of the object */
WGL_EVENT_SHORT_CLICKED, /**< User pressed object for a short period of time, then released it. Not called if dragged. */
WGL_EVENT_LONG_PRESSED, /**< Object has been pressed for at least `WGL_INDEV_LONG_PRESS_TIME`. Not called if dragged.*/
WGL_EVENT_LONG_PRESSED_REPEAT, /**< Called after `WGL_INDEV_LONG_PRESS_TIME` in every
`WGL_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
WGL_EVENT_CLICKED, /**< Called on release if not dragged (regardless to long press)*/
WGL_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
WGL_EVENT_DRAG_BEGIN,
WGL_EVENT_DRAG_END,
WGL_EVENT_DRAG_THROW_BEGIN,
WGL_EVENT_KEY,
WGL_EVENT_FOCUSED,
WGL_EVENT_DEFOCUSED,
WGL_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
WGL_EVENT_INSERT,
WGL_EVENT_REFRESH,
WGL_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
WGL_EVENT_CANCEL, /**< "Close", "Cancel" or similar specific button has clicked*/
WGL_EVENT_DELETE, /**< Object is being deleted */
};
typedef uint8_t wgl_event_t; /**< Type of event being sent to the object. */
/** Object alignment. */
enum {
WGL_ALIGN_CENTER = 0,
WGL_ALIGN_IN_TOP_LEFT,
WGL_ALIGN_IN_TOP_MID,
WGL_ALIGN_IN_TOP_RIGHT,
WGL_ALIGN_IN_BOTTOM_LEFT,
WGL_ALIGN_IN_BOTTOM_MID,
WGL_ALIGN_IN_BOTTOM_RIGHT,
WGL_ALIGN_IN_LEFT_MID,
WGL_ALIGN_IN_RIGHT_MID,
WGL_ALIGN_OUT_TOP_LEFT,
WGL_ALIGN_OUT_TOP_MID,
WGL_ALIGN_OUT_TOP_RIGHT,
WGL_ALIGN_OUT_BOTTOM_LEFT,
WGL_ALIGN_OUT_BOTTOM_MID,
WGL_ALIGN_OUT_BOTTOM_RIGHT,
WGL_ALIGN_OUT_LEFT_TOP,
WGL_ALIGN_OUT_LEFT_MID,
WGL_ALIGN_OUT_LEFT_BOTTOM,
WGL_ALIGN_OUT_RIGHT_TOP,
WGL_ALIGN_OUT_RIGHT_MID,
WGL_ALIGN_OUT_RIGHT_BOTTOM,
};
typedef uint8_t wgl_align_t;
enum {
WGL_DRAG_DIR_HOR = 0x1, /**< Object can be dragged horizontally. */
WGL_DRAG_DIR_VER = 0x2, /**< Object can be dragged vertically. */
WGL_DRAG_DIR_ALL = 0x3, /**< Object can be dragged in all directions. */
};
typedef uint8_t wgl_drag_dir_t;
typedef void (*wgl_event_cb_t)(wgl_obj_t obj, wgl_event_t event);
void wgl_obj_align(wgl_obj_t obj, wgl_obj_t base, wgl_align_t align, wgl_coord_t x_mod, wgl_coord_t y_mod);
void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb);
wgl_res_t wgl_obj_del(wgl_obj_t obj);
void wgl_obj_del_async(wgl_obj_t obj);
void wgl_obj_clean(wgl_obj_t obj);
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_OBJ_H */

View File

@ -1,29 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_TYPES_H
#define WAMR_GRAPHIC_LIBRARY_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* WGL error codes.
*/
enum {
WGL_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action
function or an operation was failed*/
WGL_RES_OK, /*The object is valid (no deleted) after the action*/
};
typedef uint8_t wgl_res_t;
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_TYPES_H */

View File

@ -0,0 +1,497 @@
/**
* @file lv_conf.h
*
*/
/*
* COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER
*/
#if 1 /*Set it to "1" to enable content*/
#ifndef LV_CONF_H
#define LV_CONF_H
/* clang-format off */
#include <stdint.h>
/*====================
Graphical settings
*====================*/
/* Maximal horizontal and vertical resolution to support by the library.*/
#define LV_HOR_RES_MAX (480)
#define LV_VER_RES_MAX (320)
/* Color depth:
* - 1: 1 byte per pixel
* - 8: RGB233
* - 16: RGB565
* - 32: ARGB8888
*/
#define LV_COLOR_DEPTH 16
/* Swap the 2 bytes of RGB565 color.
* Useful if the display has a 8 bit interface (e.g. SPI)*/
#define LV_COLOR_16_SWAP 0
/* 1: Enable screen transparency.
* Useful for OSD or other overlapping GUIs.
* Requires `LV_COLOR_DEPTH = 32` colors and the screen's style should be modified: `style.body.opa = ...`*/
#define LV_COLOR_SCREEN_TRANSP 0
/*Images pixels with this color will not be drawn (with chroma keying)*/
#define LV_COLOR_TRANSP LV_COLOR_LIME /*LV_COLOR_LIME: pure green*/
/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
#define LV_ANTIALIAS 1
/* Default display refresh period.
* Can be changed in the display driver (`lv_disp_drv_t`).*/
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/
/* Dot Per Inch: used to initialize default sizes.
* E.g. a button with width = LV_DPI / 2 -> half inch wide
* (Not so important, you can adjust it to modify default sizes and spaces)*/
#define LV_DPI 100 /*[px]*/
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
typedef int16_t lv_coord_t;
/*=========================
Memory manager settings
*=========================*/
/* LittelvGL's internal memory manager's settings.
* The graphical objects and other related data are stored here. */
/* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
# define LV_MEM_SIZE (32U * 1024U)
/* Complier prefix for a big array declaration */
# define LV_MEM_ATTR
/* Set an address for the memory pool instead of allocating it as an array.
* Can be in external SRAM too. */
# define LV_MEM_ADR 0
/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */
# define LV_MEM_AUTO_DEFRAG 1
#else /*LV_MEM_CUSTOM*/
# define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
# define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
# define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
#endif /*LV_MEM_CUSTOM*/
/* Garbage Collector settings
* Used if lvgl is binded to higher level language and the memory is managed by that language */
#define LV_ENABLE_GC 0
#if LV_ENABLE_GC != 0
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
# define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/
# define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/
#endif /* LV_ENABLE_GC */
/*=======================
Input device settings
*=======================*/
/* Input device default settings.
* Can be changed in the Input device driver (`lv_indev_drv_t`)*/
/* Input device read period in milliseconds */
#define LV_INDEV_DEF_READ_PERIOD 30
/* Drag threshold in pixels */
#define LV_INDEV_DEF_DRAG_LIMIT 10
/* Drag throw slow-down in [%]. Greater value -> faster slow-down */
#define LV_INDEV_DEF_DRAG_THROW 20
/* Long press time in milliseconds.
* Time to send `LV_EVENT_LONG_PRESSSED`) */
#define LV_INDEV_DEF_LONG_PRESS_TIME 400
/* Repeated trigger period in long press [ms]
* Time between `LV_EVENT_LONG_PRESSED_REPEAT */
#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100
/*==================
* Feature usage
*==================*/
/*1: Enable the Animations */
#define LV_USE_ANIMATION 1
#if LV_USE_ANIMATION
/*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_anim_user_data_t;
#endif
/* 1: Enable shadow drawing*/
#define LV_USE_SHADOW 1
/* 1: Enable object groups (for keyboard/encoder navigation) */
#define LV_USE_GROUP 1
#if LV_USE_GROUP
typedef void * lv_group_user_data_t;
#endif /*LV_USE_GROUP*/
/* 1: Enable GPU interface*/
#define LV_USE_GPU 1
/* 1: Enable file system (might be required for images */
#define LV_USE_FILESYSTEM 1
#if LV_USE_FILESYSTEM
/*Declare the type of the user data of file system drivers (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_fs_drv_user_data_t;
#endif
/*1: Add a `user_data` to drivers and objects*/
#define LV_USE_USER_DATA 0
/*========================
* Image decoder and cache
*========================*/
/* 1: Enable indexed (palette) images */
#define LV_IMG_CF_INDEXED 1
/* 1: Enable alpha indexed images */
#define LV_IMG_CF_ALPHA 1
/* Default image cache size. Image caching keeps the images opened.
* If only the built-in image formats are used there is no real advantage of caching.
* (I.e. no new image decoder is added)
* With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
* However the opened images might consume additional RAM.
* LV_IMG_CACHE_DEF_SIZE must be >= 1 */
#define LV_IMG_CACHE_DEF_SIZE 1
/*Declare the type of the user data of image decoder (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_img_decoder_user_data_t;
/*=====================
* Compiler settings
*====================*/
/* Define a custom attribute to `lv_tick_inc` function */
#define LV_ATTRIBUTE_TICK_INC
/* Define a custom attribute to `lv_task_handler` function */
#define LV_ATTRIBUTE_TASK_HANDLER
/* With size optimization (-Os) the compiler might not align data to
* 4 or 8 byte boundary. This alignment will be explicitly applied where needed.
* E.g. __attribute__((aligned(4))) */
#define LV_ATTRIBUTE_MEM_ALIGN
/* Attribute to mark large constant arrays for example
* font's bitmaps */
#define LV_ATTRIBUTE_LARGE_CONST
/*===================
* HAL settings
*==================*/
/* 1: use a custom tick source.
* It removes the need to manually update the tick with `lv_tick_inc`) */
#define LV_TICK_CUSTOM 0
#if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif /*LV_TICK_CUSTOM*/
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/
/*================
* Log settings
*===============*/
/*1: Enable the log module*/
#define LV_USE_LOG 0
#if LV_USE_LOG
/* How important log should be added:
* LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
* LV_LOG_LEVEL_INFO Log important events
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
* LV_LOG_LEVEL_NONE Do not log anything
*/
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
/* 1: Print the log with 'printf';
* 0: user need to register a callback with `lv_log_register_print`*/
# define LV_LOG_PRINTF 0
#endif /*LV_USE_LOG*/
/*================
* THEME USAGE
*================*/
#define LV_THEME_LIVE_UPDATE 0 /*1: Allow theme switching at run time. Uses 8..10 kB of RAM*/
#define LV_USE_THEME_TEMPL 0 /*Just for test*/
#define LV_USE_THEME_DEFAULT 0 /*Built mainly from the built-in styles. Consumes very few RAM*/
#define LV_USE_THEME_ALIEN 0 /*Dark futuristic theme*/
#define LV_USE_THEME_NIGHT 0 /*Dark elegant theme*/
#define LV_USE_THEME_MONO 0 /*Mono color theme for monochrome displays*/
#define LV_USE_THEME_MATERIAL 0 /*Flat theme with bold colors and light shadows*/
#define LV_USE_THEME_ZEN 0 /*Peaceful, mainly light theme */
#define LV_USE_THEME_NEMO 0 /*Water-like theme based on the movie "Finding Nemo"*/
/*==================
* FONT USAGE
*===================*/
/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel.
* The symbols are available via `LV_SYMBOL_...` defines
* More info about fonts: https://docs.littlevgl.com/#Fonts
* To create a new font go to: https://littlevgl.com/ttf-font-to-c-array
*/
/* Robot fonts with bpp = 4
* https://fonts.google.com/specimen/Roboto */
#define LV_FONT_ROBOTO_12 0
#define LV_FONT_ROBOTO_16 1
#define LV_FONT_ROBOTO_22 0
#define LV_FONT_ROBOTO_28 0
/*Pixel perfect monospace font
* http://pelulamu.net/unscii/ */
#define LV_FONT_UNSCII_8 0
/* Optionally declare your custom fonts here.
* You can use these fonts as default font too
* and they will be available globally. E.g.
* #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \
* LV_FONT_DECLARE(my_font_2)
*/
#define LV_FONT_CUSTOM_DECLARE
/*Always set a default font from the built-in fonts*/
#define LV_FONT_DEFAULT &lv_font_roboto_16
/* Enable it if you have fonts with a lot of characters.
* The limit depends on the font size, font face and bpp
* but with > 10,000 characters if you see issues probably you need to enable it.*/
#define LV_FONT_FMT_TXT_LARGE 0
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_font_user_data_t;
/*=================
* Text settings
*=================*/
/* Select a character encoding for strings.
* Your IDE or editor should have the same character encoding
* - LV_TXT_ENC_UTF8
* - LV_TXT_ENC_ASCII
* */
#define LV_TXT_ENC LV_TXT_ENC_UTF8
/*Can break (wrap) texts on these chars*/
#define LV_TXT_BREAK_CHARS " ,.;:-_"
/*===================
* LV_OBJ SETTINGS
*==================*/
/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_obj_user_data_t;
/*1: enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
#define LV_USE_OBJ_REALIGN 1
/* Enable to make the object clickable on a larger area.
* LV_EXT_CLICK_AREA_OFF or 0: Disable this feature
* LV_EXT_CLICK_AREA_TINY: The extra area can be adjusted horizontally and vertically (0..255 px)
* LV_EXT_CLICK_AREA_FULL: The extra area can be adjusted in all 4 directions (-32k..+32k px)
*/
#define LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_OFF
/*==================
* LV OBJ X USAGE
*================*/
/*
* Documentation of the object types: https://docs.littlevgl.com/#Object-types
*/
/*Arc (dependencies: -)*/
#define LV_USE_ARC 1
/*Bar (dependencies: -)*/
#define LV_USE_BAR 1
/*Button (dependencies: lv_cont*/
#define LV_USE_BTN 1
#if LV_USE_BTN != 0
/*Enable button-state animations - draw a circle on click (dependencies: LV_USE_ANIMATION)*/
# define LV_BTN_INK_EFFECT 0
#endif
/*Button matrix (dependencies: -)*/
#define LV_USE_BTNM 1
/*Calendar (dependencies: -)*/
#define LV_USE_CALENDAR 1
/*Canvas (dependencies: lv_img)*/
#define LV_USE_CANVAS 1
/*Check box (dependencies: lv_btn, lv_label)*/
#define LV_USE_CB 1
/*Chart (dependencies: -)*/
#define LV_USE_CHART 1
#if LV_USE_CHART
# define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 20
#endif
/*Container (dependencies: -*/
#define LV_USE_CONT 1
/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/
#define LV_USE_DDLIST 1
#if LV_USE_DDLIST != 0
/*Open and close default animation time [ms] (0: no animation)*/
# define LV_DDLIST_DEF_ANIM_TIME 200
#endif
/*Gauge (dependencies:lv_bar, lv_lmeter)*/
#define LV_USE_GAUGE 1
/*Image (dependencies: lv_label*/
#define LV_USE_IMG 1
/*Image Button (dependencies: lv_btn*/
#define LV_USE_IMGBTN 1
#if LV_USE_IMGBTN
/*1: The imgbtn requires left, mid and right parts and the width can be set freely*/
# define LV_IMGBTN_TILED 0
#endif
/*Keyboard (dependencies: lv_btnm)*/
#define LV_USE_KB 1
/*Label (dependencies: -*/
#define LV_USE_LABEL 1
#if LV_USE_LABEL != 0
/*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_ROLL/ROLL_CIRC' mode*/
# define LV_LABEL_DEF_SCROLL_SPEED 25
/* Waiting period at beginning/end of animation cycle */
# define LV_LABEL_WAIT_CHAR_COUNT 3
/*Enable selecting text of the label */
# define LV_LABEL_TEXT_SEL 0
/*Store extra some info in labels (12 bytes) to speed up drawing of very long texts*/
# define LV_LABEL_LONG_TXT_HINT 0
#endif
/*LED (dependencies: -)*/
#define LV_USE_LED 1
/*Line (dependencies: -*/
#define LV_USE_LINE 1
/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/
#define LV_USE_LIST 1
#if LV_USE_LIST != 0
/*Default animation time of focusing to a list element [ms] (0: no animation) */
# define LV_LIST_DEF_ANIM_TIME 100
#endif
/*Line meter (dependencies: *;)*/
#define LV_USE_LMETER 1
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
#define LV_USE_MBOX 1
/*Page (dependencies: lv_cont)*/
#define LV_USE_PAGE 1
#if LV_USE_PAGE != 0
/*Focus default animation time [ms] (0: no animation)*/
# define LV_PAGE_DEF_ANIM_TIME 400
#endif
/*Preload (dependencies: lv_arc, lv_anim)*/
#define LV_USE_PRELOAD 1
#if LV_USE_PRELOAD != 0
# define LV_PRELOAD_DEF_ARC_LENGTH 60 /*[deg]*/
# define LV_PRELOAD_DEF_SPIN_TIME 1000 /*[ms]*/
# define LV_PRELOAD_DEF_ANIM LV_PRELOAD_TYPE_SPINNING_ARC
#endif
/*Roller (dependencies: lv_ddlist)*/
#define LV_USE_ROLLER 1
#if LV_USE_ROLLER != 0
/*Focus animation time [ms] (0: no animation)*/
# define LV_ROLLER_DEF_ANIM_TIME 200
/*Number of extra "pages" when the roller is infinite*/
# define LV_ROLLER_INF_PAGES 7
#endif
/*Slider (dependencies: lv_bar)*/
#define LV_USE_SLIDER 1
/*Spinbox (dependencies: lv_ta)*/
#define LV_USE_SPINBOX 1
/*Switch (dependencies: lv_slider)*/
#define LV_USE_SW 1
/*Text area (dependencies: lv_label, lv_page)*/
#define LV_USE_TA 1
#if LV_USE_TA != 0
# define LV_TA_DEF_CURSOR_BLINK_TIME 400 /*ms*/
# define LV_TA_DEF_PWD_SHOW_TIME 1500 /*ms*/
#endif
/*Table (dependencies: lv_label)*/
#define LV_USE_TABLE 1
#if LV_USE_TABLE
# define LV_TABLE_COL_MAX 12
#endif
/*Tab (dependencies: lv_page, lv_btnm)*/
#define LV_USE_TABVIEW 1
# if LV_USE_TABVIEW != 0
/*Time of slide animation [ms] (0: no animation)*/
# define LV_TABVIEW_DEF_ANIM_TIME 300
#endif
/*Tileview (dependencies: lv_page) */
#define LV_USE_TILEVIEW 1
#if LV_USE_TILEVIEW
/*Time of slide animation [ms] (0: no animation)*/
# define LV_TILEVIEW_DEF_ANIM_TIME 300
#endif
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
#define LV_USE_WIN 1
/*==================
* Non-user section
*==================*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/
# define _CRT_SECURE_NO_WARNINGS
#endif
/*--END OF LV_CONF_H--*/
/*Be sure every define has a default value*/
//#include "../lv_conf_checker.h"
#endif /*LV_CONF_H*/
#endif /*End of "Content enable"*/

View File

@ -1,8 +0,0 @@
MIT licence
Copyright (c) 2016 Gábor Kiss-Vámosi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,75 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_BTN_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_BTN_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../inc/wgl_btn.h"
/** Possible states of a button.
* It can be used not only by buttons but other button-like objects too*/
enum {
/**Released*/
LV_BTN_STATE_REL,
/**Pressed*/
LV_BTN_STATE_PR,
/**Toggled released*/
LV_BTN_STATE_TGL_REL,
/**Toggled pressed*/
LV_BTN_STATE_TGL_PR,
/**Inactive*/
LV_BTN_STATE_INA,
/**Number of states*/
_LV_BTN_STATE_NUM,
};
typedef wgl_btn_state_t lv_btn_state_t;
/**Styles*/
enum {
/** Release style */
LV_BTN_STYLE_REL,
/**Pressed style*/
LV_BTN_STYLE_PR,
/** Toggle released style*/
LV_BTN_STYLE_TGL_REL,
/** Toggle pressed style */
LV_BTN_STYLE_TGL_PR,
/** Inactive style*/
LV_BTN_STYLE_INA,
};
typedef wgl_btn_style_t lv_btn_style_t;
#define lv_btn_create wgl_btn_create
#define lv_btn_set_toggle wgl_btn_set_toggle
#define lv_btn_set_state wgl_btn_set_state
#define lv_btn_toggle wgl_btn_toggle
#define lv_btn_set_ink_in_time wgl_btn_set_ink_in_time
#define lv_btn_set_ink_wait_time wgl_btn_set_ink_wait_time
#define lv_btn_set_ink_out_time wgl_btn_set_ink_out_time
#define lv_btn_get_state wgl_btn_get_state
#define lv_btn_get_toggle wgl_btn_get_toggle
#define lv_btn_get_ink_in_time wgl_btn_get_ink_in_time
#define lv_btn_get_ink_wait_time wgl_btn_get_ink_wait_time
#define lv_btn_get_ink_out_time wgl_btn_get_ink_out_time
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_BTN_LVGL_COMPATIBLE_H */

View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_CB_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_CB_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../inc/wgl_cb.h"
/** Checkbox styles. */
enum {
LV_CB_STYLE_BG, /**< Style of object background. */
LV_CB_STYLE_BOX_REL, /**< Style of box (released). */
LV_CB_STYLE_BOX_PR, /**< Style of box (pressed). */
LV_CB_STYLE_BOX_TGL_REL, /**< Style of box (released but checked). */
LV_CB_STYLE_BOX_TGL_PR, /**< Style of box (pressed and checked). */
LV_CB_STYLE_BOX_INA, /**< Style of disabled box */
};
typedef wgl_cb_style_t lv_cb_style_t;
#define lv_cb_create wgl_cb_create
#define lv_cb_set_text wgl_cb_set_text
#define lv_cb_set_static_text wgl_cb_set_static_text
#define lv_cb_get_text(cb) wgl_cb_get_text(cb, g_widget_text, 100)
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_CB_LVGL_COMPATIBLE_H */

View File

@ -1,50 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_LABEL_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_LABEL_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../inc/wgl_label.h"
/** Long mode behaviors. Used in 'lv_label_ext_t' */
enum {
LV_LABEL_LONG_EXPAND, /**< Expand the object size to the text size*/
LV_LABEL_LONG_BREAK, /**< Keep the object width, break the too long lines and expand the object
height*/
LV_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
LV_LABEL_LONG_SROLL, /**< Keep the size and roll the text back and forth*/
LV_LABEL_LONG_SROLL_CIRC, /**< Keep the size and roll the text circularly*/
LV_LABEL_LONG_CROP, /**< Keep the size and crop the text out of it*/
};
typedef wgl_label_long_mode_t lv_label_long_mode_t;
/** Label align policy*/
enum {
LV_LABEL_ALIGN_LEFT, /**< Align text to left */
LV_LABEL_ALIGN_CENTER, /**< Align text to center */
LV_LABEL_ALIGN_RIGHT, /**< Align text to right */
};
typedef wgl_label_align_t lv_label_align_t;
/** Label styles*/
enum {
LV_LABEL_STYLE_MAIN,
};
typedef wgl_label_style_t lv_label_style_t;
#define lv_label_create wgl_label_create
#define lv_label_set_text wgl_label_set_text
#define lv_label_get_text(label) wgl_label_get_text(label, g_widget_text, 100)
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_LABEL_LVGL_COMPATIBLE_H */

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_LIST_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_LIST_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../inc/wgl_list.h"
/** List styles. */
enum {
LV_LIST_STYLE_BG, /**< List background style */
LV_LIST_STYLE_SCRL, /**< List scrollable area style. */
LV_LIST_STYLE_SB, /**< List scrollbar style. */
LV_LIST_STYLE_EDGE_FLASH, /**< List edge flash style. */
LV_LIST_STYLE_BTN_REL, /**< Same meaning as the ordinary button styles. */
LV_LIST_STYLE_BTN_PR,
LV_LIST_STYLE_BTN_TGL_REL,
LV_LIST_STYLE_BTN_TGL_PR,
LV_LIST_STYLE_BTN_INA,
};
typedef wgl_list_style_t lv_list_style_t;
#define lv_list_create wgl_list_create
#define lv_list_add_btn wgl_list_add_btn
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_LIST_LVGL_COMPATIBLE_H */

View File

@ -1,89 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_OBJ_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_OBJ_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../inc/wgl_obj.h"
typedef void lv_obj_t;
enum {
LV_EVENT_PRESSED,
LV_EVENT_PRESSING,
LV_EVENT_PRESS_LOST,
LV_EVENT_SHORT_CLICKED,
LV_EVENT_LONG_PRESSED,
LV_EVENT_LONG_PRESSED_REPEAT,
LV_EVENT_CLICKED,
LV_EVENT_RELEASED,
LV_EVENT_DRAG_BEGIN,
LV_EVENT_DRAG_END,
LV_EVENT_DRAG_THROW_BEGIN,
LV_EVENT_KEY,
LV_EVENT_FOCUSED,
LV_EVENT_DEFOCUSED,
LV_EVENT_VALUE_CHANGED,
LV_EVENT_INSERT,
LV_EVENT_REFRESH,
LV_EVENT_APPLY,
LV_EVENT_CANCEL,
LV_EVENT_DELETE,
};
typedef wgl_event_t lv_event_t;
/** Object alignment. */
enum {
LV_ALIGN_CENTER,
LV_ALIGN_IN_TOP_LEFT,
LV_ALIGN_IN_TOP_MID,
LV_ALIGN_IN_TOP_RIGHT,
LV_ALIGN_IN_BOTTOM_LEFT,
LV_ALIGN_IN_BOTTOM_MID,
LV_ALIGN_IN_BOTTOM_RIGHT,
LV_ALIGN_IN_LEFT_MID,
LV_ALIGN_IN_RIGHT_MID,
LV_ALIGN_OUT_TOP_LEFT,
LV_ALIGN_OUT_TOP_MID,
LV_ALIGN_OUT_TOP_RIGHT,
LV_ALIGN_OUT_BOTTOM_LEFT,
LV_ALIGN_OUT_BOTTOM_MID,
LV_ALIGN_OUT_BOTTOM_RIGHT,
LV_ALIGN_OUT_LEFT_TOP,
LV_ALIGN_OUT_LEFT_MID,
LV_ALIGN_OUT_LEFT_BOTTOM,
LV_ALIGN_OUT_RIGHT_TOP,
LV_ALIGN_OUT_RIGHT_MID,
LV_ALIGN_OUT_RIGHT_BOTTOM,
};
typedef wgl_align_t lv_align_t;
enum {
LV_DRAG_DIR_HOR,
LV_DRAG_DIR_VER,
LV_DRAG_DIR_ALL,
};
typedef wgl_drag_dir_t lv_drag_dir_t;
#define lv_obj_align wgl_obj_align
#define lv_obj_set_event_cb wgl_obj_set_event_cb
#define lv_obj_del wgl_obj_del
#define lv_obj_del_async wgl_obj_del_async
#define lv_obj_clean wgl_obj_clean
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_OBJ_LVGL_COMPATIBLE_H */

View File

@ -1,28 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_TYPES_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_TYPES_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../inc/wgl_types.h"
/**
* error codes.
*/
enum {
LV_RES_INV,
LV_RES_OK,
};
typedef wgl_res_t lv_res_t;
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_TYPES_LVGL_COMPATIBLE_H */

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "bi-inc/wgl_shared_utils.h" /* shared types between app and native */
#include "lvgl-compatible/lv_types.h"
#include "lvgl-compatible/lv_obj.h"
#include "lvgl-compatible/lv_btn.h"
#include "lvgl-compatible/lv_cb.h"
#include "lvgl-compatible/lv_label.h"
#include "lvgl-compatible/lv_list.h"
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H */

View File

@ -0,0 +1,916 @@
/**
* @file lv_obj.h
*
*/
#ifndef LV_OBJ_H
#define LV_OBJ_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../../lv_conf.h"
#endif
#include <stddef.h>
#include <stdbool.h>
#include "lv_style.h"
#include "../lv_misc/lv_types.h"
#include "../lv_misc/lv_area.h"
#include "../lv_misc/lv_mem.h"
#include "../lv_misc/lv_ll.h"
#include "../lv_misc/lv_color.h"
#include "../lv_misc/lv_log.h"
#include "../lv_hal/lv_hal.h"
/*********************
* DEFINES
*********************/
/*Error check of lv_conf.h*/
#if LV_HOR_RES_MAX == 0 || LV_VER_RES_MAX == 0
#error "LittlevGL: LV_HOR_RES_MAX and LV_VER_RES_MAX must be greater than 0"
#endif
#if LV_ANTIALIAS > 1
#error "LittlevGL: LV_ANTIALIAS can be only 0 or 1"
#endif
#define LV_MAX_ANCESTOR_NUM 8
#define LV_EXT_CLICK_AREA_OFF 0
#define LV_EXT_CLICK_AREA_TINY 1
#define LV_EXT_CLICK_AREA_FULL 2
/**********************
* TYPEDEFS
**********************/
struct _lv_obj_t;
/** Design modes */
enum {
LV_DESIGN_DRAW_MAIN, /**< Draw the main portion of the object */
LV_DESIGN_DRAW_POST, /**< Draw extras on the object */
LV_DESIGN_COVER_CHK, /**< Check if the object fully covers the 'mask_p' area */
};
typedef uint8_t lv_design_mode_t;
/**
* The design callback is used to draw the object on the screen.
* It accepts the object, a mask area, and the mode in which to draw the object.
*/
typedef bool (*lv_design_cb_t)(struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
enum {
LV_EVENT_PRESSED, /**< The object has been pressed*/
LV_EVENT_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
LV_EVENT_PRESS_LOST, /**< User is still pressing but slid cursor/finger off of the object */
LV_EVENT_SHORT_CLICKED, /**< User pressed object for a short period of time, then released it. Not called if dragged. */
LV_EVENT_LONG_PRESSED, /**< Object has been pressed for at least `LV_INDEV_LONG_PRESS_TIME`. Not called if dragged.*/
LV_EVENT_LONG_PRESSED_REPEAT, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every
`LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
LV_EVENT_CLICKED, /**< Called on release if not dragged (regardless to long press)*/
LV_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
LV_EVENT_DRAG_BEGIN,
LV_EVENT_DRAG_END,
LV_EVENT_DRAG_THROW_BEGIN,
LV_EVENT_KEY,
LV_EVENT_FOCUSED,
LV_EVENT_DEFOCUSED,
LV_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
LV_EVENT_INSERT,
LV_EVENT_REFRESH,
LV_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
LV_EVENT_CANCEL, /**< "Close", "Cancel" or similar specific button has clicked*/
LV_EVENT_DELETE, /**< Object is being deleted */
};
typedef uint8_t lv_event_t; /**< Type of event being sent to the object. */
/**
* @brief Event callback.
* Events are used to notify the user of some action being taken on the object.
* For details, see ::lv_event_t.
*/
typedef void (*lv_event_cb_t)(struct _lv_obj_t * obj, lv_event_t event);
/** Signals are for use by the object itself or to extend the object's functionality.
* Applications should use ::lv_obj_set_event_cb to be notified of events that occur
* on the object. */
enum {
/*General signals*/
LV_SIGNAL_CLEANUP, /**< Object is being deleted */
LV_SIGNAL_CHILD_CHG, /**< Child was removed/added */
LV_SIGNAL_CORD_CHG, /**< Object coordinates/size have changed */
LV_SIGNAL_PARENT_SIZE_CHG, /**< Parent's size has changed */
LV_SIGNAL_STYLE_CHG, /**< Object's style has changed */
LV_SIGNAL_REFR_EXT_DRAW_PAD, /**< Object's extra padding has changed */
LV_SIGNAL_GET_TYPE, /**< LittlevGL needs to retrieve the object's type */
/*Input device related*/
LV_SIGNAL_PRESSED, /**< The object has been pressed*/
LV_SIGNAL_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
LV_SIGNAL_PRESS_LOST, /**< User is still pressing but slid cursor/finger off of the object */
LV_SIGNAL_RELEASED, /**< User pressed object for a short period of time, then released it. Not called if dragged. */
LV_SIGNAL_LONG_PRESS, /**< Object has been pressed for at least `LV_INDEV_LONG_PRESS_TIME`. Not called if dragged.*/
LV_SIGNAL_LONG_PRESS_REP, /**< Called after `LV_INDEV_LONG_PRESS_TIME` in every `LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
LV_SIGNAL_DRAG_BEGIN,
LV_SIGNAL_DRAG_END,
/*Group related*/
LV_SIGNAL_FOCUS,
LV_SIGNAL_DEFOCUS,
LV_SIGNAL_CONTROL,
LV_SIGNAL_GET_EDITABLE,
};
typedef uint8_t lv_signal_t;
typedef lv_res_t (*lv_signal_cb_t)(struct _lv_obj_t * obj, lv_signal_t sign, void * param);
/** Object alignment. */
enum {
LV_ALIGN_CENTER = 0,
LV_ALIGN_IN_TOP_LEFT,
LV_ALIGN_IN_TOP_MID,
LV_ALIGN_IN_TOP_RIGHT,
LV_ALIGN_IN_BOTTOM_LEFT,
LV_ALIGN_IN_BOTTOM_MID,
LV_ALIGN_IN_BOTTOM_RIGHT,
LV_ALIGN_IN_LEFT_MID,
LV_ALIGN_IN_RIGHT_MID,
LV_ALIGN_OUT_TOP_LEFT,
LV_ALIGN_OUT_TOP_MID,
LV_ALIGN_OUT_TOP_RIGHT,
LV_ALIGN_OUT_BOTTOM_LEFT,
LV_ALIGN_OUT_BOTTOM_MID,
LV_ALIGN_OUT_BOTTOM_RIGHT,
LV_ALIGN_OUT_LEFT_TOP,
LV_ALIGN_OUT_LEFT_MID,
LV_ALIGN_OUT_LEFT_BOTTOM,
LV_ALIGN_OUT_RIGHT_TOP,
LV_ALIGN_OUT_RIGHT_MID,
LV_ALIGN_OUT_RIGHT_BOTTOM,
};
typedef uint8_t lv_align_t;
#if LV_USE_OBJ_REALIGN
typedef struct
{
const struct _lv_obj_t * base;
lv_coord_t xofs;
lv_coord_t yofs;
lv_align_t align;
uint8_t auto_realign : 1;
uint8_t origo_align : 1; /**< 1: the origo (center of the object) was aligned with
`lv_obj_align_origo`*/
} lv_reailgn_t;
#endif
enum {
LV_DRAG_DIR_HOR = 0x1, /**< Object can be dragged horizontally. */
LV_DRAG_DIR_VER = 0x2, /**< Object can be dragged vertically. */
LV_DRAG_DIR_ALL = 0x3, /**< Object can be dragged in all directions. */
};
typedef uint8_t lv_drag_dir_t;
typedef void lv_obj_t;
typedef void lv_obj_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Init. the 'lv' library.
*/
void lv_init(void);
/*--------------------
* Create and delete
*-------------------*/
/**
* Create a basic object
* @param parent pointer to a parent object.
* If NULL then a screen will be created
* @param copy pointer to a base object, if not NULL then the new object will be copied from it
* @return pointer to the new object
*/
lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy);
/**
* Delete 'obj' and all of its children
* @param obj pointer to an object to delete
* @return LV_RES_INV because the object is deleted
*/
lv_res_t lv_obj_del(lv_obj_t * obj);
/**
* Helper function for asynchronously deleting objects.
* Useful for cases where you can't delete an object directly in an `LV_EVENT_DELETE` handler (i.e. parent).
* @param obj object to delete
* @see lv_async_call
*/
void lv_obj_del_async(struct _lv_obj_t *obj);
/**
* Delete all children of an object
* @param obj pointer to an object
*/
void lv_obj_clean(lv_obj_t * obj);
/**
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
* @param obj pointer to an object
*/
void lv_obj_invalidate(const lv_obj_t * obj);
/*=====================
* Setter functions
*====================*/
/*--------------------
* Parent/children set
*--------------------*/
/**
* Set a new parent for an object. Its relative position will be the same.
* @param obj pointer to an object. Can't be a screen.
* @param parent pointer to the new parent object. (Can't be NULL)
*/
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
/**
* Move and object to the foreground
* @param obj pointer to an object
*/
void lv_obj_move_foreground(lv_obj_t * obj);
/**
* Move and object to the background
* @param obj pointer to an object
*/
void lv_obj_move_background(lv_obj_t * obj);
/*--------------------
* Coordinate set
* ------------------*/
/**
* Set relative the position of an object (relative to the parent)
* @param obj pointer to an object
* @param x new distance from the left side of the parent
* @param y new distance from the top of the parent
*/
void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y);
/**
* Set the x coordinate of a object
* @param obj pointer to an object
* @param x new distance from the left side from the parent
*/
void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x);
/**
* Set the y coordinate of a object
* @param obj pointer to an object
* @param y new distance from the top of the parent
*/
void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y);
/**
* Set the size of an object
* @param obj pointer to an object
* @param w new width
* @param h new height
*/
void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h);
/**
* Set the width of an object
* @param obj pointer to an object
* @param w new width
*/
void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w);
/**
* Set the height of an object
* @param obj pointer to an object
* @param h new height
*/
void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h);
/**
* Align an object to an other object.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
*/
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
/**
* Align an object to an other object.
* @param obj pointer to an object to align
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
* @param align type of alignment (see 'lv_align_t' enum)
* @param x_mod x coordinate shift after alignment
* @param y_mod y coordinate shift after alignment
*/
void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
/**
* Realign the object based on the last `lv_obj_align` parameters.
* @param obj pointer to an object
*/
void lv_obj_realign(lv_obj_t * obj);
/**
* Enable the automatic realign of the object when its size has changed based on the last
* `lv_obj_align` parameters.
* @param obj pointer to an object
* @param en true: enable auto realign; false: disable auto realign
*/
void lv_obj_set_auto_realign(lv_obj_t * obj, bool en);
/**
* Set the size of an extended clickable area
* @param obj pointer to an object
* @param left extended clickable are on the left [px]
* @param right extended clickable are on the right [px]
* @param top extended clickable are on the top [px]
* @param bottom extended clickable are on the bottom [px]
*/
void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right, lv_coord_t top, lv_coord_t bottom);
/*---------------------
* Appearance set
*--------------------*/
/**
* Set a new style for an object
* @param obj pointer to an object
* @param style_p pointer to the new style
*/
void lv_obj_set_style(lv_obj_t * obj, const lv_style_t * style);
/**
* Notify an object about its style is modified
* @param obj pointer to an object
*/
void lv_obj_refresh_style(lv_obj_t * obj);
/**
* Notify all object if a style is modified
* @param style pointer to a style. Only the objects with this style will be notified
* (NULL to notify all objects)
*/
void lv_obj_report_style_mod(lv_style_t * style);
/*-----------------
* Attribute set
*----------------*/
/**
* Hide an object. It won't be visible and clickable.
* @param obj pointer to an object
* @param en true: hide the object
*/
void lv_obj_set_hidden(lv_obj_t * obj, bool en);
/**
* Enable or disable the clicking of an object
* @param obj pointer to an object
* @param en true: make the object clickable
*/
void lv_obj_set_click(lv_obj_t * obj, bool en);
/**
* Enable to bring this object to the foreground if it
* or any of its children is clicked
* @param obj pointer to an object
* @param en true: enable the auto top feature
*/
void lv_obj_set_top(lv_obj_t * obj, bool en);
/**
* Enable the dragging of an object
* @param obj pointer to an object
* @param en true: make the object dragable
*/
void lv_obj_set_drag(lv_obj_t * obj, bool en);
/**
* Set the directions an object can be dragged in
* @param obj pointer to an object
* @param drag_dir bitwise OR of allowed drag directions
*/
void lv_obj_set_drag_dir(lv_obj_t * obj, lv_drag_dir_t drag_dir);
/**
* Enable the throwing of an object after is is dragged
* @param obj pointer to an object
* @param en true: enable the drag throw
*/
void lv_obj_set_drag_throw(lv_obj_t * obj, bool en);
/**
* Enable to use parent for drag related operations.
* If trying to drag the object the parent will be moved instead
* @param obj pointer to an object
* @param en true: enable the 'drag parent' for the object
*/
void lv_obj_set_drag_parent(lv_obj_t * obj, bool en);
/**
* Propagate the events to the parent too
* @param obj pointer to an object
* @param en true: enable the event propagation
*/
void lv_obj_set_parent_event(lv_obj_t * obj, bool en);
/**
* Set the opa scale enable parameter (required to set opa_scale with `lv_obj_set_opa_scale()`)
* @param obj pointer to an object
* @param en true: opa scaling is enabled for this object and all children; false: no opa scaling
*/
void lv_obj_set_opa_scale_enable(lv_obj_t * obj, bool en);
/**
* Set the opa scale of an object.
* The opacity of this object and all it's children will be scaled down with this factor.
* `lv_obj_set_opa_scale_enable(obj, true)` needs to be called to enable it.
* (not for all children just for the parent where to start the opa scaling)
* @param obj pointer to an object
* @param opa_scale a factor to scale down opacity [0..255]
*/
void lv_obj_set_opa_scale(lv_obj_t * obj, lv_opa_t opa_scale);
/**
* Set a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from `lv_protect_t`
*/
void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
/**
* Clear a bit or bits in the protect filed
* @param obj pointer to an object
* @param prot 'OR'-ed values from `lv_protect_t`
*/
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
/**
* Set a an event handler function for an object.
* Used by the user to react on event which happens with the object.
* @param obj pointer to an object
* @param event_cb the new event function
*/
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb);
/**
* Send an event to the object
* @param obj pointer to an object
* @param event the type of the event from `lv_event_t`.
* @param data arbitrary data depending on the object type and the event. (Usually `NULL`)
* @return LV_RES_OK: `obj` was not deleted in the event; LV_RES_INV: `obj` was deleted in the event
*/
lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data);
/**
* Call an event function with an object, event, and data.
* @param event_xcb an event callback function. If `NULL` `LV_RES_OK` will return without any actions.
* (the 'x' in the argument name indicates that its not a fully generic function because it not follows
* the `func_name(object, callback, ...)` convention)
* @param obj pointer to an object to associate with the event (can be `NULL` to simply call the `event_cb`)
* @param event an event
* @param data pointer to a custom data
* @return LV_RES_OK: `obj` was not deleted in the event; LV_RES_INV: `obj` was deleted in the event
*/
lv_res_t lv_event_send_func(lv_event_cb_t event_xcb, lv_obj_t * obj, lv_event_t event, const void * data);
/**
* Get the `data` parameter of the current event
* @return the `data` parameter
*/
const void * lv_event_get_data(void);
/**
* Set the a signal function of an object. Used internally by the library.
* Always call the previous signal function in the new.
* @param obj pointer to an object
* @param signal_cb the new signal function
*/
void lv_obj_set_signal_cb(lv_obj_t * obj, lv_signal_cb_t signal_cb);
/**
* Send an event to the object
* @param obj pointer to an object
* @param event the type of the event from `lv_event_t`.
*/
void lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param);
/**
* Set a new design function for an object
* @param obj pointer to an object
* @param design_cb the new design function
*/
void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t design_cb);
/*----------------
* Other set
*--------------*/
/**
* Allocate a new ext. data for an object
* @param obj pointer to an object
* @param ext_size the size of the new ext. data
* @return pointer to the allocated ext
*/
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size);
/**
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
* @param obj pointer to an object
*/
void lv_obj_refresh_ext_draw_pad(lv_obj_t * obj);
/*=======================
* Getter functions
*======================*/
/**
* Return with the screen of an object
* @param obj pointer to an object
* @return pointer to a screen
*/
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj);
/**
* Get the display of an object
* @param scr pointer to an object
* @return pointer the object's display
*/
lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj);
/*---------------------
* Parent/children get
*--------------------*/
/**
* Returns with the parent of an object
* @param obj pointer to an object
* @return pointer to the parent of 'obj'
*/
lv_obj_t * lv_obj_get_parent(const lv_obj_t * obj);
/**
* Iterate through the children of an object (start from the "youngest, lastly created")
* @param obj pointer to an object
* @param child NULL at first call to get the next children
* and the previous return value later
* @return the child after 'act_child' or NULL if no more child
*/
lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child);
/**
* Iterate through the children of an object (start from the "oldest", firstly created)
* @param obj pointer to an object
* @param child NULL at first call to get the next children
* and the previous return value later
* @return the child after 'act_child' or NULL if no more child
*/
lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child);
/**
* Count the children of an object (only children directly on 'obj')
* @param obj pointer to an object
* @return children number of 'obj'
*/
uint16_t lv_obj_count_children(const lv_obj_t * obj);
/** Recursively count the children of an object
* @param obj pointer to an object
* @return children number of 'obj'
*/
uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj);
/*---------------------
* Coordinate get
*--------------------*/
/**
* Copy the coordinates of an object to an area
* @param obj pointer to an object
* @param cords_p pointer to an area to store the coordinates
*/
void lv_obj_get_coords(const lv_obj_t * obj, lv_area_t * cords_p);
/**
* Reduce area retried by `lv_obj_get_coords()` the get graphically usable area of an object.
* (Without the size of the border or other extra graphical elements)
* @param coords_p store the result area here
*/
void lv_obj_get_inner_coords(const lv_obj_t * obj, lv_area_t * coords_p);
/**
* Get the x coordinate of object
* @param obj pointer to an object
* @return distance of 'obj' from the left side of its parent
*/
lv_coord_t lv_obj_get_x(const lv_obj_t * obj);
/**
* Get the y coordinate of object
* @param obj pointer to an object
* @return distance of 'obj' from the top of its parent
*/
lv_coord_t lv_obj_get_y(const lv_obj_t * obj);
/**
* Get the width of an object
* @param obj pointer to an object
* @return the width
*/
lv_coord_t lv_obj_get_width(const lv_obj_t * obj);
/**
* Get the height of an object
* @param obj pointer to an object
* @return the height
*/
lv_coord_t lv_obj_get_height(const lv_obj_t * obj);
/**
* Get that width reduced by the left and right padding.
* @param obj pointer to an object
* @return the width which still fits into the container
*/
lv_coord_t lv_obj_get_width_fit(lv_obj_t * obj);
/**
* Get that height reduced by the top an bottom padding.
* @param obj pointer to an object
* @return the height which still fits into the container
*/
lv_coord_t lv_obj_get_height_fit(lv_obj_t * obj);
/**
* Get the automatic realign property of the object.
* @param obj pointer to an object
* @return true: auto realign is enabled; false: auto realign is disabled
*/
bool lv_obj_get_auto_realign(lv_obj_t * obj);
/**
* Get the left padding of extended clickable area
* @param obj pointer to an object
* @return the extended left padding
*/
lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj);
/**
* Get the right padding of extended clickable area
* @param obj pointer to an object
* @return the extended right padding
*/
lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj);
/**
* Get the top padding of extended clickable area
* @param obj pointer to an object
* @return the extended top padding
*/
lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj);
/**
* Get the bottom padding of extended clickable area
* @param obj pointer to an object
* @return the extended bottom padding
*/
lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj);
/**
* Get the extended size attribute of an object
* @param obj pointer to an object
* @return the extended size attribute
*/
lv_coord_t lv_obj_get_ext_draw_pad(const lv_obj_t * obj);
/*-----------------
* Appearance get
*---------------*/
/**
* Get the style pointer of an object (if NULL get style of the parent)
* @param obj pointer to an object
* @return pointer to a style
*/
const lv_style_t * lv_obj_get_style(const lv_obj_t * obj);
/*-----------------
* Attribute get
*----------------*/
/**
* Get the hidden attribute of an object
* @param obj pointer to an object
* @return true: the object is hidden
*/
bool lv_obj_get_hidden(const lv_obj_t * obj);
/**
* Get the click enable attribute of an object
* @param obj pointer to an object
* @return true: the object is clickable
*/
bool lv_obj_get_click(const lv_obj_t * obj);
/**
* Get the top enable attribute of an object
* @param obj pointer to an object
* @return true: the auto top feature is enabled
*/
bool lv_obj_get_top(const lv_obj_t * obj);
/**
* Get the drag enable attribute of an object
* @param obj pointer to an object
* @return true: the object is dragable
*/
bool lv_obj_get_drag(const lv_obj_t * obj);
/**
* Get the directions an object can be dragged
* @param obj pointer to an object
* @return bitwise OR of allowed directions an object can be dragged in
*/
lv_drag_dir_t lv_obj_get_drag_dir(const lv_obj_t * obj);
/**
* Get the drag throw enable attribute of an object
* @param obj pointer to an object
* @return true: drag throw is enabled
*/
bool lv_obj_get_drag_throw(const lv_obj_t * obj);
/**
* Get the drag parent attribute of an object
* @param obj pointer to an object
* @return true: drag parent is enabled
*/
bool lv_obj_get_drag_parent(const lv_obj_t * obj);
/**
* Get the drag parent attribute of an object
* @param obj pointer to an object
* @return true: drag parent is enabled
*/
bool lv_obj_get_parent_event(const lv_obj_t * obj);
/**
* Get the opa scale enable parameter
* @param obj pointer to an object
* @return true: opa scaling is enabled for this object and all children; false: no opa scaling
*/
lv_opa_t lv_obj_get_opa_scale_enable(const lv_obj_t * obj);
/**
* Get the opa scale parameter of an object
* @param obj pointer to an object
* @return opa scale [0..255]
*/
lv_opa_t lv_obj_get_opa_scale(const lv_obj_t * obj);
/**
* Get the protect field of an object
* @param obj pointer to an object
* @return protect field ('OR'ed values of `lv_protect_t`)
*/
uint8_t lv_obj_get_protect(const lv_obj_t * obj);
/**
* Check at least one bit of a given protect bitfield is set
* @param obj pointer to an object
* @param prot protect bits to test ('OR'ed values of `lv_protect_t`)
* @return false: none of the given bits are set, true: at least one bit is set
*/
bool lv_obj_is_protected(const lv_obj_t * obj, uint8_t prot);
/**
* Get the signal function of an object
* @param obj pointer to an object
* @return the signal function
*/
lv_signal_cb_t lv_obj_get_signal_cb(const lv_obj_t * obj);
/**
* Get the design function of an object
* @param obj pointer to an object
* @return the design function
*/
lv_design_cb_t lv_obj_get_design_cb(const lv_obj_t * obj);
/**
* Get the event function of an object
* @param obj pointer to an object
* @return the event function
*/
lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj);
/*------------------
* Other get
*-----------------*/
/**
* Get the ext pointer
* @param obj pointer to an object
* @return the ext pointer but not the dynamic version
* Use it as ext->data1, and NOT da(ext)->data1
*/
void * lv_obj_get_ext_attr(const lv_obj_t * obj);
/**
* Get object's and its ancestors type. Put their name in `type_buf` starting with the current type.
* E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
* @param obj pointer to an object which type should be get
* @param buf pointer to an `lv_obj_type_t` buffer to store the types
*/
void lv_obj_get_type(lv_obj_t * obj, lv_obj_type_t * buf);
#if LV_USE_USER_DATA
/**
* Get the object's user data
* @param obj pointer to an object
* @return user data
*/
lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj);
/**
* Get a pointer to the object's user data
* @param obj pointer to an object
* @return pointer to the user data
*/
lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj);
/**
* Set the object's user data. The data will be copied.
* @param obj pointer to an object
* @param data user data
*/
void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data);
#endif
#if LV_USE_GROUP
/**
* Get the group of the object
* @param obj pointer to an object
* @return the pointer to group of the object
*/
void * lv_obj_get_group(const lv_obj_t * obj);
/**
* Tell whether the object is the focused object of a group or not.
* @param obj pointer to an object
* @return true: the object is focused, false: the object is not focused or not in a group
*/
bool lv_obj_is_focused(const lv_obj_t * obj);
#endif
/**********************
* MACROS
**********************/
/**
* Helps to quickly declare an event callback function.
* Will be expanded to: `void <name> (lv_obj_t * obj, lv_event_t e)`
*
* Examples:
* static LV_EVENT_CB_DECLARE(my_event1); //Protoype declaration
*
* static LV_EVENT_CB_DECLARE(my_event1)
* {
* if(e == LV_EVENT_CLICKED) {
* lv_obj_set_hidden(obj ,true);
* }
* }
*/
#define LV_EVENT_CB_DECLARE(name) void name(lv_obj_t * obj, lv_event_t e)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_OBJ_H*/

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H
#define WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H
#ifdef __cplusplus
extern "C" {
#endif
//#include "bi-inc/wgl_shared_utils.h" /* shared types between app and native */
/*
#include "lvgl-compatible/lv_types.h"
#include "lvgl-compatible/lv_obj.h"
#include "lvgl-compatible/lv_btn.h"
#include "lvgl-compatible/lv_cb.h"
#include "lvgl-compatible/lv_label.h"
#include "lvgl-compatible/lv_list.h"
*/
#include "src/lv_version.h"
#include "src/lv_misc/lv_log.h"
#include "src/lv_misc/lv_task.h"
#include "src/lv_misc/lv_math.h"
//#include "src/lv_misc/lv_async.h"
//#include "src/lv_hal/lv_hal.h"
#include "src/lv_core/lv_obj.h"
#include "src/lv_core/lv_group.h"
#include "src/lv_core/lv_refr.h"
#include "src/lv_core/lv_disp.h"
#include "src/lv_themes/lv_theme.h"
#include "src/lv_font/lv_font.h"
#include "src/lv_font/lv_font_fmt_txt.h"
#include "src/lv_objx/lv_btn.h"
#include "src/lv_objx/lv_imgbtn.h"
#include "src/lv_objx/lv_img.h"
#include "src/lv_objx/lv_label.h"
#include "src/lv_objx/lv_line.h"
#include "src/lv_objx/lv_page.h"
#include "src/lv_objx/lv_cont.h"
#include "src/lv_objx/lv_list.h"
#include "src/lv_objx/lv_chart.h"
#include "src/lv_objx/lv_table.h"
#include "src/lv_objx/lv_cb.h"
#include "src/lv_objx/lv_bar.h"
#include "src/lv_objx/lv_slider.h"
#include "src/lv_objx/lv_led.h"
#include "src/lv_objx/lv_btnm.h"
#include "src/lv_objx/lv_kb.h"
#include "src/lv_objx/lv_ddlist.h"
#include "src/lv_objx/lv_roller.h"
#include "src/lv_objx/lv_ta.h"
#include "src/lv_objx/lv_canvas.h"
#include "src/lv_objx/lv_win.h"
#include "src/lv_objx/lv_tabview.h"
#include "src/lv_objx/lv_tileview.h"
#include "src/lv_objx/lv_mbox.h"
#include "src/lv_objx/lv_gauge.h"
#include "src/lv_objx/lv_lmeter.h"
#include "src/lv_objx/lv_sw.h"
#include "src/lv_objx/lv_kb.h"
#include "src/lv_objx/lv_arc.h"
#include "src/lv_objx/lv_preload.h"
#include "src/lv_objx/lv_calendar.h"
#include "src/lv_objx/lv_spinbox.h"
#include "src/lv_draw/lv_img_cache.h"
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H */

View File

@ -0,0 +1,11 @@
#include "lvgl.h"
int main()
{
return 0;
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_H
#define WAMR_GRAPHIC_LIBRARY_H
#ifdef __cplusplus
extern "C" {
#endif
#include "bi-inc/wgl_shared_utils.h" /* shared types between app and native */
#include "inc/wgl_types.h"
#include "inc/wgl_obj.h"
#include "inc/wgl_btn.h"
#include "inc/wgl_cb.h"
#include "inc/wgl_label.h"
#include "inc/wgl_list.h"
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_H */

View File

@ -0,0 +1,95 @@
WASM Graphic Layer (WGL)
=======
The WGL builds the littlevgl v6.0 into the runtime and exports a API layer for WASM appication programming graphic user interfaces. This approach will makes the WASM application small footprint. Another option will be built the whole littlevgl library into WASM, which is how the sample littlevgl is implemented.
# Challenges
When the littlevgl library is compiled into the runtime, all the widget data is actually located in the runtime native space. As the WASM sandbox won't allow the WASM application to directly access the native data, it introduced a few problems for the API porting:
1. Reference to the widget object
Almost each littlevgl API will take widget object as the first argument, which leads to either read or write the data associated with the object. We have to prevent the WASM app utilize this to access unauthorized the memmory.
The solution is to track the objects created by the WASM App in the native layer. Every access to the object must be validated in advance. To simplify each native wrapper function, the wgl_native_func_call() will do the validation for the object presented in the first argument.
When multiple WASM apps are creating their own UI, the object will be also validated for his owner module instance.
2. Access the object properties
The data structure of widget objects is no longer visible to the applications. The app has to call APIs to get/set the properties of an object.
3. Pass function arguments in stucture pointers
We have to do serialization for the structure passing between the WASM and native.
4. Callbacks
# API compatibility with littlevgl
We wish the application continue to use the littlevgl API and keep existing header files inclusion, however it is also a bit challenging.
Firstly we have to redefine some data types such as lv_obj_t in the APIs exposed to the WASM app.
'''
typedef void lv_obj_t;
'''
# Prepare the lvgl header files for WASM applicaitons
Run the below script to setup the lvgl header files for the wasm appliation.
```
core/app-framework/wgl/app/prepare_headers.sh
```
The script is also automatically executed after downloading the lvgl repo in the wamr-sdk building process.
# How to extend a little vgl wideget
Currently the wgl has exported the API for a few common used widgets such as button, label etc.
Refer to the implementation of these widgets for extending other widgets.

28
core/deps/download.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
DEPS_ROOT=$(cd "$(dirname "$0")/" && pwd)
cd ${DEPS_ROOT}
if [ ! -d "lvgl" ]; then
echo "git pull lvgl..."
git clone https://github.com/littlevgl/lvgl.git --branch v6.0.1
[ $? -eq 0 ] || exit $?
../app-framework/wgl/app/prepare_headers.sh
fi
if [ ! -d "lv_drivers" ]; then
echo "git pull lv_drivers..."
git clone https://github.com/littlevgl/lv_drivers.git
[ $? -eq 0 ] || exit $?
fi
if [ ! -d "tlsf" ]; then
echo "git pull tlsf..."
git clone https://github.com/mattconte/tlsf
[ $? -eq 0 ] || exit $?
#cd ${WAMR_DIR}/core/shared/mem-alloc
fi
exit 0

View File

@ -40,16 +40,14 @@ Build and Run
- Build</br>
`./build.sh`</br>
All binaries are in "out", which contains "host_tool", "lvgl_native_ui_app", "ui_app.wasm", "ui_app_lvgl_compatible.wasm" and "wasm_runtime_wgl".
- Run native Linux application</br>
`./lvgl_native_ui_app`</br>
All binaries are in "out", which contains "host_tool", "ui_decrease.wasm", "ui_increase.wasm" and "wasm_runtime_wgl".
- Run WASM VM Linux applicaton & install WASM APP</br>
First start wasm_runtime_wgl in server mode.</br>
`./wasm_runtime_wgl -s`</br>
Then install wasm APP use host tool.</br>
`./host_tool -i ui_app -f ui_app.wasm`</br>
`./host_tool -i ui_app -f ui_app_lvgl_compatible.wasm`</br>
`./host_tool -i inc -f ui_increase.wasm`</br>
`./host_tool -i dec -f ui_decrease.wasm`</br>
@ -107,11 +105,11 @@ https://docs.zephyrproject.org/latest/getting_started/index.html</br>
- Install WASM application to Zephyr using host_tool</br>
First, connect PC and STM32 with UART. Then install to use host_tool.</br>
`./host_tool -D /dev/ttyUSBXXX -i ui_app -f ui_app.wasm`
`./host_tool -D /dev/ttyUSBXXX -i inc -f ui_increase.wasm`
- Install AOT version WASM application
`wamrc --target=thumbv7 --target-abi=eabi --cpu=cortex-m7 -o ui_app.aot ui_app.wasm`
`./host_tool -D /dev/ttyUSBXXX -i ui_app -f ui_app.aot`
`wamrc --target=thumbv7 --target-abi=eabi --cpu=cortex-m7 -o ui_app.aot ui_increase.wasm`
`./host_tool -D /dev/ttyUSBXXX -i inc -f ui_app.aot`

View File

@ -25,21 +25,8 @@ rm -rf ${OUT_DIR}
mkdir ${OUT_DIR}
cd ${WAMR_DIR}/core/shared/mem-alloc
if [ ! -d "tlsf" ]; then
git clone https://github.com/mattconte/tlsf
fi
cd ${WAMR_DIR}/core/deps
if [ ! -d "lvgl" ]; then
git clone https://github.com/littlevgl/lvgl.git --branch v6.0.1
fi
if [ ! -d "lv_drivers" ]; then
git clone https://github.com/littlevgl/lv_drivers.git
fi
echo -e "\n\n"
echo "##################### 0. build wamr-sdk gui start#####################"
echo "##################### 1. build wamr-sdk gui start#####################"
cd ${WAMR_DIR}/wamr-sdk
./build_sdk.sh -n gui -x ${WAMR_RUNTIME_CFG} -e ${LV_CFG_PATH}
[ $? -eq 0 ] || exit $?
@ -47,23 +34,6 @@ cd ${WAMR_DIR}/wamr-sdk
echo "#####################build wamr-sdk success"
echo -e "\n\n"
echo "##################### 1. build native-ui-app start#####################"
cd $BUILD_DIR
mkdir -p lvgl-native-ui-app
cd lvgl-native-ui-app
$cmakewrap ${PROJECT_DIR}/lvgl-native-ui-app
[ $? -eq 0 ] || exit $?
$makewrap
if [ $? != 0 ];then
echo "BUILD_FAIL native-ui-app $?\n"
exit 2
fi
echo $PWD
cp lvgl_native_ui_app ${OUT_DIR}
echo "#####################build native-ui-app success"
echo -e "\n\n"
echo "##################### 2. build wasm runtime start#####################"
cd $BUILD_DIR
@ -94,20 +64,7 @@ echo "#####################build host-tool success"
echo -e "\n\n"
echo "##################### 3. build wasm ui app start#####################"
cd ${PROJECT_DIR}/wasm-apps/wgl
cd ${PROJECT_DIR}/wasm-apps
export OUT_DIR=${OUT_DIR}
./build_apps.sh
rm -rf build
mkdir build && cd build
$cmakewrap .. -DCMAKE_TOOLCHAIN_FILE=${WAMR_DIR}/wamr-sdk/out/gui/app-sdk/wamr_toolchain.cmake
$makewrap
[ $? -eq 0 ] || exit $?
mv ui_app.wasm ${OUT_DIR}/
# $makewrap
# mv ui_app.wasm ${OUT_DIR}/
cd ${PROJECT_DIR}/wasm-apps/lvgl-compatible
$makewrap
[ $? -eq 0 ] || exit $?
mv ui_app_lvgl_compatible.wasm ${OUT_DIR}/
echo "##################### build wasm ui app end#####################"

View File

@ -1,43 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required (VERSION 2.8.2)
message ("lvgl_native_ui_app...")
project (lvgl_native_ui_app)
#################################################################
# Currently build as 64-bit by default. Set to "NO" to build 32-bit binaries.
set (BUILD_AS_64BIT_SUPPORT "YES")
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (${BUILD_AS_64BIT_SUPPORT} STREQUAL "YES")
# Add -fPIC flag if build as 64-bit
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
else ()
add_definitions (-m32)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif ()
endif ()
set(WAMR_DEPS_DIR ../../../core/deps)
set(LVGL_SOURCE_DIR ${WAMR_DEPS_DIR}/lvgl)
set(LVGL_DRIVER_DIR ${WAMR_DEPS_DIR}/lv_drivers)
#################################
add_definitions(-DLV_CONF_INCLUDE_SIMPLE)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${WAMR_DEPS_DIR})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../lv_config)
file(GLOB_RECURSE INCLUDES "${LVGL_DRIVER_DIR}/*.h" "${LVGL_SOURCE_DIR}/*.h" "./*.h" )
file(GLOB_RECURSE SOURCES "${LVGL_DRIVER_DIR}/*.c" "${LVGL_SOURCE_DIR}/*.c" )
add_executable(lvgl_native_ui_app main.c get_time.c ${SOURCES} ${INCLUDES})
target_link_libraries(lvgl_native_ui_app PRIVATE SDL2 )

View File

@ -1,8 +0,0 @@
MIT licence
Copyright (c) 2016 Gábor Kiss-Vámosi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,11 +0,0 @@
#include <sys/time.h>
#include "system_header.h"
int time_get_ms()
{
static struct timeval tv;
gettimeofday(&tv, NULL);
long long time_in_mill = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
return (int) time_in_mill;
}

View File

@ -1,153 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
/**
* @file main
*
*/
/*********************
* INCLUDES
*********************/
#define _DEFAULT_SOURCE /* needed for usleep() */
#include <stdlib.h>
#include <unistd.h>
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
#include <SDL2/SDL.h>
#include "lvgl/lvgl.h"
#include "lv_drivers/display/monitor.h"
#include "lv_drivers/indev/mouse.h"
#include "lv_drivers/indev/mousewheel.h"
#include "lv_drivers/indev/keyboard.h"
/*********************
* DEFINES
*********************/
/*On OSX SDL needs different handling*/
#if defined(__APPLE__) && defined(TARGET_OS_MAC)
# if __APPLE__ && TARGET_OS_MAC
#define SDL_APPLE
# endif
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void hal_init(void);
static void btn_event_cb(lv_obj_t * btn, lv_event_t event);
/**********************
* STATIC VARIABLES
**********************/
uint32_t count = 0;
char count_str[11] = { 0 };
lv_obj_t *hello_world_label;
lv_obj_t *count_label;
lv_obj_t * btn1;
lv_obj_t * label_count1;
int label_count1_value = 0;
char label_count1_str[11] = { 0 };
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
int main(int argc, char ** argv)
{
(void) argc; /*Unused*/
(void) argv; /*Unused*/
/*Initialize LittlevGL*/
lv_init();
/*Initialize the HAL (display, input devices, tick) for LittlevGL*/
hal_init();
hello_world_label = lv_label_create(lv_disp_get_scr_act(NULL), NULL);
lv_label_set_text(hello_world_label, "Hello world!");
lv_obj_align(hello_world_label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
count_label = lv_label_create(lv_disp_get_scr_act(NULL), NULL);
lv_obj_align(count_label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
btn1 = lv_btn_create(lv_disp_get_scr_act(NULL), NULL); /*Create a button on the currently loaded screen*/
lv_obj_set_event_cb(btn1, btn_event_cb); /*Set function to be called when the button is released*/
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 20); /*Align below the label*/
/*Create a label on the button*/
lv_obj_t * btn_label = lv_label_create(btn1, NULL);
lv_label_set_text(btn_label, "Click ++");
label_count1 = lv_label_create(lv_disp_get_scr_act(NULL), NULL);
lv_label_set_text(label_count1, "0");
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
while(1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
if ((count % 100) == 0) {
snprintf(count_str, sizeof(count_str), "%d", count/ 100);
lv_label_set_text(count_label, count_str);
}
lv_task_handler();
++count;
usleep(10 * 1000); /*Just to let the system breath*/
}
return 0;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
*/
static void hal_init(void)
{
/* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
monitor_init();
/*Create a display buffer*/
static lv_disp_buf_t disp_buf1;
static lv_color_t buf1_1[320*10];
lv_disp_buf_init(&disp_buf1, buf1_1, NULL, 320*10);
/*Create a display*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.buffer = &disp_buf1;
disp_drv.flush_cb = monitor_flush; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/
// disp_drv.hor_res = 200;
// disp_drv.ver_res = 100;
lv_disp_drv_register(&disp_drv);
/* Add the mouse as input device
* Use the 'mouse' driver which reads the PC's mouse*/
mouse_init();
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
lv_indev_drv_register(&indev_drv);
}
static void btn_event_cb(lv_obj_t * btn, lv_event_t event)
{
if(event == LV_EVENT_RELEASED) {
label_count1_value++;
snprintf(label_count1_str, sizeof(label_count1_str),
"%d", label_count1_value);
lv_label_set_text(label_count1, label_count1_str);
}
}

View File

@ -0,0 +1,44 @@
#!/bin/bash
APPS_ROOT=$(cd "$(dirname "$0")/" && pwd)
cd ${APPS_ROOT}
echo "OUT_DIR: ${OUT_DIR}"
if [ -z ${OUT_DIR} ]; then
OUT_DIR=${APPS_ROOT}/out
echo "set the wasm app folder: ${OUT_DIR}"
if [ -d ${OUT_DIR} ]; then
rm -rf ${OUT_DIR}
echo "removed the present output folder: ${OUT_DIR}"
fi
mkdir ${OUT_DIR}
fi
if [ -z ${WAMR_DIR} ]; then
WAMR_DIR=${APPS_ROOT}/../../..
fi
cd ${APPS_ROOT}/increase
rm -rf build
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=${WAMR_DIR}/wamr-sdk/out/gui/app-sdk/wamr_toolchain.cmake
make
[ $? -eq 0 ] || exit $?
mv ui_increase.wasm ${OUT_DIR}/
# $makewrap
# mv ui_app.wasm ${OUT_DIR}/
cd ${APPS_ROOT}/decrease
make
[ $? -eq 0 ] || exit $?
mv ui_decrease.wasm ${OUT_DIR}/
echo "WASM files generated in folder ${OUT_DIR}"
echo "##################### build WASM APPs finished #####################"

View File

@ -26,4 +26,4 @@ all:
-Wl,--export=on_init -Wl,--export=on_timer_callback \
-Wl,--export=on_widget_event \
-Wl,--export=__heap_base,--export=__data_end \
-o ui_app_lvgl_compatible.wasm
-o ui_decrease.wasm

View File

@ -5,7 +5,7 @@
#include <stdlib.h>
#include "wasm_app.h"
#include "wa-inc/lvgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "wa-inc/timer_wasm_app.h"
extern char g_widget_text[];

View File

@ -13,8 +13,8 @@ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS},-L${WAMR_ROOT_DIR}/wamr-s
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS},--export=on_init,--export=on_timer_callback,--export=on_widget_event,--export=__heap_base,--export=__data_end")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-unused-command-line-argument")
add_executable(ui_app.wasm
add_executable(ui_increase.wasm
${CMAKE_CURRENT_LIST_DIR}/src/main.c
)
target_link_libraries(ui_app.wasm app_framework)
target_link_libraries(ui_increase.wasm app_framework)

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdlib.h>
#include "wasm_app.h"
#include "wa-inc/lvgl/lvgl.h"
#include "wa-inc/timer_wasm_app.h"
extern char g_widget_text[];
static void btn_event_cb(lv_obj_t *btn, lv_event_t event);
uint32_t count = 0;
char count_str[11] = { 0 };
lv_obj_t *hello_world_label;
lv_obj_t *count_label;
lv_obj_t *btn1;
lv_obj_t *label_count1;
int label_count1_value = 1;
char label_count1_str[11] = { 0 };
void timer1_update(user_timer_t timer1)
{
if ((count % 100) == 0) {
snprintf(count_str, sizeof(count_str), "%d", count / 100);
lv_label_set_text(count_label, count_str);
}
++count;
}
void on_init()
{
char *text;
hello_world_label = lv_label_create(NULL, NULL);
lv_label_set_text(hello_world_label, "Hello world!");
text = lv_label_get_text(hello_world_label);
printf("Label text %lu %s \n", strlen(text), text);
lv_obj_align(hello_world_label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
count_label = lv_label_create(NULL, NULL);
lv_obj_align(count_label, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
btn1 = lv_btn_create(NULL, NULL); /*Create a button on the currently loaded screen*/
lv_obj_set_event_cb(btn1, btn_event_cb); /*Set function to be called when the button is released*/
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align below the label*/
/*Create a label on the button*/
lv_obj_t *btn_label = lv_label_create(btn1, NULL);
lv_label_set_text(btn_label, "Click ++");
label_count1 = lv_label_create(NULL, NULL);
lv_label_set_text(label_count1, "1");
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
/* set up a timer */
user_timer_t timer;
timer = api_timer_create(10, true, false, timer1_update);
if (timer)
api_timer_restart(timer, 10);
else
printf("Fail to create timer.\n");
}
static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
{
if(event == LV_EVENT_RELEASED) {
label_count1_value++;
snprintf(label_count1_str, sizeof(label_count1_str),
"%d", label_count1_value);
lv_label_set_text(label_count1, label_count1_str);
if (label_count1_value == 100)
label_count1_value = 0;
}
}

View File

@ -1,72 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdlib.h>
#include "wasm_app.h"
#include "wa-inc/wgl.h"
#include "wa-inc/timer_wasm_app.h"
static void btn_event_cb(wgl_obj_t btn, wgl_event_t event);
uint32_t count = 0;
char count_str[11] = { 0 };
wgl_obj_t hello_world_label;
wgl_obj_t count_label;
wgl_obj_t btn1;
wgl_obj_t label_count1;
int label_count1_value = 0;
char label_count1_str[11] = { 0 };
void timer1_update(user_timer_t timer1)
{
if ((count % 100) == 0) {
snprintf(count_str, sizeof(count_str), "%d", count / 100);
wgl_label_set_text(count_label, count_str);
}
++count;
}
void on_init()
{
hello_world_label = wgl_label_create((wgl_obj_t)NULL, (wgl_obj_t)NULL);
wgl_label_set_text(hello_world_label, "Hello world!");
wgl_obj_align(hello_world_label, (wgl_obj_t)NULL, WGL_ALIGN_IN_TOP_LEFT, 0, 0);
count_label = wgl_label_create((wgl_obj_t)NULL, (wgl_obj_t)NULL);
wgl_obj_align(count_label, (wgl_obj_t)NULL, WGL_ALIGN_IN_TOP_MID, 0, 0);
btn1 = wgl_btn_create((wgl_obj_t)NULL, (wgl_obj_t)NULL); /*Create a button on the currently loaded screen*/
wgl_obj_set_event_cb(btn1, btn_event_cb); /*Set function to be called when the button is released*/
wgl_obj_align(btn1, (wgl_obj_t)NULL, WGL_ALIGN_CENTER, 0, 0); /*Align below the label*/
/*Create a label on the button*/
wgl_obj_t btn_label = wgl_label_create(btn1, (wgl_obj_t)NULL);
wgl_label_set_text(btn_label, "Click ++");
label_count1 = wgl_label_create((wgl_obj_t)NULL, (wgl_obj_t)NULL);
wgl_label_set_text(label_count1, "0");
wgl_obj_align(label_count1, (wgl_obj_t)NULL, WGL_ALIGN_IN_BOTTOM_MID, 0, 0);
/* set up a timer */
user_timer_t timer;
timer = api_timer_create(10, true, false, timer1_update);
if (timer)
api_timer_restart(timer, 10);
else
printf("Fail to create timer.\n");
}
static void btn_event_cb(wgl_obj_t btn, wgl_event_t event)
{
if(event == WGL_EVENT_RELEASED) {
label_count1_value++;
snprintf(label_count1_str, sizeof(label_count1_str),
"%d", label_count1_value);
wgl_label_set_text(label_count1, label_count1_str);
//wgl_cont_set_fit4(btn, WGL_FIT_FLOOD, WGL_FIT_FLOOD, WGL_FIT_FLOOD, WGL_FIT_FLOOD);
//wgl_obj_clean(btn);
}
}

View File

@ -75,6 +75,13 @@ if [ ! -f "/opt/wasi-sdk/bin/clang" ]; then
exit 1
fi
echo "download dependent external repositories.."
${wamr_root_dir}/core/deps/download.sh
[ $? -eq 0 ] || exit $?
if [ -z "$PROFILE" ]; then
PROFILE="default"
echo "PROFILE argument not set, using DEFAULT"
@ -166,8 +173,7 @@ if [[ -n "${app_wgl_selected}" ]] || [[ -n "${app_all_selected}" ]]; then
read -a extra_file_path
if [[ -z "${extra_file_path}" ]] || [[ ! -d "${extra_file_path}" ]]; then
echo -e "\033[31mThe extra SDK path is invalid, exiting\033[0m"
exit 1
echo -e "\033[31mThe extra SDK path is empty\033[0m"
else
CM_DEXTRA_SDK_INCLUDE_PATH="-DEXTRA_SDK_INCLUDE_PATH=${extra_file_path}"
fi