refactor: replace lv_coord_t with int32_t
This commit is contained in:
@@ -36,8 +36,8 @@ static void anim_x_cb(void * var, int32_t v);
|
||||
*/
|
||||
void lv_example_anim_3(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[] = {LV_GRID_FR(1), 200, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t row_dsc[] = {30, 10, 10, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {LV_GRID_FR(1), 200, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {30, 10, 10, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -7,8 +7,8 @@ static lv_obj_t * obj1 = NULL;
|
||||
static lv_obj_t * obj2 = NULL;
|
||||
static lv_obj_t * obj3 = NULL;
|
||||
|
||||
static const lv_coord_t obj_width = 90;
|
||||
static const lv_coord_t obj_height = 70;
|
||||
static const int32_t obj_width = 90;
|
||||
static const int32_t obj_height = 70;
|
||||
|
||||
static void set_width(void * var, int32_t v)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
void lv_example_grid_1(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
void lv_example_grid_2(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -9,12 +9,12 @@ void lv_example_grid_3(void)
|
||||
/*Column 1: fix width 60 px
|
||||
*Column 2: 1 unit from the remaining free space
|
||||
*Column 3: 2 unit from the remaining free space*/
|
||||
static lv_coord_t col_dsc[] = {60, LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {60, LV_GRID_FR(1), LV_GRID_FR(2), LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Row 1: fix width 50 px
|
||||
*Row 2: 1 unit from the remaining free space
|
||||
*Row 3: fix width 50 px*/
|
||||
static lv_coord_t row_dsc[] = {50, LV_GRID_FR(1), 50, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {50, LV_GRID_FR(1), 50, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
void lv_example_grid_4(void)
|
||||
{
|
||||
static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
|
||||
/*Add space between the columns and move the rows to the bottom (end)*/
|
||||
|
||||
@@ -18,8 +18,8 @@ void lv_example_grid_5(void)
|
||||
{
|
||||
|
||||
/*60x60 cells*/
|
||||
static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
void lv_example_grid_6(void)
|
||||
{
|
||||
|
||||
static lv_coord_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static lv_coord_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t col_dsc[] = {60, 60, 60, LV_GRID_TEMPLATE_LAST};
|
||||
static int32_t row_dsc[] = {45, 45, 45, LV_GRID_TEMPLATE_LAST};
|
||||
|
||||
/*Create a container with grid*/
|
||||
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -38,8 +38,8 @@ void lv_example_fragment_2(void)
|
||||
lv_obj_t * root = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(root, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_layout(root, LV_LAYOUT_GRID);
|
||||
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static const lv_coord_t row_dsc[] = {LV_GRID_FR(1), LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||
static const int32_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
|
||||
static const int32_t row_dsc[] = {LV_GRID_FR(1), LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST};
|
||||
lv_obj_set_grid_dsc_array(root, col_dsc, row_dsc);
|
||||
container = lv_obj_create(root);
|
||||
lv_obj_remove_style_all(container);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
LV_IMAGE_DECLARE(emoji_F617)
|
||||
char path_buf[128];
|
||||
static const void * get_imgfont_path(const lv_font_t * font, uint32_t unicode, uint32_t unicode_next,
|
||||
lv_coord_t * offset_y, void * user_data)
|
||||
int32_t * offset_y, void * user_data)
|
||||
{
|
||||
LV_UNUSED(font);
|
||||
LV_UNUSED(unicode_next);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
void lv_example_monkey_3(void)
|
||||
{
|
||||
static lv_point_t btn_points[3];
|
||||
lv_coord_t hor_res = LV_HOR_RES;
|
||||
int32_t hor_res = LV_HOR_RES;
|
||||
|
||||
/*Create button monkey test*/
|
||||
lv_monkey_config_t config;
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
static void touchpad_init(void);
|
||||
static void touchpad_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static bool touchpad_is_pressed(void);
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
static void touchpad_get_xy(int32_t * x, int32_t * y);
|
||||
|
||||
static void mouse_init(void);
|
||||
static void mouse_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
static bool mouse_is_pressed(void);
|
||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y);
|
||||
static void mouse_get_xy(int32_t * x, int32_t * y);
|
||||
|
||||
static void keypad_init(void);
|
||||
static void keypad_read(lv_indev_t * indev, lv_indev_data_t * data);
|
||||
@@ -182,8 +182,8 @@ static void touchpad_init(void)
|
||||
/*Will be called by the library to read the touchpad*/
|
||||
static void touchpad_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static lv_coord_t last_x = 0;
|
||||
static lv_coord_t last_y = 0;
|
||||
static int32_t last_x = 0;
|
||||
static int32_t last_y = 0;
|
||||
|
||||
/*Save the pressed coordinates and the state*/
|
||||
if(touchpad_is_pressed()) {
|
||||
@@ -208,7 +208,7 @@ static bool touchpad_is_pressed(void)
|
||||
}
|
||||
|
||||
/*Get the x and y coordinates if the touchpad is pressed*/
|
||||
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||
static void touchpad_get_xy(int32_t * x, int32_t * y)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
@@ -250,7 +250,7 @@ static bool mouse_is_pressed(void)
|
||||
}
|
||||
|
||||
/*Get the x and y coordinates if the mouse is pressed*/
|
||||
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y)
|
||||
static void mouse_get_xy(int32_t * x, int32_t * y)
|
||||
{
|
||||
/*Your code comes here*/
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ static void scroll_event_cb(lv_event_t * e)
|
||||
|
||||
lv_area_t cont_a;
|
||||
lv_obj_get_coords(cont, &cont_a);
|
||||
lv_coord_t cont_y_center = cont_a.y1 + lv_area_get_height(&cont_a) / 2;
|
||||
int32_t cont_y_center = cont_a.y1 + lv_area_get_height(&cont_a) / 2;
|
||||
|
||||
lv_coord_t r = lv_obj_get_height(cont) * 7 / 10;
|
||||
int32_t r = lv_obj_get_height(cont) * 7 / 10;
|
||||
uint32_t i;
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(cont);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
@@ -17,13 +17,13 @@ static void scroll_event_cb(lv_event_t * e)
|
||||
lv_area_t child_a;
|
||||
lv_obj_get_coords(child, &child_a);
|
||||
|
||||
lv_coord_t child_y_center = child_a.y1 + lv_area_get_height(&child_a) / 2;
|
||||
int32_t child_y_center = child_a.y1 + lv_area_get_height(&child_a) / 2;
|
||||
|
||||
lv_coord_t diff_y = child_y_center - cont_y_center;
|
||||
int32_t diff_y = child_y_center - cont_y_center;
|
||||
diff_y = LV_ABS(diff_y);
|
||||
|
||||
/*Get the x of diff_y on a circle.*/
|
||||
lv_coord_t x;
|
||||
int32_t x;
|
||||
/*If diff_y is out of the circle use the last point of the circle (the radius)*/
|
||||
if(diff_y >= r) {
|
||||
x = r;
|
||||
|
||||
@@ -11,7 +11,7 @@ static void event_cb(lv_event_t * e)
|
||||
lv_obj_invalidate(chart);
|
||||
}
|
||||
if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_coord_t * s = lv_event_get_param(e);
|
||||
int32_t * s = lv_event_get_param(e);
|
||||
*s = LV_MAX(*s, 20);
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_POST_END) {
|
||||
@@ -25,8 +25,8 @@ static void event_cb(lv_event_t * e)
|
||||
lv_point_t p;
|
||||
lv_chart_get_point_pos_by_id(chart, ser, id, &p);
|
||||
|
||||
lv_coord_t * y_array = lv_chart_get_y_array(chart, ser);
|
||||
lv_coord_t value = y_array[id];
|
||||
int32_t * y_array = lv_chart_get_y_array(chart, ser);
|
||||
int32_t value = y_array[id];
|
||||
|
||||
char buf[16];
|
||||
lv_snprintf(buf, sizeof(buf), LV_SYMBOL_DUMMY"$%d", value);
|
||||
|
||||
@@ -11,8 +11,8 @@ static void draw_event_cb(lv_event_t * e)
|
||||
lv_draw_fill_dsc_t * fill_dsc = draw_task->draw_dsc;
|
||||
|
||||
lv_obj_t * chart = lv_event_get_target(e);
|
||||
lv_coord_t * y_array = lv_chart_get_y_array(chart, lv_chart_get_series_next(chart, NULL));
|
||||
lv_coord_t v = y_array[base_dsc->id2];
|
||||
int32_t * y_array = lv_chart_get_y_array(chart, lv_chart_get_series_next(chart, NULL));
|
||||
int32_t v = y_array[base_dsc->id2];
|
||||
|
||||
uint32_t ratio = v * 255 / 100;
|
||||
fill_dsc->color = lv_color_mix(lv_palette_main(LV_PALETTE_GREEN), lv_palette_main(LV_PALETTE_RED), ratio);
|
||||
|
||||
@@ -10,8 +10,6 @@ def event_cb(e):
|
||||
chart.invalidate()
|
||||
|
||||
if code == lv.EVENT.REFR_EXT_DRAW_SIZE:
|
||||
# s = lv.coord_t.__cast__(e.get_param())
|
||||
# print("s: {:d}".format(s))
|
||||
e.set_ext_draw_size(20)
|
||||
|
||||
elif code == lv.EVENT.DRAW_POST_END:
|
||||
|
||||
@@ -70,9 +70,9 @@ static void add_faded_area(lv_event_t * e)
|
||||
tri_dsc.p[2].y = LV_MAX(draw_line_dsc->p1_y, draw_line_dsc->p2_y);
|
||||
tri_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
|
||||
|
||||
lv_coord_t full_h = lv_obj_get_height(obj);
|
||||
lv_coord_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - obj->coords.y1) * 255 / full_h;
|
||||
lv_coord_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - obj->coords.y1) * 255 / full_h;
|
||||
int32_t full_h = lv_obj_get_height(obj);
|
||||
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - obj->coords.y1) * 255 / full_h;
|
||||
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - obj->coords.y1) * 255 / full_h;
|
||||
tri_dsc.bg_grad.stops[0].color = ser->color;
|
||||
tri_dsc.bg_grad.stops[0].opa = 255 - fract_uppter;
|
||||
tri_dsc.bg_grad.stops[0].frac = 0;
|
||||
|
||||
@@ -15,8 +15,8 @@ static void draw_event_cb(lv_event_t * e)
|
||||
rect_draw_dsc->bg_opa = (LV_OPA_COVER * base_dsc->id2) / (cnt - 1);
|
||||
|
||||
/*Make smaller values blue, higher values red*/
|
||||
lv_coord_t * x_array = lv_chart_get_x_array(obj, ser);
|
||||
lv_coord_t * y_array = lv_chart_get_y_array(obj, ser);
|
||||
int32_t * x_array = lv_chart_get_x_array(obj, ser);
|
||||
int32_t * y_array = lv_chart_get_y_array(obj, ser);
|
||||
/*dsc->id is the tells drawing order, but we need the ID of the point being drawn.*/
|
||||
uint32_t start_point = lv_chart_get_x_start_point(obj, ser);
|
||||
uint32_t p_act = (start_point + base_dsc->id2) % cnt; /*Consider start point to get the index of the array*/
|
||||
|
||||
@@ -11,7 +11,7 @@ static void add_data(lv_timer_t * t)
|
||||
|
||||
uint16_t p = lv_chart_get_point_count(chart);
|
||||
uint16_t s = lv_chart_get_x_start_point(chart, ser);
|
||||
lv_coord_t * a = lv_chart_get_y_array(chart, ser);
|
||||
int32_t * a = lv_chart_get_y_array(chart, ser);
|
||||
|
||||
a[(s + 1) % p] = LV_CHART_POINT_NONE;
|
||||
a[(s + 2) % p] = LV_CHART_POINT_NONE;
|
||||
|
||||
@@ -11,8 +11,8 @@ static void drag_event_handler(lv_event_t * e)
|
||||
lv_point_t vect;
|
||||
lv_indev_get_vect(indev, &vect);
|
||||
|
||||
lv_coord_t x = lv_obj_get_x(obj) + vect.x;
|
||||
lv_coord_t y = lv_obj_get_y(obj) + vect.y;
|
||||
int32_t x = lv_obj_get_x(obj) + vect.x;
|
||||
int32_t y = lv_obj_get_y(obj) + vect.y;
|
||||
lv_obj_set_pos(obj, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ static void mask_event_cb(lv_event_t * e)
|
||||
else if(code == LV_EVENT_DRAW_MAIN_BEGIN) {
|
||||
/* add mask */
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN);
|
||||
lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
|
||||
lv_coord_t font_h = lv_font_get_line_height(font);
|
||||
int32_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
|
||||
int32_t font_h = lv_font_get_line_height(font);
|
||||
|
||||
lv_area_t roller_coords;
|
||||
lv_obj_get_coords(obj, &roller_coords);
|
||||
|
||||
@@ -30,7 +30,7 @@ void lv_example_spinbox_1(void)
|
||||
lv_obj_set_width(spinbox, 100);
|
||||
lv_obj_center(spinbox);
|
||||
|
||||
lv_coord_t h = lv_obj_get_height(spinbox);
|
||||
int32_t h = lv_obj_get_height(spinbox);
|
||||
|
||||
lv_obj_t * btn = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_size(btn, h, h);
|
||||
|
||||
Reference in New Issue
Block a user