build and test pass

This commit is contained in:
Wang Xin 2020-04-12 16:15:54 +08:00
parent 66d6a3986a
commit 4c1558a785
22 changed files with 183 additions and 672 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

@ -10,17 +10,17 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, argv, ARGC)
lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_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 lv_btn_set_toggle(lv_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 lv_btn_set_toggle(lv_obj_t * btn, bool tgl);
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
}
void lv_btn_set_state(lv_obj_t * btn, lv_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 lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
}
void lv_btn_toggle(lv_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 lv_btn_set_ink_in_time(lv_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 lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time);
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_IN_TIME);
}
void lv_btn_set_ink_wait_time(lv_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 lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time);
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_WAIT_TIME);
}
void lv_btn_set_ink_out_time(lv_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 lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time);
// //wasm_btn_set_style(btn, type, style);
//}
//
lv_btn_state_t lv_btn_get_state(const lv_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 lv_btn_get_toggle(const lv_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 lv_btn_get_toggle(const lv_obj_t * btn);
return (bool)argv[0];
}
uint16_t lv_btn_get_ink_in_time(const lv_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 lv_btn_get_ink_in_time(const lv_obj_t * btn);
return (uint16_t)argv[0];
}
uint16_t lv_btn_get_ink_wait_time(const lv_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 lv_btn_get_ink_wait_time(const lv_obj_t * btn);
return (uint16_t)argv[0];
}
uint16_t lv_btn_get_ink_out_time(const lv_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

@ -12,17 +12,17 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_CB_NATIVE_FUNC(id) wasm_cb_native_call(id, argv, ARGC)
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_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 lv_cb_set_text(lv_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;
@ -31,7 +31,7 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt);
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_TEXT);
}
void lv_cb_set_static_text(lv_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;
@ -46,7 +46,7 @@ void lv_cb_set_static_text(lv_obj_t * cb, const char * txt);
//}
//
static 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;
@ -54,7 +54,7 @@ static unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
return argv[0];
}
static 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;

View File

@ -13,17 +13,17 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_LABEL_NATIVE_FUNC(id) wasm_label_native_call(id, argv, ARGC)
lv_obj_t * lv_label_create(lv_obj_t * par, const lv_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 lv_label_set_text(lv_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;
@ -33,7 +33,7 @@ void lv_label_set_text(lv_obj_t * label, const char * text);
}
void lv_label_set_array_text(lv_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;
@ -43,7 +43,7 @@ void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size
}
void lv_label_set_static_text(lv_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;
@ -53,7 +53,7 @@ void lv_label_set_static_text(lv_obj_t * label, const char * text);
}
void lv_label_set_long_mode(lv_obj_t * label, lv_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;
@ -62,7 +62,7 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
}
void lv_label_set_align(lv_obj_t * label, lv_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;
@ -71,7 +71,7 @@ void lv_label_set_align(lv_obj_t * label, lv_label_align_t align);
}
void lv_label_set_recolor(lv_obj_t * label, bool en);
void lv_label_set_recolor(lv_obj_t * label, bool en)
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -80,7 +80,7 @@ void lv_label_set_recolor(lv_obj_t * label, bool en);
}
void lv_label_set_body_draw(lv_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;
@ -89,7 +89,7 @@ void lv_label_set_body_draw(lv_obj_t * label, bool en);
}
void lv_label_set_anim_speed(lv_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;
@ -98,7 +98,7 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed);
}
void lv_label_set_text_sel_start(lv_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;
@ -107,7 +107,7 @@ void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index);
}
void lv_label_set_text_sel_end(lv_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;
@ -115,7 +115,7 @@ void lv_label_set_text_sel_end(lv_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;
@ -123,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;
@ -137,28 +137,30 @@ char * wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len)
char * lv_label_get_text(const lv_obj_t * label)
{
return NULL;
}
wgl_label_long_mode_t wgl_label_get_long_mode(const wgl_obj_t label)
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];
}
lv_label_long_mode_t lv_label_get_long_mode(const lv_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 lv_label_get_recolor(const lv_obj_t * label);
bool lv_label_get_recolor(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -167,7 +169,7 @@ bool lv_label_get_recolor(const lv_obj_t * label);
}
bool lv_label_get_body_draw(const lv_obj_t * label);
bool lv_label_get_body_draw(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -176,7 +178,7 @@ bool lv_label_get_body_draw(const lv_obj_t * label);
}
uint16_t lv_label_get_anim_speed(const lv_obj_t * label);
uint16_t lv_label_get_anim_speed(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -185,7 +187,7 @@ uint16_t lv_label_get_anim_speed(const lv_obj_t * label);
}
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_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;
@ -196,7 +198,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
}
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_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;
@ -207,7 +209,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos);
}
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_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;
@ -218,7 +220,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos);
}
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label);
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -227,7 +229,7 @@ uint16_t lv_label_get_text_sel_start(const lv_obj_t * label);
}
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label);
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label)
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -236,7 +238,7 @@ uint16_t lv_label_get_text_sel_end(const lv_obj_t * label);
}
void lv_label_ins_text(lv_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;
@ -247,7 +249,7 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt);
}
void lv_label_cut_text(lv_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

@ -13,7 +13,7 @@
#define CALL_LIST_NATIVE_FUNC(id) wasm_list_native_call(id, argv, ARGC)
lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy);
lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
{
uint32 argv[2] = {0};
@ -21,7 +21,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_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];
}
//
//
@ -31,7 +31,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy);
//}
//
lv_obj_t * lv_list_add_btn(lv_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};
@ -41,7 +41,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * t
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

@ -15,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;
@ -25,29 +24,29 @@ static obj_evt_cb_t *g_obj_evt_cb_list = NULL;
/* For lvgl compatible */
char g_widget_text[100];
lv_res_t lv_obj_del(lv_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 lv_obj_del_async(struct _lv_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 lv_obj_clean(lv_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 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);
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;
@ -58,7 +57,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_ALIGN);
}
lv_event_cb_t lv_obj_get_event_cb(const lv_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) {
@ -71,7 +70,7 @@ lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj);
return NULL;
}
void lv_obj_set_event_cb(lv_obj_t * obj, lv_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};
@ -103,7 +102,7 @@ void lv_obj_set_event_cb(lv_obj_t * obj, lv_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

@ -30,9 +30,24 @@ Firstly we have to redefine some data types such as lv_obj_t in the APIs exposed
typedef void lv_obj_t;
'''
Secondly, as the littlevgl source code is no longer compiled and linked with the WASM app source codes, the compilation won't be successfully while including the original littvgl header files.
# 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,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

@ -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

@ -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[];
@ -18,7 +18,7 @@ lv_obj_t *hello_world_label;
lv_obj_t *count_label;
lv_obj_t *btn1;
lv_obj_t *label_count1;
int label_count1_value = 100;
int label_count1_value = 1;
char label_count1_str[11] = { 0 };
void timer1_update(user_timer_t timer1)
@ -49,10 +49,10 @@ void on_init()
/*Create a label on the button*/
lv_obj_t *btn_label = lv_label_create(btn1, NULL);
lv_label_set_text(btn_label, "Click --");
lv_label_set_text(btn_label, "Click ++");
label_count1 = lv_label_create(NULL, NULL);
lv_label_set_text(label_count1, "100");
lv_label_set_text(label_count1, "1");
lv_obj_align(label_count1, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
/* set up a timer */
@ -67,11 +67,12 @@ void on_init()
static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
{
if(event == LV_EVENT_RELEASED) {
label_count1_value--;
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 == 0)
label_count1_value = 100;
if (label_count1_value == 100)
label_count1_value = 0;
}
}

View File

@ -1,29 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
CC = /opt/wasi-sdk/bin/clang
APP_DIR = ${shell pwd}
IWASM_DIR = $(APP_DIR)/../../../../core/iwasm
SDK_DIR = $(APP_DIR)/../../../../wamr-sdk/out/gui/app-sdk
APP_FRAMEWORK_DIR = $(APP_DIR)/../../../../wamr-sdk/out/gui/app-sdk/wamr-app-framework
DEPS_DIR = $(APP_DIR)/../../../../core/deps
CFLAGS += -O3 \
-Wno-int-conversion \
-I$(APP_DIR)/src \
-I$(APP_FRAMEWORK_DIR)/include \
-I${DEPS_DIR}
SRCS += $(APP_DIR)/src/main.c
all:
@$(CC) $(CFLAGS) $(SRCS) \
--target=wasm32 -O3 -z stack-size=2048 -Wl,--initial-memory=65536 \
--sysroot=$(SDK_DIR)/libc-builtin-sysroot \
-L$(APP_FRAMEWORK_DIR)/lib -lapp_framework \
-Wl,--allow-undefined-file=$(SDK_DIR)/libc-builtin-sysroot/share/defined-symbols.txt \
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
-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

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